/* =====================================================
   Bill Splitter — Mobile-First Light Theme
   Clean, modern, card-based UI with teal-indigo accents
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────── */
:root {
    --primary: #4f46e5;
    /* indigo */
    --primary-light: #eef2ff;
    --primary-dark: #3730a3;
    --accent: #06b6d4;
    /* cyan */
    --accent-light: #ecfeff;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --bg: #f9fafb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.05);

    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset & Base ─────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ── Typography ─────────────────────────────────────- */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.4rem;
}

h3 {
    font-size: 1.1rem;
}

p {
    color: var(--text-secondary);
}

small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Navbar ─────────────────────────────────────────- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    gap: 1rem;
}

.navbar .logo h2 {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.nav-links a:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* ── Buttons ────────────────────────────────────────- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.875rem;
    font-family: var(--font);
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

.btn:active {
    transform: translateY(0);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--primary-light);
    box-shadow: none;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}

/* ── Card / Glass Container ──────────────────────── */
.glass-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
}

/* ── Inputs & Forms ─────────────────────────────── */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

input::placeholder {
    color: var(--text-muted);
}

/* Checkboxes & radios — keep native appearance */
input[type="checkbox"],
input[type="radio"] {
    width: 18px !important;
    height: 18px !important;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-appearance: auto;
    appearance: auto;
}

/* ── Dashboard Grid ──────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    padding: 1.25rem;
    max-width: 1300px;
    margin: 0 auto;
    width: 100%;
}

/* ── List Items ──────────────────────────────────── */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 0.625rem;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
    gap: 0.75rem;
}

.list-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: #d1d5db;
    transform: translateY(-1px);
}

.list-item:last-child {
    margin-bottom: 0;
}

/* ── Badges ──────────────────────────────────────── */
.paid-badge,
.unpaid-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.paid-badge {
    background: var(--success-light);
    color: #065f46;
}

.unpaid-badge {
    background: var(--danger-light);
    color: #991b1b;
}

/* ── Alert / Flash Messages ──────────────────────── */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    margin: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    background: var(--warning-light);
    border: 1px solid #fcd34d;
    color: #92400e;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert::before {
    content: "ℹ️";
    flex-shrink: 0;
}

/* ── Section Headers ─────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.section-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ── Stat Cards ──────────────────────────────────── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-value.owe {
    color: var(--danger);
}

.stat-value.owed {
    color: var(--success);
}

.stat-value.neutral {
    color: var(--text-primary);
}

/* ── Chip / Tag ──────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid #c7d2fe;
}

/* ── Empty State ─────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── Bottom Nav (mobile app feel) ────────────────── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 200;
    padding: 0.5rem 0 max(0.5rem, env(safe-area-inset-bottom));
}

.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}

.bottom-nav-item .nav-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.bottom-nav-item.active {
    color: var(--primary);
}

/* FAB (Floating Action Button) */
.fab {
    display: none;
    position: fixed;
    bottom: calc(70px + max(0.5rem, env(safe-area-inset-bottom)));
    right: 1.25rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    font-size: 1.5rem;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    text-decoration: none;
    z-index: 200;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 400;
}

.fab:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(79, 70, 229, 0.5);
}

/* ── Content Area ────────────────────────────────── */
.content {
    flex: 1;
}

/* ── Page Wrapper ────────────────────────────────── */
.page-wrapper {
    max-width: 680px;
    margin: 1.5rem auto;
    padding: 0 1rem 6rem;
}

/* ── Divider ──────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

/* ── Checkbox Item ───────────────────────────────── */
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.95rem;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
    cursor: pointer;
}

/* ========================================
   RESPONSIVE — TABLET
   ======================================== */
@media (max-width: 768px) {
    body {
        padding-bottom: 70px;
    }

    .navbar .nav-links {
        display: none;
        /* hidden on mobile — bottom nav takes over */
    }

    .bottom-nav {
        display: block;
    }

    .fab {
        display: flex;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }

    .glass-container {
        padding: 1.25rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.05rem;
    }
}

/* ========================================
   RESPONSIVE — MOBILE
   ======================================== */
@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .navbar {
        padding: 0.75rem 1rem;
    }

    .navbar .logo h2 {
        font-size: 1.1rem;
    }

    .glass-container {
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    .dashboard-grid {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    h1 {
        font-size: 1.35rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 1.45rem;
    }

    .list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .list-item>div:last-child {
        width: 100%;
    }

    .btn {
        min-height: 44px;
        font-size: 0.9rem;
    }

    input,
    select {
        padding: 0.7rem 0.875rem;
        font-size: 0.95rem;
    }

    .alert {
        margin: 0.75rem;
        font-size: 0.85rem;
    }
}

/* ========================================
   TOUCH DEVICES
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
    }

    .list-item:hover {
        transform: none;
    }

    .nav-links a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    input[type="checkbox"] {
        width: 22px !important;
        height: 22px;
    }
}

/* ── Custom Modal ────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.modal-text {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
}

.modal-actions .btn {
    flex: 1;
}