/* ============================================================
   NOMS — Design System Foundations
   ============================================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-base);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.3;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}

/* ============================================================
   CSS Custom Properties — Light Mode (default)
   ============================================================ */
:root {
    /* Backgrounds */
    --bg-base: #FAF7F2;
    --surface: #F5F0E8;

    /* Neumorphic shadows */
    --shadow-light: #FFFDF8;
    --shadow-dark: #C8C1B4;

    /* Button edge color (inherits parent context) */
    --btn-edge: var(--bg-base);

    /* Glassmorphism */
    --glass-fill: rgba(255, 255, 255, 0.20);
    --glass-border: rgba(255, 255, 255, 0.30);
    --glass-blur: blur(16px) saturate(180%);

    /* Accent palette */
    --accent: #D9735A;
    --accent-hover: #C4613F;
    --success: #5A9E6F;
    --success-bg: rgba(90, 158, 111, 0.10);
    --warning: #D4923B;
    --error: #C4504A;
    --error-bg: rgba(196, 80, 74, 0.10);

    /* Text */
    --text-primary: #2D2A26;
    --text-secondary: #7A756D;
    --text-tertiary: #A8A29A;

    /* Typography */
    --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
    --font-display: 'Fredoka', 'Georgia', serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Background gradient */
    --bg-gradient-1: #FAF7F2;
    --bg-gradient-2: #F5E6D0;
    --bg-gradient-3: #E8EDE2;
    --bg-gradient-4: #F0DCC8;
}

/* ============================================================
   CSS Custom Properties — Dark Mode
   ============================================================ */
.dark {
    --bg-base: #1E1C18;
    --surface: #242220;
    --shadow-light: #33302A;
    --shadow-dark: #0F0E0B;
    --glass-fill: rgba(30, 28, 24, 0.50);
    --glass-border: rgba(255, 255, 255, 0.10);
    --glass-blur: blur(16px) saturate(150%);
    --accent: #E8896E;
    --accent-hover: #F0A08C;
    --success: #72B886;
    --success-bg: rgba(114, 184, 134, 0.15);
    --warning: #E5A54E;
    --error: #D96B63;
    --error-bg: rgba(217, 107, 99, 0.15);
    --text-primary: #EDE8DF;
    --text-secondary: #9E978C;
    --text-tertiary: #6B655D;

    --bg-gradient-1: #1A1814;
    --bg-gradient-2: #221E18;
    --bg-gradient-3: #181E20;
    --bg-gradient-4: #1E1820;
}

/* ============================================================
   Animated Background Gradient (Layer 0)
   ============================================================ */
.bg-gradient-animated {
    background: linear-gradient(
        135deg,
        var(--bg-gradient-1),
        var(--bg-gradient-2),
        var(--bg-gradient-3),
        var(--bg-gradient-4)
    );
    background-size: 400% 400%;
    animation: gradient-shift 30s ease infinite;
}

@keyframes gradient-shift {
    0%   { background-position: 0% 50%; }
    25%  { background-position: 100% 50%; }
    50%  { background-position: 100% 100%; }
    75%  { background-position: 0% 100%; }
    100% { background-position: 0% 50%; }
}

/* ============================================================
   Neumorphic Utility Classes
   ============================================================ */
.neumo-raised {
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light);
    border-radius: var(--radius-md);
}

.neumo-inset {
    box-shadow: inset 5px 5px 4px var(--shadow-dark), inset -5px -5px 4px var(--shadow-light);
    border-radius: var(--radius-md);
}

.neumo-card {
    --btn-edge: var(--surface);
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light);
    border-radius: var(--radius-lg);
}

/* ============================================================
   Glassmorphism Utility
   ============================================================ */
.glass {
    background: var(--glass-fill);
    backdrop-filter: var(--glass-blur) !important;
    -webkit-backdrop-filter: var(--glass-blur) !important;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--surface);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Responsive Content Container
   ============================================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

@media (min-width: 1024px) {
    .container {
        padding: 0 var(--space-xl);
    }
}

@media (min-width: 1920px) {
    .container {
        max-width: 1440px;
    }
}

/* ============================================================
    Touch Target Minimum (WCAG / Apple HIG)
    ============================================================ */
.touch-target {
    min-width: 44px;
    min-height: 44px;
}

/* ============================================================
    Button Components
    ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light),
                inset 0 0 0 5px var(--btn-edge);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light),
                inset 0 0 0 5px var(--btn-edge);
}

.btn-primary:active:not(:disabled) {
    box-shadow: inset 5px 5px 4px var(--shadow-dark), inset -5px -5px 4px var(--shadow-light);
}

.btn-secondary {
    background: var(--surface);
    color: var(--accent);
    border: 2px solid var(--accent);
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light),
                inset 0 0 0 5px var(--btn-edge);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--accent);
    color: white;
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light),
                inset 0 0 0 5px var(--btn-edge);
}

.btn-secondary:active:not(:disabled) {
    box-shadow: inset 5px 5px 4px var(--shadow-dark), inset -5px -5px 4px var(--shadow-light);
}

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

.btn-ghost:hover:not(:disabled) {
    color: var(--accent);
    background: var(--glass-fill);
}

.btn-danger {
    background: var(--error);
    color: white;
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light),
                inset 0 0 0 5px var(--btn-edge);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light),
                inset 0 0 0 5px var(--btn-edge);
}

.btn-danger:active:not(:disabled) {
    box-shadow: inset 5px 5px 4px var(--shadow-dark), inset -5px -5px 4px var(--shadow-light);
}

/* ============================================================
    Input Component
    ============================================================ */
.input {
    border: none;
    transition: box-shadow 0.2s ease;
}

.input:focus {
    box-shadow: inset 5px 5px 4px var(--shadow-dark), inset -5px -5px 4px var(--shadow-light),
                0 0 0 2px var(--accent);
}

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

