/* ============================================================
   SuperRenta — OpenAI Style Reference
   "Research lab notebook at noon."
   Theme: Light, typographic, editorial canvas.
   Pure white surfaces, near-black type, hairline borders.
   ============================================================ */

:root {
    /* --- OpenAI Colors --- */
    --color-obsidian: #000000;
    --color-graphite: #666666;
    --color-smoke: #8f8f8f;
    --color-paper: #ffffff;
    --color-ash: #f1f1f1;
    --color-hairline: rgba(0, 0, 0, 0.12);
    --color-whisper: rgba(0, 0, 0, 0.04);

    /* Mapped Theme Tokens */
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-elevated: #fbfbfb;
    --surface-hover: #f1f1f1;
    --sidebar: #ffffff;
    --text: #000000;
    --text-secondary: #666666;
    --text-muted: #8f8f8f;
    --border: rgba(0, 0, 0, 0.12);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --hover: rgba(0, 0, 0, 0.04);

    /* Primary Emphasis: Solid Obsidian Black */
    --accent: #000000;
    --accent-hover: #222222;
    --accent-text: #ffffff;
    --accent-soft: rgba(0, 0, 0, 0.05);

    /* Legacy compatibility fallbacks */
    --color-snow: #000000;
    --color-silver-mist: #666666;
    --color-slate: rgba(0, 0, 0, 0.12);
    --color-phosphor-green: #000000;
    --orange: #000000;

    /* Subtle Editorial Status Tones (Monochrome-Disciplined) */
    --status-paid: #000000;
    --status-paid-bg: #f1f1f1;
    --status-pending: #666666;
    --status-pending-bg: rgba(0, 0, 0, 0.04);
    --status-alert: #111111;
    --status-alert-border: rgba(0, 0, 0, 0.25);
    --error: #b91c1c;
    --error-soft: rgba(185, 28, 28, 0.06);

    /* Radii from OpenAI Spec */
    --radius-tags: 9999px;
    --radius-cards: 6px;
    --radius-links: 4px;
    --radius-inputs: 9999px;
    --radius-buttons: 9999px;
    --radius-full: 9999px;
    --radius: 6px;
    --radius-sm: 4px;

    /* Spacing & Sizes */
    --sidebar-width: 240px;
    --topbar-h: 64px;

    /* Typography */
    --font-family: 'OpenAI Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Tracking */
    --tracking-display: -0.03em;
    --tracking-subhead: -0.01em;
    --tracking-body: -0.01em;

    color-scheme: light;
}

[data-theme="dark"] {
    /* --- Dark Mode Tokens (OpenAI Midnight / Research Lab) --- */
    --color-obsidian: #ffffff;
    --color-graphite: #a1a1aa;
    --color-smoke: #71717a;
    --color-paper: #0c0c0e;
    --color-ash: #18181b;
    --color-hairline: rgba(255, 255, 255, 0.12);
    --color-whisper: rgba(255, 255, 255, 0.04);

    --bg: #0c0c0e;
    --surface: #0c0c0e;
    --surface-elevated: #141417;
    --surface-hover: #1f1f23;
    --sidebar: #0c0c0e;
    --text: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border: rgba(255, 255, 255, 0.12);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --hover: rgba(255, 255, 255, 0.04);

    /* Primary Emphasis: White button on dark canvas */
    --accent: #ffffff;
    --accent-hover: #e4e4e7;
    --accent-text: #000000;
    --accent-soft: rgba(255, 255, 255, 0.08);

    --color-snow: #ffffff;
    --color-silver-mist: #a1a1aa;
    --color-slate: rgba(255, 255, 255, 0.12);
    --color-phosphor-green: #ffffff;
    --orange: #ffffff;

    --status-paid: #ffffff;
    --status-paid-bg: #27272a;
    --status-pending: #a1a1aa;
    --status-pending-bg: rgba(255, 255, 255, 0.06);
    --status-alert: #ffffff;
    --status-alert-border: rgba(255, 255, 255, 0.28);
    --error: #ef4444;
    --error-soft: rgba(239, 68, 68, 0.12);

    color-scheme: dark;
}

[data-theme="dark"] .btn-pill-primary {
    background-color: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

[data-theme="dark"] .btn-pill-primary:hover {
    background-color: #e4e4e7;
    border-color: #e4e4e7;
    color: #000000;
}

[data-theme="dark"] .btn-pill-ghost {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.16);
}

[data-theme="dark"] .btn-pill-ghost:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

