/* --- 🎨 Modern Premium UI Theme --- */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Light Mode (Default) */
    --color-primary: #4A6CF7;
    --color-primary-dark: #3a5bd9;
    --color-secondary: #854AF7;
    --color-background: #F4F7FE;
    --color-card-bg: #FFFFFF;
    --color-text-main: #1b2559;
    --color-text-muted: #8F9BBA;
    --color-border: #E0E5F2;
    --color-success: #05CD99;
    --color-warning: #FFB547;
    --color-danger: #EE5D50;
    --color-input-bg: #F4F7FE;
    --color-bg-secondary: #E6EEFA;
    /* Slightly darker than bg for contrast items */
    --color-progress-bg: #E9EDF7;

    /* Effects */
    --shadow-card: 0px 18px 40px rgba(112, 144, 176, 0.12);
    --shadow-hover: 0px 22px 45px rgba(112, 144, 176, 0.18);
    --shadow-sm: 0px 4px 12px rgba(112, 144, 176, 0.08);
    --radius-l: 24px;
    --radius-m: 16px;
    --radius-s: 10px;

    /* Transition */
    --transition-fast: 0.2s ease;

    --font-main: 'Outfit', sans-serif;
}

[data-theme="dark"] {
    --color-background: #0f1115;
    /* Deep Slate/Black */
    --color-card-bg: #1b1d22;
    /* Lighter Slate */
    --color-text-main: #FFFFFF;
    --color-text-muted: #9CA3AF;
    --color-border: #2D3748;
    --color-input-bg: #27282d;
    /* Contrast for inputs */
    --color-bg-secondary: #27282d;
    --color-progress-bg: #374151;
    --shadow-card: none;
    --shadow-hover: none;
    --shadow-sm: 0px 4px 12px rgba(0, 0, 0, 0.5);
}

body {
    font-family: var(--font-main);
    background-color: var(--color-background);
    color: var(--color-text-main);
    margin: 0;
    padding: 0;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* --- Controls --- */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 48px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    background-color: white;
    bottom: 4px;
    content: "";
    height: 16px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 16px;
    border-radius: 50%;
}

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

input:checked+.slider:before {
    transform: translateX(24px);
}

/* Range Slider */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: var(--color-border);
    border-radius: 2px;
}

/* File Upload */
.file-upload-wrapper {
    position: relative;
    width: 100%;
    height: 100px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-m);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    background-color: var(--color-input-bg);
}

.file-upload-wrapper:hover {
    border-color: var(--color-primary);
    background-color: rgba(74, 108, 247, 0.05);
}

.file-upload-text {
    color: var(--color-text-muted);
    font-size: 13px;
    pointer-events: none;
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 10px;
}

.radio-option {
    flex: 1;
    position: relative;
}

.radio-option input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.radio-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-s);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.radio-option input:checked~.radio-label {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Close Button */
.close-modal-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 24px;
    cursor: pointer;
    position: absolute;
    top: 20px;
    right: 20px;
    transition: color 0.2s;
}

.close-modal-btn:hover {
    color: var(--color-danger);
}


/* --- Layout --- */
#sidebar {
    width: 280px;
    background-color: var(--color-card-bg);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    border-right: none;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.02);
    z-index: 10;
}

#dashboard-main {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
}

/* --- Typography --- */
h1,
h2,
h3,
h4 {
    margin: 0;
    font-weight: 700;
}

h1 {
    font-size: 24px;
    color: var(--color-primary);
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
}

h2 {
    font-size: 28px;
    margin-bottom: 10px;
}

p {
    line-height: 1.6;
    color: var(--color-text-muted);
}

/* --- Components --- */
.card-panel {
    background: var(--color-card-bg);
    border-radius: var(--radius-l);
    padding: 30px;
    box-shadow: var(--shadow-card);
    transition: var(--transition-fast);
    border: 1px solid transparent;
    /* Removed white border for better dark mode */
}

.card-panel:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-m);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(74, 108, 247, 0.25);
    transition: var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: auto;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.btn-primary:hover {
    box-shadow: 0 15px 30px rgba(74, 108, 247, 0.35);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: var(--color-text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid rgba(74, 108, 247, 0.1);
    padding: 12px 24px;
    border-radius: var(--radius-m);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background: rgba(74, 108, 247, 0.05);
    border-color: var(--color-primary);
}

/* Sidebar Menu */
.menu-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-radius: var(--radius-m);
    color: var(--color-text-muted);
    font-weight: 500;
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.menu-item.active {
    background-color: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.menu-item:hover:not(.active) {
    background-color: var(--color-input-bg);
    color: var(--color-primary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-gap: 30px;
}

/* Panels Layout */
#daily-challenge {
    grid-column: span 8;
}

#progress-stats-container {
    grid-column: span 12;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 30px;
}

#streak-lockout {
    grid-column: span 4;
}

