/* ============================================
   SplitEasy - Stylesheet
   Aesthetic: Bold Editorial / Modern Utility
   ============================================ */

:root {
    --bg:        #0f0f13;
    --bg2:       #17171f;
    --bg3:       #1f1f2e;
    --border:    #2a2a3d;
    --accent:    #f0c040;
    --accent2:   #ff6b6b;
    --accent3:   #4ecdc4;
    --text:      #f0eff5;
    --text-dim:  #8887a0;
    --text-muted:#4d4c62;
    --success:   #4ecdc4;
    --danger:    #ff6b6b;
    --radius:    12px;
    --radius-lg: 20px;
    --shadow:    0 8px 32px rgba(0,0,0,0.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --font-head: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Noise texture overlay ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* ── Navbar ── */
.navbar {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 2rem;
    height: 64px;
    background: rgba(15,15,19,0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text);
    letter-spacing: -0.5px;
}
.brand-icon { font-size: 1.4rem; }
.brand-name { color: var(--accent); }

.nav-links { display: flex; gap: 0.25rem; margin-left: auto; }
.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
    color: var(--text);
    background: var(--bg3);
}
.nav-link.active { color: var(--accent); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: 1.5rem;
}
.nav-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 0.75rem;
    color: #000;
    flex-shrink: 0;
}
.nav-username { font-size: 0.875rem; font-weight: 500; color: var(--text-dim); }
.nav-logout {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.1rem;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    transition: all 0.2s;
}
.nav-logout:hover { color: var(--danger); background: rgba(255,107,107,0.1); }

/* ── Main ── */
.main-content {
    flex: 1;
    padding: 2rem;
    position: relative;
    z-index: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* ── Flash ── */
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}
.flash--success { background: rgba(78,205,196,0.15); border: 1px solid rgba(78,205,196,0.3); color: var(--success); }
.flash--error   { background: rgba(255,107,107,0.15); border: 1px solid rgba(255,107,107,0.3); color: var(--danger); }
.flash--info    { background: rgba(240,192,64,0.12);  border: 1px solid rgba(240,192,64,0.3);  color: var(--accent); }
.flash-close { background: none; border: none; cursor: pointer; color: inherit; font-size: 1.2rem; line-height: 1; }
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* ── Cards ── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: border-color 0.2s;
}
.card:hover { border-color: #3a3a52; }
.card--accent { border-color: rgba(240,192,64,0.3); }

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}
.page-title {
    font-family: var(--font-head);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.1;
}
.page-title span { color: var(--accent); }
.page-subtitle { color: var(--text-dim); font-size: 0.95rem; margin-top: 0.3rem; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.3rem;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn--primary {
    background: var(--accent);
    color: #000;
}
.btn--primary:hover { background: #f7d060; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(240,192,64,0.35); }
.btn--secondary {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn--secondary:hover { background: #27273a; border-color: #3a3a52; }
.btn--danger { background: rgba(255,107,107,0.15); color: var(--danger); border: 1px solid rgba(255,107,107,0.3); }
.btn--danger:hover { background: rgba(255,107,107,0.25); }
.btn--sm { padding: 0.4rem 0.8rem; font-size: 0.82rem; }
.btn--ghost { background: none; color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); background: var(--bg3); }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-dim); margin-bottom: 0.4rem; letter-spacing: 0.3px; }
.form-control {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,192,64,0.12); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Auth Pages ── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.auth-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}
.auth-logo {
    font-family: var(--font-head);
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    text-align: center;
    margin-bottom: 0.3rem;
}
.auth-logo-icon { display: block; text-align: center; font-size: 2.5rem; margin-bottom: 0.5rem; }
.auth-subtitle { text-align: center; color: var(--text-dim); margin-bottom: 2rem; font-size: 0.9rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-dim); }
.auth-footer a { color: var(--accent); text-decoration: none; font-weight: 500; }

