/* ===================================================================
   STRIV — Cognitive Operating System Design System
   Lovable Technical Disclosure Alignment
   Outfit (Display) + DM Sans (Body)
   90% Neutral / 10% Sage Green (#5a706b)
   =================================================================== */

/* — Typography Imports — */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300;1,9..40,400&family=Outfit:wght@300;400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap');

/* =====================================================================
   DARK THEME (Product Default: <html class="dark"> or [data-theme="dark"])
   True near-black neutral ramp
   ===================================================================== */
:root,
[data-theme="dark"],
.dark {
    color-scheme: dark;

    /* STRIV Core Tokens */
    --background:             #090909;
    --surface:                #141414;
    --elevated:               #1c1c1c;
    --foreground:             #ffffff;
    --muted-foreground:       #a6a6a6;
    --divider:                #2a2a2a;
    --border:                 #2a2a2a;

    --primary:                #5a706b;
    --primary-hover:          #6f8882;
    --primary-glow:           #8da9a2;
    --primary-tint:           #1b2321;
    --primary-foreground:     #ffffff;

    --destructive:            #d4736a;
    --glass:                  rgba(20, 20, 20, 0.72);

    /* Radii */
    --radius-sm:              10px;
    --radius-md:              14px;
    --radius-lg:              16px;
    --radius-xl:              20px;
    --radius-2xl:             24px;
    --radius-3xl:             32px;
    --radius:                 16px;

    /* Shadows (dark mode uses surface contrast, soft ambient shadows for floating chrome) */
    --shadow-ambient:         0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    --shadow-float:           0 2px 6px rgba(0, 0, 0, 0.16), 0 18px 48px -24px rgba(0, 0, 0, 0.7);

    /* Semantic color mappings for backward-compatibility */
    --color-background:       var(--background);
    --color-on-background:    var(--foreground);
    --color-surface:          var(--surface);
    --color-surface-dim:      var(--elevated);
    --color-surface-bright:   var(--surface);
    --color-surface-container:var(--elevated);
    --color-surface-container-low: var(--surface);
    --color-surface-container-high: var(--elevated);
    --color-surface-container-highest: var(--elevated);
    --color-surface-variant:  var(--elevated);
    --color-surface-tint:     var(--primary);
    --color-on-surface:       var(--foreground);
    --color-on-surface-variant: var(--muted-foreground);
    --color-outline:          var(--divider);
    --color-outline-variant:  var(--divider);
    --color-primary:          var(--primary);
    --color-on-primary:       var(--primary-foreground);
    --color-primary-container:var(--primary-tint);
    --color-on-primary-container: var(--foreground);
    --color-secondary:        var(--elevated);
    --color-on-secondary:     var(--foreground);
    --color-tertiary:         var(--primary-glow);
    --color-on-tertiary:      var(--foreground);
    --color-error:            var(--destructive);
    --color-on-error:         var(--primary-foreground);
    --color-divider:          var(--divider);

    /* Glass and interface tokens */
    --glass-bg:               var(--glass);
    --glass-border:           rgba(255, 255, 255, 0.07);
    --glass-blur:             20px;
    --header-bg:              var(--glass);
    --header-border:          var(--divider);
    --sidebar-bg:             var(--surface);
    --sidebar-border:         var(--divider);
    --dropdown-bg:            rgba(20, 20, 20, 0.95);
    --dropdown-border:        var(--divider);
    --dropdown-shadow:        var(--shadow-ambient);
    --dropdown-item-hover-bg: rgba(255, 255, 255, 0.05);

    /* Chat bubble tokens */
    --bubble-user-bg:         var(--elevated);
    --bubble-user-border:     rgba(255, 255, 255, 0.06);
    --bubble-user-text:       var(--foreground);
    --bubble-ai-bg:           transparent;
    --bubble-ai-border:       transparent;
    --bubble-ai-text:         var(--foreground);

    --scrollbar-thumb:        rgba(255, 255, 255, 0.12);
    --scrollbar-thumb-hover:  rgba(255, 255, 255, 0.22);
}

/* =====================================================================
   LIGHT THEME ([data-theme="light"] or .light-mode)
   Warm near-white neutral ramp
   ===================================================================== */