/* Stat Boxes */
.stat-box {
    background: var(--color-card-bg);
    border-radius: var(--radius-l);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
}

.stat-box h3 {
    font-size: 36px;
    color: var(--color-text-main);
    margin: 10px 0 0 0;
}

.stat-box p {
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
}

/* Challenge Section */
#daily-challenge h2 {
    color: var(--color-primary);
    font-size: 24px;
    margin-bottom: 5px;
}

.challenge-highlight-box {
    background: var(--color-input-bg);
    /* Fixed: Use variable */
    border-radius: var(--radius-m);
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.challenge-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-bottom: 5px;
    display: block;
}

.challenge-value {
    color: var(--color-text-main);
    font-weight: 600;
    font-size: 15px;
}

/* User Profile in Sidebar */
.user-profile-section {
    background: var(--color-bg-secondary);
    /* Fixed: Use variable */
    border-radius: var(--radius-m);
    padding: 20px;
    margin-bottom: 30px;
    text-align: center;
}

.user-avatar {
    width: 60px;
    height: 60px;
    background: var(--color-card-bg);
    border-radius: 50%;
    margin: 0 auto 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-sm);
    color: var(--color-primary);
}

/* Info Box Secondary */
.info-box-secondary {
    background: var(--color-bg-secondary);
}

/* Progress Bar */
.progress-container {
    background: var(--color-progress-bg);
    /* Fixed: Use variable */
    border-radius: 10px;
    height: 10px;
    width: 100%;
    overflow: hidden;
    margin-top: 15px;
}

#progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Analytics & Charts */
.chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 200px;
    width: 100%;
    padding-top: 20px;
}

.chart-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 15%;
    height: 100%;
}

.chart-bar {
    width: 100%;
    background: var(--color-primary);
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    /* Ensure visibility for 0 */
    transition: height 0.5s ease;
    opacity: 0.8;
}

.chart-bar:hover {
    opacity: 1;
    background: var(--color-secondary);
}

.chart-label {
    margin-top: 10px;
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 600;
}

.chart-value {
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-main);
}

.insight-item {
    padding: 15px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

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

/* Modals */
.nb-modal-backdrop {
    background-color: rgba(27, 37, 89, 0.4);
    /* Dark blue tint */
    backdrop-filter: blur(5px);
}

.nb-modal-content {
    background-color: var(--color-card-bg);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-card);
    border: none;
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

input,
select,
textarea {
    background: var(--color-input-bg);
    /* Fixed: Use variable */
    border: 1px solid transparent;
    border-radius: var(--radius-m);
    padding: 15px;
    color: var(--color-text-main);
    font-family: var(--font-main);
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    background: var(--color-card-bg);
    /* Use variable for focus */
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(74, 108, 247, 0.1);
}

/* Form Styles */
label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-main);
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #A0AEC0;
}

/* Mobile Responsive (App Mode) */
@media (max-width: 900px) {
    body {
        flex-direction: column;
    }

    #sidebar {
        display: none !important;
    }

    #dashboard-main {
        padding: 15px 15px 90px 15px;
        /* Bottom padding for nav */
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* Sticky, Blurred Header */
    #dashboard-header {
        position: sticky;
        top: 0;
        z-index: 900;
        background: rgba(var(--color-background), 0.95);
        /* Fallback if var not RGB */
        background: var(--color-background);
        /* Solid fallback */
        margin: -15px -15px 20px -15px;
        padding: 15px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    /* Force simple stacking layout */
    .dashboard-grid {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    /* All grid items logic reset */
    .dashboard-grid>div,
    .dashboard-grid>section,
    .card-panel {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        grid-column: unset !important;
    }

    /* Stats Specifics: 2x2 Grid fits mobile well */
    #progress-stats-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        margin-bottom: 0 !important;
    }

    /* Streak box spans full width in the 2x2 grid */
    #progress-stats-container .stat-box:last-child {
        grid-column: span 2;
    }

    /* Make stat boxes compact */
    .stat-box {
        padding: 15px;
    }

    .stat-box h3 {
        font-size: 28px;
    }

    /* Bottom Navigation Bar */
    #mobile-bottom-nav {
        display: flex;
        /* Show it */
        justify-content: space-around;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        background: var(--color-card-bg);
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
        /* Premium shadow */
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom);
        border-top: 1px solid var(--color-border);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--color-text-muted);
        font-size: 10px;
        font-weight: 600;
        width: 100%;
        height: 100%;
        cursor: pointer;
    }

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

    .mobile-nav-icon {
        font-size: 20px;
    }

    /* Modal Mobile Adjustments */
    .nb-modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        padding: 30px 20px;
        margin: 0;
        border-radius: var(--radius-l) var(--radius-l) 0 0;
        position: absolute;
        bottom: 0;
        max-width: 100%;
        animation: slideUpMobile 0.3s ease-out;
    }

    .nb-modal-backdrop {
        align-items: flex-end;
        /* Bottom sheet align */
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }
}