[data-theme="dark"] .badge-tag--green {
    background-color: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

[data-theme="dark"] .badge-tag--orange {
    background-color: #1f1f23;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .badge-tag--neutral {
    background-color: #121214;
    color: #a1a1aa;
    border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .card-openai,
[data-theme="dark"] .card-supa,
[data-theme="dark"] .card-stat-mini {
    background-color: #121214;
    border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .card-openai:hover,
[data-theme="dark"] .card-supa:hover {
    border-color: rgba(255, 255, 255, 0.22);
}

[data-theme="dark"] .checklist-row {
    background-color: #121215;
    border-color: rgba(255, 255, 255, 0.10);
}

[data-theme="dark"] .checklist-row:hover {
    background-color: #18181c;
    border-color: rgba(255, 255, 255, 0.22);
}

[data-theme="dark"] .checklist-row--paid {
    background-color: #0e0e11;
    border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: #141417;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .brand-logo {
    background-color: #ffffff;
    color: #000000;
}

[data-theme="dark"] .mobile-nav-bottom {
    background-color: rgba(12, 12, 14, 0.94);
    border-top-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .mobile-top-header {
    background-color: #0c0c0e;
    border-bottom-color: rgba(255, 255, 255, 0.12);
}

/* Theme Toggle Button */
.btn-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9999px;
    background-color: transparent;
    border: 1px solid var(--color-hairline);
    color: var(--color-obsidian);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    padding: 0;
}

.btn-theme-toggle:hover {
    background-color: var(--color-ash);
    border-color: rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .btn-theme-toggle:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.theme-icon-sun {
    display: none;
}
.theme-icon-moon {
    display: block;
}

[data-theme="dark"] .theme-icon-sun {
    display: block;
}
[data-theme="dark"] .theme-icon-moon {
    display: none;
}

/* ============================================================
   Base Reset
   ============================================================ */

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

html {
    font-size: 16px;
    background-color: var(--color-paper);
    color: var(--color-obsidian);
    letter-spacing: var(--tracking-body);
}

body {
    font-family: var(--font-family);
    background-color: var(--color-paper);
    color: var(--color-obsidian);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
    font-feature-settings: 'calt' on, 'liga' on;
}

::selection {
    background-color: var(--color-obsidian);
    color: var(--color-paper);
}

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

/* ============================================================
   Layout
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--color-paper);
}

/* Sidebar Desktop */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-paper);
    border-right: 1px solid var(--color-hairline);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    height: var(--topbar-h);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--color-hairline);
}

.brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    background: var(--color-obsidian);
    color: var(--color-paper);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-obsidian);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.brand-tagline {
    font-size: 11px;
    color: var(--color-graphite);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-section-label {
    padding: 10px 12px 6px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-smoke);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-radius: 9999px;
    color: var(--color-graphite);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-item:hover {
    color: var(--color-obsidian);
    background-color: var(--color-whisper);
}

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

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    flex-shrink: 0;
}

.sidebar-bottom {
    padding: 16px 14px;
    border-top: 1px solid var(--color-hairline);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    background-color: var(--color-paper);
}

.topbar {
    min-height: var(--topbar-h);
    padding: 14px 40px;
    background-color: var(--color-paper);
    border-bottom: 1px solid var(--color-hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.topbar-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--color-obsidian);
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.topbar-subtitle {
    font-size: 13px;
    color: var(--color-graphite);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.content {
    flex: 1;
    padding: 32px 40px 64px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   OpenAI Components & Tokens
   ============================================================ */

/* Filled Action Button (The single black period CTA) */
.btn-pill-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--color-obsidian);
    color: #ffffff;
    border: 1px solid var(--color-obsidian);
    border-radius: var(--radius-buttons);
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn-pill-primary:hover {
    background-color: #262626;
    border-color: #262626;
    color: #ffffff;
}

/* Outlined Pill Button (Category chips & secondary actions) */
.btn-pill-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: transparent;
    color: var(--color-obsidian);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-buttons);
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn-pill-ghost:hover {
    background-color: var(--color-ash);
    border-color: rgba(0, 0, 0, 0.2);
    color: var(--color-obsidian);
}

/* Subtle Pill Button */
.btn-pill-subtle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: transparent;
    color: var(--color-graphite);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-buttons);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn-pill-subtle:hover {
    color: var(--color-obsidian);
    background-color: var(--color-ash);
}

/* Danger Pill Button */
.btn-pill-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: transparent;
    color: var(--error);
    border: 1px solid rgba(185, 28, 28, 0.2);
    border-radius: var(--radius-buttons);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn-pill-danger:hover {
    background-color: var(--error-soft);
    border-color: var(--error);
}

/* Cards (OpenAI 6px radius, Pure White, hairline border, no shadows) */
.card-supa,
.card-openai {
    background-color: var(--color-paper);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-cards);
    padding: 24px;
    transition: border-color 0.15s ease;
}

.card-supa:hover,
.card-openai:hover {
    border-color: rgba(0, 0, 0, 0.22);
}

/* Mini Stat Card (Editorial Metric) */
.card-stat-mini {
    background-color: var(--color-paper);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-cards);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-stat-mini__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-graphite);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-stat-mini__value {
    font-size: 28px;
    font-weight: 500;
    color: var(--color-obsidian);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

/* Inputs (OpenAI Pill shape 9999px radius, hairline border, no glow ring) */
.input-supa,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="month"],
input[type="date"],
select,
textarea {
    width: 100%;
    background-color: var(--color-paper);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-inputs);
    padding: 10px 18px;
    color: var(--color-obsidian);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease;
    outline: none;
}

