/* Expense Tracker V2 CSS Core System */

:root {
    --bg-primary: #0b0c10;
    --bg-secondary: #12141c;
    --bg-card: rgba(26, 29, 41, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f5f6fa;
    --text-secondary: #8b949e;
    
    --primary: #9b59b6;
    --primary-light: rgba(155, 89, 182, 0.2);
    --secondary: #00d2c4;
    
    --green: #2ecc71;
    --green-light: rgba(46, 204, 113, 0.15);
    --red: #e74c3c;
    --red-light: rgba(231, 76, 60, 0.15);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* -------------------------------------------------------------
   Login Page Styling
   ------------------------------------------------------------- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(circle at center, #1b1233 0%, var(--bg-primary) 100%);
    position: relative;
}

.login-background-decor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
}

.bubble-1 {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: 10%;
    right: 15%;
}

.bubble-2 {
    width: 400px;
    height: 400px;
    background: var(--secondary);
    bottom: 10%;
    left: 10%;
}

.login-container {
    width: 100%;
    max-width: 460px;
    padding: 24px;
    z-index: 2;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    border-radius: 28px;
    padding: 40px 30px;
    box-shadow: var(--shadow-premium);
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

.login-header .logo-icon {
    font-size: 54px;
    margin-bottom: 16px;
    display: inline-block;
    filter: drop-shadow(0 0 10px rgba(155, 89, 182, 0.5));
}

.login-header h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, #dcdde1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 36px;
}

.google-auth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.auth-hint {
    font-size: 10px;
    color: var(--text-secondary);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    margin: 24px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider:not(:empty)::before {
    margin-right: .5em;
}

.divider:not(:empty)::after {
    margin-left: .5em;
}

.sandbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sandbox-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px;
    text-decoration: none;
    color: var(--text-primary);
    text-align: left;
    transition: all 0.3s ease;
}

.sandbox-profile:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.sandbox-profile .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
}

.avatar-p { background-color: #9b59b6; }
.avatar-s { background-color: #2ecc71; }
.avatar-l { background-color: #e67e22; }
.avatar-a { background-color: #3498db; }

.profile-details {
    display: flex;
    flex-direction: column;
}

.profile-details .name {
    font-size: 14px;
    font-weight: 600;
}

.profile-details .role {
    font-size: 9px;
    color: var(--text-secondary);
}

/* -------------------------------------------------------------
   Dashboard Portal Layout
   ------------------------------------------------------------- */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 40px;
}

.sidebar-header .logo {
    font-size: 24px;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 800;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background-color: var(--primary-light);
}

.nav-item.active {
    border-left: 3px solid var(--primary);
    border-radius: 0 12px 12px 0;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    object-fit: cover;
}

.user-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.user-info .name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-info .email {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.btn-logout {
    color: var(--red);
    text-decoration: none;
    font-size: 18px;
    transition: transform 0.2s;
}

.btn-logout:hover {
    transform: scale(1.1);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    margin-left: 260px;
    padding: 40px;
    min-height: 100vh;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.content-header h1 {
    font-size: 28px;
    font-weight: 800;
}

.content-header .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Personal Finance metrics grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: '';
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255,255,255,0.015);
    top: -50px;
    right: -50px;
    z-index: 1;
}

.metric-card .title {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-card .value {
    font-size: 28px;
    font-weight: 800;
}

.metric-card.balance {
    background: linear-gradient(135deg, #1b2030 0%, #111422 100%);
    border-color: rgba(155, 89, 182, 0.2);
}

.metric-card.spent {
    background: linear-gradient(135deg, #13241d 0%, #0e1b15 100%);
    border-color: rgba(46, 204, 113, 0.2);
}

.metric-card.due {
    background: linear-gradient(135deg, #2c1a1a 0%, #1e1111 100%);
    border-color: rgba(231, 76, 60, 0.2);
}

/* Secondary Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr;
    gap: 24px;
}

.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 24px;
    height: 100%;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
}

.section-title .btn-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Transactions list UI */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.transaction-card {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 14px 18px;
    transition: background 0.2s;
    cursor: pointer;
}

.transaction-card:hover {
    background: rgba(255, 255, 255, 0.04);
}

.cat-icon-box {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    margin-right: 16px;
}

.trans-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.trans-details .title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.trans-details .title {
    font-size: 14px;
    font-weight: 700;
}

.trans-details .badge {
    font-size: 8px;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 800;
}

.badge-shared {
    background: var(--primary-light);
    color: #df9ffb;
}

.badge-mode {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.trans-details .note {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trans-amount-date {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.trans-amount-date .amount {
    font-size: 15px;
    font-weight: 800;
}

.amount.income { color: var(--green); }
.amount.expense { color: var(--red); }

.trans-amount-date .date {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Category Progress Bars */
.category-progress-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.progress-item {
    display: flex;
    flex-direction: column;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
}

.progress-header .label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.progress-header .color-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
}

/* -------------------------------------------------------------
   Groups and Details Screen
   ------------------------------------------------------------- */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.group-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.group-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
}

.group-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.group-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.group-card-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.group-card-header p {
    font-size: 11px;
    color: var(--text-secondary);
}

.group-balance-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 12px;
}

.group-balance-summary .indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.balance-owed { color: var(--green); }
.balance-owes { color: var(--red); }
.balance-settled { color: var(--text-secondary); }

/* Group Details Hub Layout */
.group-tabs {
    display: flex;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 12px 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
}

.tab-btn.active {
    color: var(--text-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Debts simplified cards */
.debt-transfer-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 12px;
}

.debt-info .transfer-desc {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.debt-info .transfer-amount {
    font-size: 11px;
    color: var(--text-secondary);
}

.btn-settle {
    background: var(--primary);
    border: none;
    color: #fff;
    font-family: var(--font-sans);
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-settle:hover {
    filter: brightness(1.15);
}

/* -------------------------------------------------------------
   Modal Dialog Layout
   ------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 100%;
    max-width: 480px;
    padding: 24px;
    box-shadow: var(--shadow-premium);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 800;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-body p {
    font-size: 13px;
    color: var(--text-secondary);
}

.split-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border-color);
}

/* -------------------------------------------------------------
   Responsive Media Queries & Animations
   ------------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        padding: 0 16px;
        border-right: none;
        border-top: 1px solid var(--border-color);
    }
    
    .sidebar-header, .sidebar-footer .user-info {
        display: none;
    }
    
    .sidebar-nav {
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        margin-bottom: 0;
    }
    
    .nav-item {
        padding: 8px;
        font-size: 10px;
        flex-direction: column;
        gap: 2px;
    }
    
    .nav-item span {
        display: none;
    }
    
    .nav-item::before {
        content: '⚙️'; /* Fallback icon matching */
        font-size: 18px;
    }
    .nav-item-home::before { content: '🏠'; }
    .nav-item-trans::before { content: '📊'; }
    .nav-item-groups::before { content: '👥'; }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
        padding-bottom: 80px; /* Space for bottom nav */
    }
    
    .sandbox-grid {
        grid-template-columns: 1fr;
    }
}