[data-theme="light"],
.light-mode {
    color-scheme: light;

    /* STRIV Core Tokens */
    --background:             #fafaf8;
    --surface:                #ffffff;
    --elevated:               #f3f4f3;
    --foreground:             #111111;
    --muted-foreground:       #6a6a6a;
    --divider:                #e5e7e7;
    --border:                 #e5e7e7;

    --primary:                #5a706b;
    --primary-hover:          #6f8882;
    --primary-glow:           #8da9a2;
    --primary-tint:           #e7eeec;
    --primary-foreground:     #ffffff;

    --destructive:            #b3453c;
    --glass:                  rgba(255, 255, 255, 0.72);

    /* Shadows */
    --shadow-ambient:         0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px -12px rgba(0, 0, 0, 0.18);
    --shadow-float:           0 2px 6px rgba(0, 0, 0, 0.06), 0 18px 48px -24px rgba(0, 0, 0, 0.28);

    /* Semantic color mappings for backward-compatibility */
    --color-background:       var(--background);
    --color-on-background:    var(--foreground);
    --color-surface:          var(--surface);
    --color-surface-dim:      var(--elevated);
    --color-surface-bright:   var(--surface);
    --color-surface-container:var(--elevated);
    --color-surface-container-low: var(--surface);
    --color-surface-container-high: var(--elevated);
    --color-surface-container-highest: var(--elevated);
    --color-surface-variant:  var(--elevated);
    --color-surface-tint:     var(--primary);
    --color-on-surface:       var(--foreground);
    --color-on-surface-variant: var(--muted-foreground);
    --color-outline:          var(--divider);
    --color-outline-variant:  var(--divider);
    --color-primary:          var(--primary);
    --color-on-primary:       var(--primary-foreground);
    --color-primary-container:var(--primary-tint);
    --color-on-primary-container: var(--foreground);
    --color-secondary:        var(--elevated);
    --color-on-secondary:     var(--foreground);
    --color-tertiary:         var(--primary-glow);
    --color-on-tertiary:      var(--foreground);
    --color-error:            var(--destructive);
    --color-on-error:         var(--primary-foreground);
    --color-divider:          var(--divider);

    /* Glass and interface tokens */
    --glass-bg:               var(--glass);
    --glass-border:           rgba(0, 0, 0, 0.06);
    --glass-blur:             20px;
    --header-bg:              var(--glass);
    --header-border:          var(--divider);
    --sidebar-bg:             var(--surface);
    --sidebar-border:         var(--divider);
    --dropdown-bg:            rgba(255, 255, 255, 0.96);
    --dropdown-border:        var(--divider);
    --dropdown-shadow:        var(--shadow-ambient);
    --dropdown-item-hover-bg: rgba(0, 0, 0, 0.04);

    /* Chat bubble tokens */
    --bubble-user-bg:         var(--elevated);
    --bubble-user-border:     rgba(0, 0, 0, 0.05);
    --bubble-user-text:       var(--foreground);
    --bubble-ai-bg:           transparent;
    --bubble-ai-border:       transparent;
    --bubble-ai-text:         var(--foreground);

    --scrollbar-thumb:        rgba(0, 0, 0, 0.12);
    --scrollbar-thumb-hover:  rgba(0, 0, 0, 0.22);
}

/* =====================================================================
   GLOBAL BASE TYPOGRAPHY & RULES
   ===================================================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: -0.006em;
    background-color: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, .font-display {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.022em;
}

::selection {
    background: var(--primary-tint);
    color: var(--foreground);
}

/* Prevent native mobile pull-to-refresh reload glitches */
html, body {
    overscroll-behavior-y: contain;
}

/* =====================================================================
   CORE UTILITIES (STRIV Glass, Surfaces, Shadows)
   ===================================================================== */
.glass {
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
}

.shadow-ambient {
    box-shadow: var(--shadow-ambient);
}

.shadow-float {
    box-shadow: var(--shadow-float);
}

/* Cards & Surfaces */
.glass-card,
.glass-card-frosted {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-lg);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.glass-card:hover,
.glass-card-frosted:hover {
    border-color: rgba(90, 112, 107, 0.35);
}

/* Flat background replaces volumetric blobs */
.volumetric-bg {
    background: var(--background);
    position: relative;
}

.volumetric-glow-1,
.volumetric-glow-2 {
    display: none !important;
}

/* =====================================================================
   FLOATING TOP CAPSULE NAVIGATION (Android-first centered capsule)
   ===================================================================== */
.floating-nav-capsule {
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--divider);
    border-radius: 9999px;
    padding: 6px;
    box-shadow: var(--shadow-ambient);
}

.nav-capsule-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    border-radius: 9999px;
    color: var(--muted-foreground);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.18s cubic-bezier(0.2, 0, 0, 1);
}

.nav-capsule-item:hover {
    color: var(--foreground);
    background: rgba(90, 112, 107, 0.08);
}

.nav-capsule-item.active {
    background: var(--primary-tint);
    color: var(--foreground);
}

.nav-capsule-item .material-symbols-outlined {
    font-size: 20px;
}

