/* -----------------------------------------------------------------------------
   FreelancerDashboard dark mode
   -----------------------------------------------------------------------------

   Activation:
     theme.js and the inline script in base.html resolve the user's choice
     (light | dark | auto) and set data-theme and data-bs-theme on <html>
     before first paint. Bootstrap 5.3 reads data-bs-theme and flips its own
     components (close buttons, form-select arrows, focus rings, and so on).

   Strategy:
     1. Redefine the colour roles from brand.css. Every component rule in
        components.css reads a role, so it flips with no dark selector.
        brand.css also maps the roles onto Bootstrap's custom properties.
     2. Keep only rules for things that carry brand colour of their own
        or come from a third-party widget (Quill, the theme toggle).

   Do not override --white. Several rules use it as the text colour on a
   coloured button.
   ----------------------------------------------------------------------------- */

html[data-theme="dark"] {
    color-scheme: dark;

    /* Brand */
    --fd-primary:            #8B5CF6;
    --fd-primary-rgb:        139, 92, 246;
    --fd-primary-hover:      #A78BFA;
    --fd-primary-fill:       #7C3AED;
    --fd-primary-fill-hover: #6D28D9;
    --fd-link:               #A78BFA;
    --fd-link-rgb:           167, 139, 250;
    --fd-link-hover:         #C4B5FD;
    --fd-link-hover-rgb:     196, 181, 253;

    /* Status */
    --fd-success:      #10B981;
    --fd-success-rgb:  16, 185, 129;
    --fd-success-text: #34D399;
    --fd-success-fill: #047857;
    --fd-warning:      #FBBF24;
    --fd-warning-rgb:  251, 191, 36;
    --fd-warning-text: #FBBF24;
    --fd-warning-fill: #FBBF24;
    --fd-danger:       #EF4444;
    --fd-danger-rgb:   239, 68, 68;
    --fd-danger-text:  #F87171;
    --fd-danger-fill:  #DC2626;
    --fd-info:         #60A5FA;
    --fd-info-rgb:     96, 165, 250;
    --fd-info-text:    #93C5FD;
    --fd-info-fill:    #2563EB;

    /* Surfaces and text */
    --fd-bg-page:      #0B0F19;
    --fd-bg-surface:   #1F2937;
    --fd-bg-alt:       #111827;
    --fd-border:       #374151;
    --fd-text:         #F9FAFB;
    --fd-text-muted:   #9CA3AF;
    --fd-head-bg:      #111827;
    --fd-head-fg:      #F9FAFB;
    --fd-input-bg:     #111827;
    --fd-input-border: #4B5563;
    --fd-focus-ring:   rgba(139, 92, 246, 0.35);
    --fd-page-rgb:     11, 15, 25;
    --fd-surface-rgb:  31, 41, 55;
    --fd-alt-rgb:      17, 24, 39;
    --fd-border-rgb:   55, 65, 81;
    --fd-text-rgb:     249, 250, 251;
    --fd-muted-rgb:    156, 163, 175;

    /* Dark surfaces separate with borders, not shadows. */
    --fd-shadow-sm: 0 0 0 0 transparent;
    --fd-shadow:    0 0 0 0 transparent;
    --fd-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
    --fd-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.6);

    --bs-dark-rgb: 17, 24, 39;
}

/* ---- Third-party: Quill rich-text editor ---- */
html[data-theme="dark"] .ql-toolbar .ql-stroke { stroke: var(--fd-text); }
html[data-theme="dark"] .ql-toolbar .ql-fill { fill: var(--fd-text); }
html[data-theme="dark"] .ql-toolbar .ql-picker-label,
html[data-theme="dark"] .ql-toolbar .ql-picker-options { color: var(--fd-text); }
html[data-theme="dark"] .ql-toolbar .ql-picker-options { background-color: var(--fd-bg-surface); }

/* ---- Theme toggle control ---- */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle-btn:hover,
.theme-toggle-btn:focus {
    background-color: var(--theme-toggle-hover-bg);
    outline: none;
}
.theme-toggle-btn .theme-icon-light,
.theme-toggle-btn .theme-icon-dark,
.theme-toggle-btn .theme-icon-auto {
    display: none;
}
html[data-theme-pref="light"] .theme-toggle-btn .theme-icon-light { display: inline-block; }
html[data-theme-pref="dark"]  .theme-toggle-btn .theme-icon-dark  { display: inline-block; }
html[data-theme-pref="auto"]  .theme-toggle-btn .theme-icon-auto  { display: inline-block; }

/* Sidebar variant matches the other nav items visually */
.nav-item .theme-toggle-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
    border-radius: 0;
    gap: 0.75rem;
}
.nav-item .theme-toggle-btn i {
    width: 1.25rem;
    text-align: center;
}