/* ── Dashboard Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
}
.stat-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); font-weight: 600; }
.stat-value {
    font-family: var(--font-head);
    font-size: 1.9rem;
    font-weight: 800;
    margin-top: 0.3rem;
    letter-spacing: -1px;
}
.stat-value--green { color: var(--success); }
.stat-value--red   { color: var(--danger); }
.stat-value--gold  { color: var(--accent); }

/* ── Groups Grid ── */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.group-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}
.group-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent3));
    opacity: 0;
    transition: opacity 0.2s;
}
.group-card:hover { border-color: #3a3a52; transform: translateY(-3px); box-shadow: var(--shadow); }
.group-card:hover::before { opacity: 1; }
.group-icon { font-size: 2rem; margin-bottom: 0.8rem; display: block; }
.group-name { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; margin-bottom: 0.3rem; }
.group-meta { font-size: 0.82rem; color: var(--text-dim); display: flex; gap: 1rem; flex-wrap: wrap; }
.group-balance { margin-top: 0.8rem; font-size: 0.9rem; font-weight: 600; }

/* ── Expense List ── */
.expense-list { display: flex; flex-direction: column; gap: 0.5rem; }
.expense-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}
.expense-item:hover { border-color: #3a3a52; }
.expense-cat-icon {
    width: 40px; height: 40px;
    background: var(--bg3);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.expense-info { flex: 1; }
.expense-title { font-weight: 600; font-size: 0.95rem; }
.expense-meta { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.15rem; }
.expense-amount { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; text-align: right; }
.expense-amount .paid-by { display: block; font-family: var(--font-body); font-size: 0.75rem; color: var(--text-dim); font-weight: 400; }
.expense-your-share { font-size: 0.78rem; margin-top: 0.15rem; }
.expense-your-share--owed { color: var(--danger); }
.expense-your-share--lent { color: var(--success); }
.expense-your-share--neutral { color: var(--text-muted); }

/* ── Debt Summary ── */
.debt-list { display: flex; flex-direction: column; gap: 0.75rem; }
.debt-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.debt-arrow { color: var(--text-muted); font-size: 1.2rem; }
.debt-names { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; flex-wrap: wrap; }
.debt-amount { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; color: var(--accent); white-space: nowrap; }
.debt-owed  { color: var(--danger); }
.debt-lent  { color: var(--success); }

/* ── Avatars ── */
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.72rem;
    font-family: var(--font-head);
    font-weight: 700;
    color: #000;
    flex-shrink: 0;
}
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--bg2); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
    background: none; border: none; cursor: pointer;
    padding: 0.7rem 1.2rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dim);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Members ── */
.member-list { display: flex; flex-direction: column; gap: 0.5rem; }
.member-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg3);
    border-radius: var(--radius);
}
.member-name { font-weight: 500; flex: 1; }
.member-email { font-size: 0.82rem; color: var(--text-dim); }
.member-balance { font-weight: 600; font-size: 0.9rem; text-align: right; }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-dim);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; display: block; opacity: 0.5; }
.empty-state-title { font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: 0.5rem; }
.empty-state-text { font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px);
    transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-title { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: 1.4rem; line-height: 1; transition: color 0.2s; }
.modal-close:hover { color: var(--text); }

/* ── Section Header ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.section-title { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Badge ── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge--yellow  { background: rgba(240,192,64,0.15); color: var(--accent); }
.badge--green   { background: rgba(78,205,196,0.15); color: var(--success); }
.badge--red     { background: rgba(255,107,107,0.15); color: var(--danger); }
.badge--neutral { background: var(--bg3); color: var(--text-dim); }

/* ── Split shares ── */
#share-inputs { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.share-input-row { display: flex; align-items: center; gap: 0.75rem; }
.share-input-row .avatar { flex-shrink: 0; }
.share-input-row .form-control { max-width: 120px; }

/* ── Footer ── */
.footer { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* ── Utilities ── */
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.text-dim { color: var(--text-dim); } .text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); } .text-success { color: var(--success); } .text-danger { color: var(--danger); }
.text-right { text-align: right; } .text-center { text-align: center; }
.flex { display: flex; } .flex-1 { flex: 1; } .gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.font-bold { font-weight: 700; } .font-head { font-family: var(--font-head); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.w-full { width: 100%; }

/* ── Responsive ── */
@media (max-width: 640px) {
    .main-content { padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .navbar { padding: 0 1rem; gap: 1rem; }
    .nav-username { display: none; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Admin-Button in Navbar */
.nav-admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    background: rgba(240,192,64,0.12);
    color: var(--accent);
    border: 1px solid rgba(240,192,64,0.3);
    transition: all 0.2s;
    letter-spacing: 0.2px;
}
.nav-admin-btn:hover {
    background: rgba(240,192,64,0.22);
    border-color: rgba(240,192,64,0.6);
    transform: translateY(-1px);
}
