/* =============================================================================
   BOILERPLATE - Design system, layout, theme
   ============================================================================= */

/* CSS Variables */
:root {
    /* Main palette - vibrant */
    --mint: #00e676;
    --mint-dark: #00c853;
    --mint-bg: rgba(0, 230, 118, 0.2);

    --sky: #29b6f6;
    --sky-dark: #03a9f4;
    --sky-bg: rgba(41, 182, 246, 0.2);

    --lavender: #ba68c8;
    --lavender-dark: #ab47bc;
    --lavender-bg: rgba(186, 104, 200, 0.2);

    /* Semantic */
    --primary: var(--sky);
    --primary-light: var(--sky-dark);
    --primary-bg: var(--sky-bg);

    --success: var(--mint);
    --success-bg: var(--mint-bg);

    --warning: #ffca28;
    --warning-bg: rgba(255, 202, 40, 0.2);

    --error: #ff5722;
    --error-bg: rgba(255, 87, 34, 0.2);

    /* Buttons */
    --btn-primary-bg: #0a0a0a;
    --btn-primary-text: #ffffff;
    --btn-primary-border: #333333;
    --btn-primary-hover: #1a1a1a;

    /* Dark theme (default) */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #161616;
    --bg-elevated: #1c1c1c;

    --text-primary: #f0f0f0;
    --text-secondary: #9a9a9a;
    --text-muted: #666666;

    --border: #222222;
    --border-light: #333333;

    --toggle-knob: #ffffff;
    --toggle-track: #333333;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #fafaf9;
    --bg-secondary: #f5f5f4;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;

    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --text-muted: #a8a29e;

    --border: #e7e5e4;
    --border-light: #f5f5f4;

    --toggle-knob: #57534e;
    --toggle-track: #d6d3d1;
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

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

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: var(--text-base);
}

/* =============================================================================
   APP LAYOUT
   ============================================================================= */

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    padding-top: var(--safe-top);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    height: 56px;
}

.header-left, .header-right {
    width: 40px;
}

.header-center {
    flex: 1;
    text-align: center;
}

.header-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    color: var(--text-primary);
    transition: background 0.2s;
}

.header-back:hover {
    background: var(--bg-secondary);
}

.header-title {
    font-size: var(--text-base);
    font-weight: 600;
}

.header-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #0a0a0a;
    font-weight: 600;
    font-size: var(--text-sm);
    overflow: hidden;
}

.header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-content {
    flex: 1;
    padding: var(--space-4);
    padding-bottom: calc(80px + var(--safe-bottom));
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--bg-elevated);
    border-top: 2px solid var(--primary);
    padding-bottom: var(--safe-bottom);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(41, 182, 246, 0.15);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-2);
    color: var(--text-muted);
    font-size: var(--text-xs);
    transition: color 0.2s, background 0.2s;
    border-radius: var(--radius-md);
    margin: var(--space-2) var(--space-1);
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

.nav-item.active {
    color: var(--primary);
    background: var(--primary-bg);
    font-weight: 600;
}

.nav-item:hover {
    color: var(--text-secondary);
}

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

/* Flash */
.flash-messages {
    padding: 0 var(--space-4);
}

.flash {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    font-size: var(--text-sm);
    transition: opacity 0.3s;
}

.flash svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success);
}

.flash-error {
    background: var(--error-bg);
    color: var(--error);
}

/* =============================================================================
   CARDS
   ============================================================================= */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}

.card-flat {
    background: var(--bg-secondary);
    border: none;
}

/* Generic list item (row) */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    transition: border-color 0.2s;
}

.list-item:hover {
    border-color: var(--border-light);
}

.list-item-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.list-item-icon svg {
    width: 24px;
    height: 24px;
}

.list-item-body {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.list-item-meta {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: 1px solid var(--btn-primary-border);
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-secondary);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-elevated);
    border-color: var(--text-muted);
}

.btn-large {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
}

.btn-block {
    width: 100%;
}

/* =============================================================================
   FORMS
   ============================================================================= */

.form-group {
    margin-bottom: var(--space-5);
}

.form-group > label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

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

.error-text {
    display: block;
    color: var(--error);
    font-size: var(--text-sm);
    margin-top: var(--space-2);
}

/* Toggle */
.toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    height: 30px;
}

.toggle input {
    display: none;
}

.toggle-slider {
    width: 48px;
    height: 28px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    position: relative;
    transition: background 0.2s;
    display: inline-block;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: var(--toggle-knob);
    border-radius: var(--radius-full);
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

/* =============================================================================
   SECTIONS & EMPTY STATE
   ============================================================================= */

.section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-4);
}

.empty-state {
    text-align: center;
    padding: var(--space-10) var(--space-4);
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    background: var(--sky-bg);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sky);
}

.empty-icon svg {
    width: 32px;
    height: 32px;
}

.empty-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.empty-text {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin-bottom: var(--space-6);
}

/* =============================================================================
   AUTH / LANDING (generic)
   ============================================================================= */

.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: var(--space-6);
    padding-top: calc(var(--space-10) + var(--safe-top));
}

.auth-brand {
    text-align: center;
    margin-bottom: var(--space-8);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
}

.auth-logo svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.auth-tagline {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.auth-title {
    font-size: var(--text-xl);
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--space-6);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-6);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 500;
}

.landing-card {
    text-align: center;
}

.landing-card h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-3);
    line-height: 1.2;
}

.landing-card .subtitle {
    color: var(--text-secondary);
    font-size: var(--text-base);
    margin-bottom: var(--space-6);
    line-height: 1.5;
}

.landing-features {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
    text-align: left;
}

.landing-features .feature {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-base);
    color: var(--text-primary);
}

.landing-features .feature svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
}

.auth-buttons {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.auth-buttons .btn {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    font-weight: 600;
}

.auth-note {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0;
}

/* =============================================================================
   SETTINGS (generic rows)
   ============================================================================= */

.settings-group {
    margin-bottom: var(--space-6);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-label {
    font-weight: 500;
}

.settings-desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* =============================================================================
   OPTION CARDS (generic 2-col choice)
   ============================================================================= */

.option-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-6);
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s;
}

.option-card:hover {
    background: var(--bg-elevated);
}

.option-card.selected,
.option-card:has(input:checked) {
    background: var(--primary-bg);
    border-color: var(--primary);
}

.option-card input {
    display: none;
}

.option-card-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    display: grid;
    place-items: center;
    margin-bottom: var(--space-4);
}

.option-card-icon svg {
    width: 32px;
    height: 32px;
}

.option-card-title {
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.option-card-desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* =============================================================================
   UTILITIES
   ============================================================================= */

.list-unstyled { list-style: none; }

.form-control { width: 100%; }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-primary { color: var(--primary); }

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--primary);
    color: var(--bg-primary);
    border-radius: var(--radius-full);
}

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

@media (max-width: 640px) {
    .hide-mobile { display: none !important; }
}

/* Mobile: auth/landing */
@media (max-width: 480px) {
    .auth-page {
        padding: var(--space-4);
        padding-top: calc(var(--space-6) + var(--safe-top));
        justify-content: center;
    }

    .auth-brand {
        margin-bottom: var(--space-6);
    }

    .auth-logo {
        font-size: var(--text-xl);
    }

    .auth-card {
        padding: var(--space-5);
    }

    .landing-card h1 {
        font-size: var(--text-xl);
    }

    .landing-card .subtitle {
        font-size: var(--text-sm);
    }

    .auth-buttons {
        flex-direction: column;
    }

    .auth-buttons .btn {
        width: 100%;
    }

    .option-grid {
        grid-template-columns: 1fr;
    }
}