/* =====================================================================
   CHAT BUBBLES & COMPOSER SPEC
   Assistant: direct surface render (no bubble)
   User: single elevated rounded-2xl pill
   ===================================================================== */
.user-bubble {
    background: var(--elevated) !important;
    border: none !important;
    border-radius: 20px !important;
    color: var(--foreground) !important;
    padding: 12px 20px !important;
    max-width: 80% !important;
    box-shadow: 0 0 0 1px rgba(90, 112, 107, 0.12), 0 4px 16px -2px rgba(0, 0, 0, 0.3) !important;
    line-height: 1.6;
}

.ai-bubble {
    background: transparent !important;
    border: none !important;
    color: var(--foreground) !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    line-height: 1.75;
}

/* =====================================================================
   MINIMALIST GLOW CARDS (Boxes with glowing edges, no visible harsh borders)
   ===================================================================== */
.striv-glow-card {
    background: var(--surface);
    border: none !important;
    border-radius: 20px;
    padding: 20px 24px;
    box-shadow: 
        0 0 0 1px rgba(90, 112, 107, 0.16),
        0 8px 32px -4px rgba(0, 0, 0, 0.5),
        0 0 32px -4px rgba(90, 112, 107, 0.18);
    position: relative;
    overflow: hidden;
    margin: 16px 0;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.striv-glow-card:hover {
    box-shadow: 
        0 0 0 1px rgba(90, 112, 107, 0.28),
        0 10px 36px -2px rgba(0, 0, 0, 0.6),
        0 0 40px -2px rgba(90, 112, 107, 0.24);
}

.striv-glow-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(141, 169, 162, 0.35) 0%, rgba(90, 112, 107, 0.05) 50%, rgba(255, 255, 255, 0.05) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

[data-theme="light"] .striv-glow-card,
.light-mode .striv-glow-card {
    background: #ffffff;
    box-shadow: 
        0 0 0 1px rgba(90, 112, 107, 0.14),
        0 10px 30px -4px rgba(90, 112, 107, 0.08),
        0 0 24px -4px rgba(90, 112, 107, 0.12);
}

[data-theme="light"] .striv-glow-card::before,
.light-mode .striv-glow-card::before {
    background: linear-gradient(135deg, rgba(90, 112, 107, 0.25) 0%, rgba(90, 112, 107, 0.04) 60%, rgba(0,0,0,0.02) 100%);
}

/* Key-Value Property Rows inside Glow Cards */
.striv-prop-row {
    display: flex;
    flex-direction: column;
    padding: 11px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
@media (min-width: 640px) {
    .striv-prop-row {
        flex-direction: row;
        align-items: baseline;
        gap: 18px;
    }
}
.striv-prop-row:last-child {
    border-bottom: none;
    padding-bottom: 2px;
}
.striv-prop-row:first-child {
    padding-top: 2px;
}
[data-theme="light"] .striv-prop-row,
.light-mode .striv-prop-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.striv-prop-key {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-foreground);
    min-width: 170px;
    flex-shrink: 0;
}

.striv-prop-val {
    font-size: 14px;
    line-height: 1.65;
    color: var(--foreground);
    flex: 1;
}

/* Clean List Item Row inside Glow Cards */
.striv-item-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 9px 0;
    color: var(--foreground);
    font-size: 14px;
    line-height: 1.65;
}
.striv-item-row:last-child {
    padding-bottom: 2px;
}
.striv-item-row:first-child {
    padding-top: 2px;
}
.striv-item-row + .striv-item-row {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}
[data-theme="light"] .striv-item-row + .striv-item-row,
.light-mode .striv-item-row + .striv-item-row {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Minimal Timeline Card with Glowing Sage Guide */
.striv-timeline-card {
    background: var(--surface);
    border: none;
    border-radius: 16px;
    padding: 14px 18px;
    box-shadow: 
        0 0 0 1px rgba(90, 112, 107, 0.12),
        0 4px 16px rgba(0, 0, 0, 0.25);
    margin: 8px 0;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
}
.striv-timeline-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Floating Composer Pill */
.composer-dock {
    position: relative;
    flex-shrink: 0;
    width: 100%;
    background: linear-gradient(to top, var(--background) 85%, transparent 100%);
    padding: 8px 0 max(16px, env(safe-area-inset-bottom, 16px)) 0;
    z-index: 40;
}

.composer-capsule {
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--divider);
    border-radius: var(--radius-3xl);
    box-shadow: var(--shadow-float);
    padding: 8px 12px;
    transition: border-color 0.2s ease;
}