/* ============================================================
    App Shell
    ============================================================ */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding-top: 80px; /* Space for fixed navbar */
    padding-bottom: var(--space-xl);
}

/* ============================================================
    Navbar
    ============================================================ */
  .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: var(--glass-blur) !important;
    -webkit-backdrop-filter: var(--glass-blur) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.40);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.dark .navbar {
    background: rgba(30, 28, 24, 0.75);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.20);
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: var(--space-md);
}

.navbar-logo {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    flex-shrink: 0;
}

.navbar-logo:hover {
    color: var(--accent-hover);
}

.navbar-links {
    display: none;
    align-items: center;
    gap: var(--space-lg);
}

@media (min-width: 768px) {
    .navbar-links {
        display: flex;
    }
}

.navbar-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: color 0.2s ease, background 0.2s ease;
}

.navbar-link:hover {
    color: var(--accent);
    background: var(--glass-fill);
}

.navbar-actions {
    display: none;
    align-items: center;
    gap: var(--space-md);
}

@media (min-width: 768px) {
    .navbar-actions {
        display: flex;
    }
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.navbar-username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* User menu container */
.navbar-user-menu {
    position: relative;
}

/* User dropdown trigger */
.navbar-user-dropdown {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
}

.navbar-user-dropdown:hover {
    background: var(--glass-fill);
}

/* User dropdown menu */
.navbar-dropdown-menu {
    position: absolute;
    top: calc(100% + var(--space-xs));
    right: 0;
    background: var(--bg-base);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    padding: var(--space-sm);
    min-width: 200px;
    z-index: 150;
    animation: dropdown-fade-in 0.15s ease;
}

@keyframes dropdown-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.navbar-dropdown-header {
    padding: var(--space-sm) var(--space-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-dropdown-divider {
    height: 1px;
    background: var(--glass-border);
    margin: var(--space-xs) 0;
}

.navbar-dropdown-item {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}

.navbar-dropdown-item:hover {
    background: var(--surface);
    color: var(--accent);
}

.navbar-dropdown-item-danger {
    color: var(--error);
}

.navbar-dropdown-item-danger:hover {
    background: var(--error);
    color: white;
}

/* Mobile drawer danger link */
.navbar-drawer-link-danger {
    color: var(--error);
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease;
}

.navbar-drawer-link-danger:hover {
    background: var(--surface);
}

.navbar-theme-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: background 0.2s ease;
    color: var(--text-secondary);
}

.navbar-theme-toggle:hover {
    background: var(--glass-fill);
}

/* Hamburger button */
.navbar-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
}

@media (min-width: 768px) {
    .navbar-hamburger {
        display: none;
    }
}

.hamburger-line {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Mobile drawer */
.navbar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.4);
    animation: fade-in 0.2s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.navbar-drawer-content {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-base);
    z-index: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    animation: slide-in 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

@keyframes slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.navbar-drawer-close {
    align-self: flex-end;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.2s ease;
}

.navbar-drawer-close:hover {
    color: var(--text-primary);
}

.navbar-drawer-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.navbar-drawer-link {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: background 0.2s ease, color 0.2s ease;
}

.navbar-drawer-link:hover {
    background: var(--surface);
    color: var(--accent);
}

.navbar-drawer-theme {
    margin-top: auto;
    background: var(--surface);
    border: none;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: background 0.2s ease, color 0.2s ease;
}

.navbar-drawer-theme:hover {
    color: var(--accent);
    background: var(--glass-fill);
}

/* ============================================================
    Footer
    ============================================================ */
.footer {
    --btn-edge: var(--surface);
    background: var(--surface);
    border-top: 1px solid var(--glass-border);
    padding: var(--space-md) 0;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ============================================================
    Error Fallback
    ============================================================ */
.error-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-secondary);
}

.error-fallback h1 {
    color: var(--error);
    margin-bottom: var(--space-md);
}

.error-fallback p {
    margin-bottom: var(--space-lg);
}

/* ============================================================
    NotFound (404) Page
    ============================================================ */
.not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
}

.not-found h1 {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: var(--space-sm);
}

.not-found h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

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

.not-found code {
    background: var(--surface);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 14px;
    color: var(--text-tertiary);
}

/* ============================================================
    Danger Zone
    ============================================================ */
.danger-zone .neumo-card {
    border: 2px solid var(--error);
    background: var(--error-bg);
}

/* ============================================================
    Modal Overlay
    ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    animation: fade-in 0.2s ease;
    padding: var(--space-md);
}

.modal-card {
    background: var(--bg-base);
    border-radius: var(--radius-lg);
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light);
    padding: var(--space-xl);
    max-width: 440px;
    width: 100%;
    animation: modal-slide-in 0.2s ease;
}

@keyframes modal-slide-in {
    from { opacity: 0; transform: scale(0.95) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-card h2 {
    font-size: 18px;
    color: var(--text-primary);
}

.modal-card p {
    margin: 0;
}

.modal-card code {
    background: var(--surface);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 13px;
    color: var(--text-primary);
}

/* ============================================================
   Settings Tabs
   ============================================================ */
.settings-tabs {
    --btn-edge: var(--surface);
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    box-shadow: inset 5px 5px 4px var(--shadow-dark), inset -5px -5px 4px var(--shadow-light);
    width: fit-content;
    max-width: 100%;
}

.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.settings-tab:hover {
    color: var(--accent);
    background: var(--glass-fill);
}

.settings-tab-active {
    color: var(--accent);
    background: var(--bg-base);
    box-shadow: 5px 5px 4px var(--shadow-dark), -5px -5px 4px var(--shadow-light);
}

.settings-tab-active:hover {
    color: var(--accent-hover);
}