.input-supa::placeholder,
input::placeholder {
    color: var(--color-smoke);
}

.input-supa:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-obsidian);
}

/* Badges / Tag Chips (Pill 9999px) */
.badge-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px;
    border-radius: var(--radius-tags);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-tag--green {
    background-color: #000000;
    color: #ffffff;
    border: 1px solid #000000;
}

.badge-tag--orange {
    background-color: var(--color-ash);
    color: var(--color-obsidian);
    border: 1px solid var(--color-hairline);
}

.badge-tag--red {
    background-color: var(--error-soft);
    color: var(--error);
    border: 1px solid rgba(185, 28, 28, 0.2);
}

.badge-tag--neutral {
    background-color: var(--color-paper);
    color: var(--color-graphite);
    border: 1px solid var(--color-hairline);
}

/* Checklist Row (Responsive Editorial Row) */
.checklist-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background-color: var(--color-paper);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-cards);
    margin-bottom: 8px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.checklist-row:hover {
    border-color: rgba(0, 0, 0, 0.25);
    background-color: #fafafa;
}

.checklist-row--paid {
    background-color: #fbfbfb;
    border-color: rgba(0, 0, 0, 0.08);
}

.checklist-row__info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.checklist-row__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* WhatsApp Icon Button */
.btn-wa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    background-color: #25D366;
    color: #ffffff;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.btn-wa:hover {
    opacity: 0.9;
    color: #ffffff;
}

/* Flash alerts */
.alert-box {
    padding: 12px 18px;
    margin-bottom: 20px;
    border-radius: var(--radius-cards);
    font-size: 14px;
    font-weight: 400;
    border: 1px solid var(--color-hairline);
    background-color: var(--color-ash);
    color: var(--color-obsidian);
}

.alert-box--success {
    background-color: #f7fef9;
    border-color: rgba(0, 0, 0, 0.15);
    color: var(--color-obsidian);
}

.alert-box--danger {
    background-color: #fef2f2;
    border-color: rgba(185, 28, 28, 0.2);
    color: var(--error);
}

.alert-box--info {
    background-color: var(--color-ash);
    color: var(--color-obsidian);
}

/* Mobile Navigation Bar & Drawer */
.mobile-nav-bottom {
    display: none;
}

.mobile-top-header {
    display: none;
}

.mobile-drawer-overlay {
    display: none;
}

/* ============================================================
   100% RESPONSIVE DESIGN (PC & MOBILE)
   ============================================================ */

@media (max-width: 768px) {
    /* Hide desktop sidebar */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Mobile drawer backdrop */
    .mobile-drawer-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 150;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .mobile-drawer-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile Top Header */
    .mobile-top-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        height: calc(56px + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        background-color: var(--color-paper);
        border-bottom: 1px solid var(--color-hairline);
        position: sticky;
        top: 0;
        z-index: 120;
    }

    .mobile-header-brand {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .mobile-hamburger {
        background: transparent;
        border: none;
        color: var(--color-obsidian);
        padding: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Reset Main Content margin */
    .main-content {
        margin-left: 0 !important;
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px)); /* Room for bottom navigation */
    }

    /* Topbar on Mobile */
    .topbar {
        position: static;
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        border-bottom: 1px solid var(--color-hairline);
    }

    .topbar-left {
        width: 100%;
    }

    .topbar-title {
        font-size: 18px;
    }

    .topbar-right {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .topbar-right > * {
        width: 100%;
        justify-content: center;
    }

    /* Content on Mobile */
    .content {
        padding: 16px;
    }

    /* Checklist row on Mobile: NEVER OVERLAP */
    .checklist-row {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 16px;
    }

    .checklist-row__info {
        width: 100%;
        align-items: flex-start;
    }

    .checklist-row__actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        justify-content: stretch;
    }

    .checklist-row__actions-buttons {
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
        flex-wrap: wrap;
    }

    .checklist-row__actions-buttons > * {
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    .checklist-row__actions .btn-pill-primary {
        width: 100%;
        padding: 10px 16px;
    }

    /* Cards and Grids on Mobile */
    .card-stat-mini {
        padding: 16px;
    }

    /* Mobile Bottom Navigation Bar */
    .mobile-nav-bottom {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background-color: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--color-hairline);
        z-index: 140;
        justify-content: space-around;
        align-items: center;
        padding-left: 4px;
        padding-right: 4px;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--color-graphite);
        font-size: 10px;
        font-weight: 500;
        text-decoration: none;
        padding: 4px 2px;
        border-radius: var(--radius-sm);
        transition: color 0.15s ease;
        flex: 1;
        min-width: 0;
        text-align: center;
    }

    .mobile-nav-item.active {
        color: var(--color-obsidian);
        font-weight: 600;
    }

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