/**
 * Sendora - Obsidian Dark Mode Engine (Refined Cool Slate Palette)
 * Cold, eye-friendly, calm dark theme with ZERO jarring neon colors.
 *
 * Canvas: #1e1e1e
 * Sidebar: #181818
 * Cards: #252525
 * Cool Containers (Credits Card, Terminal Boxes): #17191d
 * Cool Primary Buttons (Create Form, Embed, etc.): #242933 (Hover: #2e3542)
 * Cool Accent (Ice Blue / Cold Steel): #38bdf8
 * Text Primary: #f3f3f3
 * Text Muted: #8c94a0
 * Borders: rgba(255, 255, 255, 0.08)
 */

:root {
    --obs-bg-canvas: #f7faf5;
    --obs-bg-sidebar: #ffffff;
    --obs-bg-card: #ffffff;
    --obs-bg-hover: #f1f5f9;
    --obs-bg-active: #e2e8f0;
    --obs-bg-input: #f8fafc;
    --obs-text-primary: #0f172a;
    --obs-text-secondary: #475569;
    --obs-text-muted: #94a3b8;
    --obs-border: #e2e8f0;
    --obs-accent: #0284c7;
    --obs-accent-hover: #0369a1;
    --obs-accent-subtle: rgba(2, 132, 199, 0.12);
}

html.dark {
    --obs-bg-canvas: #1e1e1e;
    --obs-bg-sidebar: #181818;
    --obs-bg-card: #252525;
    --obs-bg-hover: #2a2a2a;
    --obs-bg-active: #252a33;
    --obs-bg-input: #181818;
    --obs-text-primary: #f3f3f3;
    --obs-text-secondary: #c9c9c9;
    --obs-text-muted: #8c94a0;
    --obs-border: rgba(255, 255, 255, 0.08);
    --obs-accent: #38bdf8;
    --obs-accent-hover: #7dd3fc;
    --obs-accent-subtle: rgba(56, 189, 248, 0.15);

    color-scheme: dark;
}

/* Base Body & Root in Dark Mode */
html.dark,
html.dark body {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
}

/* Selection */
html.dark ::selection {
    background-color: rgba(56, 189, 248, 0.3) !important;
    color: #ffffff !important;
}

/* Custom Obsidian Sleek Scrollbar */
html.dark ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
html.dark ::-webkit-scrollbar-track {
    background: #181818;
}
html.dark ::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 4px;
    border: 2px solid #181818;
}
html.dark ::-webkit-scrollbar-thumb:hover {
    background: #484848;
}

/* ==========================================================================
   Surfaces & Background Overrides
   ========================================================================== */

/* Main canvas containers & backgrounds */
html.dark .bg-background,
html.dark .bg-surface,
html.dark [class*="bg-background"],
html.dark [class*="bg-surface"] {
    background-color: #1e1e1e !important;
}

/* Card Elements & White Panels */
html.dark .bg-white,
html.dark [class*="bg-white/"] {
    background-color: #252525 !important;
}

/* Subtle backgrounds (Slate 50 / Slate 100 / Surface Container) */
html.dark .bg-slate-50,
html.dark .bg-slate-100,
html.dark .bg-surface-container,
html.dark .bg-surface-container-low,
html.dark .bg-surface-container-lowest,
html.dark [class*="bg-slate-50"],
html.dark [class*="bg-slate-100"] {
    background-color: #1c1c1c !important;
}

html.dark .bg-slate-200,
html.dark .bg-surface-container-high,
html.dark .bg-surface-container-highest {
    background-color: #2b2b2b !important;
}