/* Default Mobile Nav Hidden */
#mobile-bottom-nav {
    display: none;
}

/* Onboarding Modal Styles */
.onboarding-step {
    display: none;
    text-align: center;
    animation: fadeScale 0.3s ease-out;
}

.onboarding-step.active {
    display: block;
}

@keyframes fadeScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.onboarding-image {
    font-size: 48px;
    margin-bottom: 20px;
    display: block;
}

.step-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 25px 0;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-border);
    transition: all 0.2s;
}

.step-dot.active {
    background-color: var(--color-primary);
    width: 20px;
    border-radius: 4px;
    /* Pill shape for active */
}

.onboarding-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    border-top: 1px solid var(--color-border);
    padding-top: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}
/* --- Global Modals (Appended via Agent) --- */
.global-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}

.global-modal-content {
    background: var(--color-card-bg);
    width: 90%; max-width: 450px;
    padding: 30px;
    border-radius: var(--radius-l);
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    position: relative;
    border: 1px solid var(--color-border);
}

.global-modal-close {
    position: absolute; top: 15px; right: 15px;
    background: none; border: none;
    font-size: 24px; color: var(--color-text-muted);
    cursor: pointer; transition: color 0.2s;
}

.global-modal-close:hover { color: var(--color-danger); }

.global-input {
    width: 100%; padding: 12px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-s);
    color: var(--color-text-main);
    margin-top: 5px; box-sizing: border-box;
    font-family: inherit;
}

.global-input:focus { border-color: var(--color-primary); outline: none; }

/* Share Icons */
.share-icons-row {
    display: flex; justify-content: center;gap: 15px; margin: 20px 0; flex-wrap: wrap;
}

.share-icon {
    width: 45px; height: 45px; border-radius: 50%;
    background: var(--color-bg-secondary);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-text-main); font-size: 1.2em; text-decoration: none;
    transition: 0.2s;
}

.share-icon:hover {
    background: var(--color-primary); color: white; transform: translateY(-3px);
}

.copy-link-box {
    display: flex; gap: 10px; background: var(--color-input-bg);
    padding: 5px; border-radius: var(--radius-m);
    border: 1px solid var(--color-border);
}

.copy-link-box input {
    border: none; background: transparent; padding: 10px;
    flex-grow: 1; font-size: 0.9em;
    color: var(--color-text-muted); outline: none; width: 100%;
}

.copy-link-box button {
    background: var(--color-card-bg); border: 1px solid var(--color-border);
    padding: 5px 15px; border-radius: var(--radius-s);
    cursor: pointer; font-weight: 600; color: var(--color-text-main);
    transition: 0.2s; white-space: nowrap;
}

.copy-link-box button:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* Icon Button */
.icon-btn {
    background: transparent; border: none;
    color: var(--color-text-muted); font-size: 1.1em;
    cursor: pointer; width: 40px; height: 40px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}

.icon-btn:hover {
    background: var(--color-bg-secondary); color: var(--color-primary); transform: translateY(-2px);
}

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

.settings-section .setting-item:last-of-type { border-bottom: none; }

/* Toggle Switch (CSS-only) */
.toggle-wrapper {
    width: 40px; height: 20px;
    background: var(--color-border); border-radius: 20px;
    position: relative; cursor: pointer; transition: 0.3s;
}

.toggle-knob {
    width: 16px; height: 16px; background: white;
    border-radius: 50%; position: absolute;
    top: 2px; left: 2px; transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

[data-theme="dark"] .toggle-wrapper { background: var(--color-primary); }
[data-theme="dark"] .toggle-knob { left: 22px; }

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
