/* ============================================
   LEVIIA SCHEDULE - DARK THEME
   ============================================
   Under Tailwind/daisyUI (Bulma has been removed), daisyUI itself
   handles the light/dark switch for all of its components (buttons,
   alerts, badges, cards...) through its own --color-* variables and the
   [data-theme] attribute - no more manual contrast fixes like in the
   Bulma days. All that's left here is what daisyUI can't know about:
   FullCalendar overrides (an external library with its own DOM and
   classes) and a couple of generic, framework-independent accessibility
   rules.
   ============================================ */

/* FullCalendar in dark mode - the --fc-event-* variables are what
   .fc-event-main (the text actually rendered, notably in the Week/Day
   views) really reads, not the container's plain background-color/color
   (see the detailed comment in vendor/fullcalendar-overrides.css - a
   contrast bug where the event text stayed white/unreadable on a light
   background). */
[data-theme="dark"] .fc-event-shift {
    --fc-event-bg-color: var(--app-color-primary) !important;
    --fc-event-border-color: var(--app-color-primary) !important;
    --fc-event-text-color: var(--color-primary-content) !important;
    background-color: var(--app-color-primary) !important;
    border-color: var(--app-color-primary) !important;
    color: var(--color-primary-content) !important;
}

[data-theme="dark"] .fc-event-oncall {
    --fc-event-bg-color: var(--app-color-info) !important;
    --fc-event-border-color: var(--app-color-info) !important;
    --fc-event-text-color: var(--color-info-content) !important;
    background-color: var(--app-color-info) !important;
    border-color: var(--app-color-info) !important;
    color: var(--color-info-content) !important;
}

[data-theme="dark"] .fc-event-leave {
    --fc-event-bg-color: var(--color-danger) !important;
    --fc-event-border-color: var(--color-danger) !important;
    --fc-event-text-color: var(--color-error-content) !important;
    background-color: var(--color-danger) !important;
    border-color: var(--color-danger) !important;
    color: var(--color-error-content) !important;
}

[data-theme="dark"] .fc-event-shift .fc-event-main,
[data-theme="dark"] .fc-event-oncall .fc-event-main,
[data-theme="dark"] .fc-event-leave .fc-event-main {
    color: var(--fc-event-text-color) !important;
}

[data-theme="dark"] .fc {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* FullCalendar's global variables (read by ALL of its internal borders/
   backgrounds, including the Week/Day views - time grid, columns,
   separators - which the .fc-day/.fc-col-header-cell selectors below
   never cover, since those only target the Month view). Without this,
   the borders stayed at #ddd (FullCalendar's hardcoded light gray),
   unreadable/broken against a dark background. */
[data-theme="dark"] #calendar {
    --fc-border-color: var(--border-primary);
    --fc-page-bg-color: var(--bg-primary);
    --fc-neutral-bg-color: var(--bg-secondary);
    --fc-list-event-hover-bg-color: var(--bg-secondary);
    --fc-more-link-bg-color: var(--bg-tertiary);
    --fc-more-link-text-color: var(--text-primary);
    --fc-non-business-color: color-mix(in oklab, var(--bg-secondary) 60%, transparent);
    --fc-today-bg-color: color-mix(in oklab, var(--app-color-primary) 15%, transparent);
}

[data-theme="dark"] .fc-today,
[data-theme="dark"] .fc-day:hover,
[data-theme="dark"] .fc-day-today {
    background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .fc-header-toolbar {
    background-color: var(--bg-primary) !important;
}

[data-theme="dark"] .fc-col-header-cell,
[data-theme="dark"] .fc-day-header {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .fc-day {
    background-color: var(--bg-primary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .fc-event {
    border-color: currentColor !important;
}

[data-theme="dark"] .fc-page {
    background-color: var(--bg-primary) !important;
}

[data-theme="dark"] #calendar {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="dark"] .external-event-container {
    background: var(--bg-secondary);
}

[data-theme="dark"] .external-event {
    background: var(--app-color-primary);
}

[data-theme="dark"] .external-event.oncall {
    background: var(--app-color-info);
}

[data-theme="dark"] .external-event.leave {
    background: var(--color-danger);
}

[data-theme="dark"] .fc-event-selected {
    box-shadow: 0 0 0 2px var(--app-color-warning) !important;
}

/* Visible focus - generic, framework-independent */
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] input:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] textarea:focus-visible,
[data-theme="dark"] [tabindex]:focus-visible {
    outline: 2px solid var(--app-color-primary) !important;
    outline-offset: 2px !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    [data-theme="dark"] *,
    [data-theme="dark"] *::before,
    [data-theme="dark"] *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