/* Sidebar & Header Glassmorphic Navigation */
html.dark aside,
html.dark .sidebar,
html.dark [id*="sidebar"] {
    background-color: #181818 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

html.dark header,
html.dark .sticky header,
html.dark [class*="header"] {
    background-color: rgba(24, 24, 24, 0.92) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

/* Mobile dropdown menus */
html.dark #mobileNavMenu,
html.dark #sidebarNavMobile,
html.dark #adminSidebarNavMobile {
    background-color: #1c1c1c !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Footer in Dark Mode */
html.dark footer {
    background-color: #161616 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* ==========================================================================
   Borders & Separators
   ========================================================================== */
html.dark .border,
html.dark .border-t,
html.dark .border-b,
html.dark .border-l,
html.dark .border-r,
html.dark .border-slate-100,
html.dark .border-slate-200,
html.dark .border-slate-300,
html.dark .border-slate-800,
html.dark .border-outline-variant,
html.dark [class*="border-slate-200"],
html.dark [class*="border-slate-100"],
html.dark [class*="border-outline-variant"] {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Subtle card hover (Clean & Crisp, No Loud Colors) */
html.dark .form-card-item:hover,
html.dark .hover\:shadow-md:hover {
    border-color: rgba(255, 255, 255, 0.16) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5) !important;
}

/* ==========================================================================
   Dark Containers (Credits Left Card, API Endpoint Box, Code Snippets)
   ========================================================================== */

/* Non-interactive bg-slate-900 elements stay deep, calm dark containers */
html.dark div.bg-slate-900,
html.dark [class*="bg-slate-900"]:not(button):not(a):not(input) {
    background-color: #17191d !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    color: #e0e0e0 !important;
}

/* API Endpoint URL Box */
html.dark div.bg-slate-900 code {
    background: transparent !important;
    color: #38bdf8 !important; /* Cool Ice Blue font-mono */
}

/* Inner Copy Button in URL Box */
html.dark .bg-slate-800,
html.dark button.bg-slate-800 {
    background-color: #23272f !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}
html.dark .bg-slate-800:hover,
html.dark button.bg-slate-800:hover {
    background-color: #2c323c !important;
    color: #ffffff !important;
}

/* Credits Progress Bar Track */
html.dark div.bg-slate-900 .bg-slate-800 {
    background-color: #252a33 !important;
}

/* Top Up Balance Button inside Credits Left Card */
html.dark div.bg-slate-900 a.bg-emerald-500 {
    background-color: #382a57 !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}
html.dark div.bg-slate-900 a.bg-emerald-500:hover {
    background-color: #423265 !important;
    border: none !important;
    color: #ffffff !important;
}

/* ==========================================================================
   Primary Action Buttons (Solid Deep Cold Purple - No Borders, No Glass)
   ========================================================================== */

html.dark button.bg-slate-900,
html.dark a.bg-slate-900,
html.dark button.bg-primary,
html.dark a.bg-primary,
html.dark .btn-primary {
    background-color: #382a57 !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
    transition: background-color 0.2s ease, transform 0.1s ease !important;
}

html.dark button.bg-slate-900:hover,
html.dark a.bg-slate-900:hover,
html.dark button.bg-primary:hover,
html.dark a.bg-primary:hover,
html.dark .btn-primary:hover {
    background-color: #44336a !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
}

html.dark button.bg-slate-900:active,
html.dark a.bg-slate-900:active,
html.dark button.bg-primary:active,
html.dark a.bg-primary:active,
html.dark .btn-primary:active {
    background-color: #2b1f44 !important;
    border: none !important;
    transform: scale(0.98);
}

/* Secondary Button (Top Up in Navbar / Outline buttons) */
html.dark .bg-slate-100.text-slate-700,
html.dark .bg-slate-100.text-slate-800 {
    background-color: #22262e !important;
    color: #e0e0e0 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}
html.dark .bg-slate-100.text-slate-700:hover,
html.dark .bg-slate-100.text-slate-800:hover {
    background-color: #2a303a !important;
    color: #ffffff !important;
}

/* ==========================================================================
   Interactive & Nav States
   ========================================================================== */

/* Hover state on list/nav items */
html.dark .hover\:bg-slate-100:hover,
html.dark .hover\:bg-slate-50:hover,
html.dark .hover\:bg-surface-container-high:hover {
    background-color: #252a33 !important;
    color: #ffffff !important;
}

/* Active navigation item (Clean & Seamless, No Side Borders) */
html.dark aside nav a.bg-slate-900,
html.dark header nav a.bg-primary-fixed\/60 {
    background-color: #262b35 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Status & Feature Badges (Subdued Cold Tones) */
html.dark .bg-emerald-50,
html.dark .bg-emerald-100 {
    background-color: rgba(16, 185, 129, 0.12) !important;
    border-color: rgba(16, 185, 129, 0.25) !important;
}
html.dark .text-emerald-700,
html.dark .text-emerald-800,
html.dark .text-emerald-600 {
    color: #34d399 !important;
}

html.dark .bg-amber-50,
html.dark .bg-amber-100 {
    background-color: rgba(245, 158, 11, 0.12) !important;
    border-color: rgba(245, 158, 11, 0.25) !important;
}
html.dark .text-amber-700,
html.dark .text-amber-800,
html.dark .text-amber-600 {
    color: #fbbf24 !important;
}

html.dark .bg-rose-50,
html.dark .bg-rose-100,
html.dark .bg-red-50,
html.dark .bg-red-100 {
    background-color: rgba(239, 68, 68, 0.12) !important;
    border-color: rgba(239, 68, 68, 0.25) !important;
}
html.dark .text-rose-700,
html.dark .text-rose-800,
html.dark .text-rose-600,
html.dark .text-red-600,
html.dark .text-red-700 {
    color: #f87171 !important;
}

html.dark .badge-cool,
html.dark [class*="bg-primary-fixed"] {
    background-color: rgba(56, 189, 248, 0.12) !important;
    color: #7dd3fc !important;
    border: 1px solid rgba(56, 189, 248, 0.25) !important;
}

/* ==========================================================================
   Typography Overrides
   ========================================================================== */

/* Headings & High-contrast Text */
html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4,
html.dark h5,
html.dark h6,
html.dark .text-slate-900,
html.dark .text-slate-800,
html.dark .text-on-background,
html.dark .text-on-surface,
html.dark .text-primary {
    color: #f3f3f3 !important;
}

/* Body & Medium Text */
html.dark p,
html.dark .text-slate-700,
html.dark .text-slate-600 {
    color: #c9c9c9 !important;
}

/* Muted & Secondary Text */
html.dark .text-slate-500,
html.dark .text-slate-400,
html.dark .text-secondary,
html.dark .text-on-surface-variant {
    color: #8c94a0 !important;
}

/* ==========================================================================
   Forms, Inputs, & Dialogs
   ========================================================================== */

html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
html.dark textarea,
html.dark select {
    background-color: #181818 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #e6e6e6 !important;
}

html.dark input:focus,
html.dark textarea:focus,
html.dark select:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2) !important;
    outline: none !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
    color: #666666 !important;
}

/* Chrome Autofill fix for Obsidian Dark */
html.dark input:-webkit-autofill,
html.dark input:-webkit-autofill:hover, 
html.dark input:-webkit-autofill:focus, 
html.dark input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #181818 inset !important;
    -webkit-text-fill-color: #e6e6e6 !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Modals & Overlays */
html.dark .fixed.inset-0.bg-black\/50,
html.dark .fixed.inset-0.bg-slate-900\/50 {
    background-color: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(4px) !important;
}

html.dark [id*="modal"] > div,
html.dark [class*="modal"] > div {
    background-color: #252525 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.75) !important;
}

/* Toast notifications */
html.dark #toastContainer > div {
    background-color: #252a33 !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6) !important;
}

/* ==========================================================================
   Tables & Data Lists
   ========================================================================== */

html.dark table {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

html.dark thead,
html.dark th {
    background-color: #181818 !important;
    color: #a0a0a0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

html.dark tbody tr {
    background-color: #252525;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

html.dark tbody tr:nth-child(even) {
    background-color: #212121 !important;
}

html.dark tbody tr:hover {
    background-color: #2b2b2b !important;
}

html.dark td {
    color: #d1d1d1 !important;
}

/* ==========================================================================
   Code Blocks & Pre
   ========================================================================== */

html.dark pre,
html.dark code {
    background-color: #141619 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    color: #38bdf8 !important;
}

/* ==========================================================================
   Theme Switcher Button Widget Styles (Pure Clean Icon - No Background/Borders)
   ========================================================================== */

.theme-toggle-btn,
.theme-toggle-btn:hover,
.theme-toggle-btn:focus,
.theme-toggle-btn:active,
html.dark .theme-toggle-btn,
html.dark .theme-toggle-btn:hover,
html.dark .theme-toggle-btn:focus,
html.dark .theme-toggle-btn:active {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    border-radius: 9999px;
    color: #475569;
    transition: color 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle-btn:hover {
    color: #4f46e5;
    transform: scale(1.15) rotate(-10deg);
}

.theme-toggle-btn:active {
    transform: scale(0.92);
}

html.dark .theme-toggle-btn {
    color: #fbbf24;
}

html.dark .theme-toggle-btn:hover {
    color: #fde047;
    transform: scale(1.15) rotate(15deg);
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.65));
}

.theme-icon-sun {
    display: none;
}
.theme-icon-moon {
    display: block;
    animation: moonSwing 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

html.dark .theme-icon-sun {
    display: block;
    animation: sunPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
html.dark .theme-icon-moon {
    display: none;
}

@keyframes sunPop {
    0% { transform: rotate(-90deg) scale(0.5); opacity: 0; }
    100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

@keyframes moonSwing {
    0% { transform: rotate(60deg) scale(0.5); opacity: 0; }
    100% { transform: rotate(0deg) scale(1); opacity: 1; }
}