@media (max-width: 640px) {
    .composer-dock {
        padding: 6px 0 max(12px, env(safe-area-inset-bottom, 12px)) 0;
    }
    .composer-capsule {
        padding: 6px 10px;
        gap: 6px;
    }
    .composer-capsule button {
        width: 36px;
        height: 36px;
    }
    .composer-capsule textarea {
        font-size: 14px;
        min-height: 36px !important;
    }
}

.composer-capsule:focus-within {
    border-color: rgba(90, 112, 107, 0.5);
}

/* =====================================================================
   TASK ROWS SPEC
   Single-row surface card, 22px checkbox, 6px priority dot
   ===================================================================== */
.task-card {
    background: var(--surface) !important;
    border: 1px solid var(--divider) !important;
    border-radius: var(--radius-xl) !important;
    padding: 14px 16px !important;
    transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease !important;
}

.task-card:hover {
    border-color: rgba(90, 112, 107, 0.4) !important;
}

.task-row-card {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.task-row-card:hover {
    border-color: rgba(90, 112, 107, 0.35);
}

/* Circular 22px checkbox */
.task-checkbox-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--divider);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
    background: transparent;
}

.task-checkbox-circle:hover {
    border-color: var(--primary);
}

.task-checkbox-circle.checked {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
}

/* Priority dot (6px circle) */
.priority-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.priority-dot.high {
    background: var(--primary);
}

.priority-dot.medium {
    background: rgba(90, 112, 107, 0.5);
}

.priority-dot.low {
    background: var(--divider);
}

/* =====================================================================
   CHIPS (Profile & Filters)
   ===================================================================== */
.striv-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 9999px;
    border: 1px solid var(--divider);
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted-foreground);
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.striv-chip:hover {
    color: var(--foreground);
    border-color: var(--muted-foreground);
}

.striv-chip.active {
    border-color: rgba(90, 112, 107, 0.4);
    background: var(--primary-tint);
    color: var(--foreground);
}

/* =====================================================================
   DASHBOARD WIDGET SPEC
   ===================================================================== */
.dashboard-widget-tile {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.dashboard-widget-tile:hover {
    transform: translateY(-2px);
    border-color: rgba(90, 112, 107, 0.35);
}

/* Drag & Drop Creation Selection Rectangle */
.calendar-drag-selection {
    background: rgba(90, 112, 107, 0.35) !important;
    border: 1.5px solid #6f8882 !important;
    box-shadow: 0 0 14px rgba(90, 112, 107, 0.35), inset 0 0 10px rgba(90, 112, 107, 0.2) !important;
    border-radius: 8px !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.light-mode .calendar-drag-selection,
:root:not(.dark) .calendar-drag-selection,
[data-theme="light"] .calendar-drag-selection {
    background: rgba(90, 112, 107, 0.22) !important;
    border: 1.5px solid #4a5e5a !important;
    box-shadow: 0 0 10px rgba(90, 112, 107, 0.2) !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Mobile Week View 2D Canvas & Sticky Axes */
#calendar-scroll-canvas {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

#calendar-grid-header {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.day-column {
    min-height: 1440px;
    touch-action: pan-x pan-y;
}

.day-column.touch-none {
    touch-action: none !important;
}

/* Mobile Quick-Jump Week Bar Items */
.mobile-day-strip-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
}

.mobile-day-strip-item:hover {
    background: var(--elevated);
}

.mobile-day-strip-item.active {
    background: var(--primary-tint);
    border: 1px solid rgba(90, 112, 107, 0.35);
}

.mobile-day-strip-item.is-today .strip-day-num {
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 700;
}

.cal-suggestion-pill {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--divider);
    border-radius: 9999px;
    padding: 8px 16px;
    box-shadow: var(--shadow-ambient);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 50;
}

/* =====================================================================
   CHAT SESSION DROPDOWN & DIALOGS
   ===================================================================== */
.chat-session-dropdown {
    background: var(--dropdown-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--dropdown-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--dropdown-shadow);
    z-index: 100;
}

.chat-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--foreground);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.chat-dropdown-item:hover {
    background: var(--dropdown-item-hover-bg);
}

.chat-dropdown-danger {
    color: var(--destructive) !important;
}

/* =====================================================================
   GLOBAL LOADER OVERLAY
   ===================================================================== */
#striv-global-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--background);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#striv-global-loader.hidden-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Scrollbars */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 99px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Smooth theme transitions */
html,
html *,
html *::before,
html *::after {
    transition: background-color 0.25s ease, color 0.2s ease, border-color 0.2s ease;
}

html.no-transition,
html.no-transition *,
html.no-transition *::before,
html.no-transition *::after {
    transition: none !important;
}
