/*
 * Admin dashboard (/admin) in dark mode, matching the dark Overview panel.
 * Everything is scoped under .admin-dark, so no other page changes.
 *
 * How it works:
 * 1. Tailwind v4 utilities read their colours from CSS variables
 *    (e.g. .bg-gray-50 { background-color: var(--color-gray-50) }).
 *    Inside .admin-dark the gray scale is inverted (50 = dark surface,
 *    900 = near-white text) and the light tints (50-300) of the other
 *    colours become translucent dark tints. This covers bg, text, border,
 *    divide and every hover/focus variant without touching the markup.
 * 2. bg-white and the dark text shades (600-900) cannot be remapped with
 *    variables (white text and saturated buttons use the same variables),
 *    so they get explicit rules in the utilities layer. They use :where()
 *    so their specificity equals Tailwind's own utility; being later in
 *    the cascade they win, while hover:/focus: variants still win on hover.
 * 3. Bootstrap is loaded too, and its CSS is not in a layer, so it beats
 *    every layered rule (its .bg-white is even !important). The unlayered
 *    block at the end overrides those Bootstrap rules; without it bg-white
 *    cards and inputs stayed white, with light text on them.
 * The accent colour is Dannebrog red (#C8102E, the `dannebrog-*` colours in
 * Components/Styles/input.css). The Overview panel uses zinc/dannebrog/lime
 * and white/opacity classes, which are not remapped.
 */

.admin-dark {
    color-scheme: dark;

    /* Gray scale, inverted */
    --color-gray-50: #1c1c24;
    --color-gray-100: #22222b;
    --color-gray-200: #2a2a34;
    --color-gray-300: #3a3a46;
    --color-gray-400: #71717a;
    --color-gray-500: #a1a1aa;
    --color-gray-600: #b4b4bd;
    --color-gray-700: #d4d4d8;
    --color-gray-800: #e4e4e7;
    --color-gray-900: #f4f4f5;

    /* Light tints become translucent tints on the dark surface */
    --color-blue-50: rgba(59, 130, 246, 0.10);
    --color-blue-100: rgba(59, 130, 246, 0.16);
    --color-blue-200: rgba(59, 130, 246, 0.28);
    --color-blue-300: rgba(59, 130, 246, 0.40);
    --color-green-50: rgba(34, 197, 94, 0.10);
    --color-green-100: rgba(34, 197, 94, 0.16);
    --color-green-200: rgba(34, 197, 94, 0.28);
    --color-green-300: rgba(34, 197, 94, 0.40);
    --color-red-50: rgba(239, 68, 68, 0.10);
    --color-red-100: rgba(239, 68, 68, 0.16);
    --color-red-200: rgba(239, 68, 68, 0.28);
    --color-red-300: rgba(239, 68, 68, 0.40);
    --color-yellow-50: rgba(234, 179, 8, 0.10);
    --color-yellow-100: rgba(234, 179, 8, 0.16);
    --color-yellow-200: rgba(234, 179, 8, 0.28);
    --color-yellow-300: rgba(234, 179, 8, 0.40);
    --color-purple-50: rgba(168, 85, 247, 0.10);
    --color-purple-100: rgba(168, 85, 247, 0.16);
    --color-purple-200: rgba(168, 85, 247, 0.28);
    --color-purple-300: rgba(168, 85, 247, 0.40);
    --color-indigo-50: rgba(99, 102, 241, 0.10);
    --color-indigo-100: rgba(99, 102, 241, 0.16);
    --color-indigo-200: rgba(99, 102, 241, 0.28);
    --color-indigo-300: rgba(99, 102, 241, 0.40);
    --color-emerald-50: rgba(16, 185, 129, 0.10);
    --color-emerald-100: rgba(16, 185, 129, 0.16);
    --color-emerald-200: rgba(16, 185, 129, 0.28);
    --color-emerald-300: rgba(16, 185, 129, 0.40);
    --color-teal-50: rgba(20, 184, 166, 0.10);
    --color-teal-100: rgba(20, 184, 166, 0.16);
    --color-teal-200: rgba(20, 184, 166, 0.28);
    --color-teal-300: rgba(20, 184, 166, 0.40);
    --color-orange-50: rgba(249, 115, 22, 0.10);
    --color-orange-100: rgba(249, 115, 22, 0.16);
    --color-orange-200: rgba(249, 115, 22, 0.28);
    --color-orange-300: rgba(249, 115, 22, 0.40);
    --color-amber-50: rgba(245, 158, 11, 0.10);
    --color-amber-100: rgba(245, 158, 11, 0.16);
    --color-amber-200: rgba(245, 158, 11, 0.28);
    --color-amber-300: rgba(245, 158, 11, 0.40);
    --color-pink-50: rgba(236, 72, 153, 0.10);
    --color-pink-100: rgba(236, 72, 153, 0.16);
    --color-pink-200: rgba(236, 72, 153, 0.28);
    --color-pink-300: rgba(236, 72, 153, 0.40);
    --color-cyan-50: rgba(6, 182, 212, 0.10);
    --color-cyan-100: rgba(6, 182, 212, 0.16);
    --color-cyan-200: rgba(6, 182, 212, 0.28);
    --color-cyan-300: rgba(6, 182, 212, 0.40);
    --color-sky-50: rgba(14, 165, 233, 0.10);
    --color-sky-100: rgba(14, 165, 233, 0.16);
    --color-sky-200: rgba(14, 165, 233, 0.28);
    --color-sky-300: rgba(14, 165, 233, 0.40);
    --color-rose-50: rgba(244, 63, 94, 0.10);
    --color-rose-100: rgba(244, 63, 94, 0.16);
    --color-rose-200: rgba(244, 63, 94, 0.28);
    --color-rose-300: rgba(244, 63, 94, 0.40);
}

/* No light strip around the admin page (e.g. the mobile bottom padding of <main>). */
body:has(.admin-dark),
main:has(.admin-dark) {
    background-color: #09090b;
}

/* Base: default borders (Tailwind's preflight uses currentColor) and form controls. */
@layer base {
    .admin-dark *,
    .admin-dark ::before,
    .admin-dark ::after {
        border-color: rgba(255, 255, 255, 0.08);
    }

    .admin-dark input[type="checkbox"],
    .admin-dark input[type="radio"] {
        accent-color: #c8102e;
    }

    .admin-dark ::placeholder {
        color: #71717a;
    }
}

@layer utilities {
    /* Surfaces */
    :where(.admin-dark) .bg-white {
        background-color: #16161c;
    }

    /* Cards: a hairline ring instead of a drop shadow, and softer corners. */
    :where(.admin-dark) .bg-white.shadow,
    :where(.admin-dark) .bg-white.shadow-sm,
    :where(.admin-dark) .bg-white.shadow-md,
    :where(.admin-dark) .bg-white.shadow-lg {
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    }

    :where(.admin-dark) .rounded-lg {
        border-radius: 1rem;
    }

    :where(.admin-dark) .rounded-xl {
        border-radius: 1.25rem;
    }

    /* Dark text shades become light shades of the same colour. */
    :where(.admin-dark) .text-blue-600, :where(.admin-dark) .text-blue-700 { color: #60a5fa; }
    :where(.admin-dark) .text-blue-800, :where(.admin-dark) .text-blue-900 { color: #93c5fd; }
    :where(.admin-dark) .text-green-600, :where(.admin-dark) .text-green-700 { color: #4ade80; }
    :where(.admin-dark) .text-green-800, :where(.admin-dark) .text-green-900 { color: #86efac; }
    :where(.admin-dark) .text-red-600, :where(.admin-dark) .text-red-700 { color: #f87171; }
    :where(.admin-dark) .text-red-800, :where(.admin-dark) .text-red-900 { color: #fca5a5; }
    :where(.admin-dark) .text-yellow-600, :where(.admin-dark) .text-yellow-700 { color: #facc15; }
    :where(.admin-dark) .text-yellow-800, :where(.admin-dark) .text-yellow-900 { color: #fde047; }
    :where(.admin-dark) .text-purple-600, :where(.admin-dark) .text-purple-700 { color: #c084fc; }
    :where(.admin-dark) .text-purple-800, :where(.admin-dark) .text-purple-900 { color: #d8b4fe; }
    :where(.admin-dark) .text-indigo-600, :where(.admin-dark) .text-indigo-700 { color: #818cf8; }
    :where(.admin-dark) .text-indigo-800, :where(.admin-dark) .text-indigo-900 { color: #a5b4fc; }
    :where(.admin-dark) .text-emerald-600, :where(.admin-dark) .text-emerald-700 { color: #34d399; }
    :where(.admin-dark) .text-emerald-800, :where(.admin-dark) .text-emerald-900 { color: #6ee7b7; }
    :where(.admin-dark) .text-teal-600, :where(.admin-dark) .text-teal-700 { color: #2dd4bf; }
    :where(.admin-dark) .text-teal-800, :where(.admin-dark) .text-teal-900 { color: #5eead4; }
    :where(.admin-dark) .text-orange-600, :where(.admin-dark) .text-orange-700 { color: #fb923c; }
    :where(.admin-dark) .text-orange-800, :where(.admin-dark) .text-orange-900 { color: #fdba74; }
    :where(.admin-dark) .text-amber-600, :where(.admin-dark) .text-amber-700 { color: #fbbf24; }
    :where(.admin-dark) .text-amber-800, :where(.admin-dark) .text-amber-900 { color: #fcd34d; }
    :where(.admin-dark) .text-pink-600, :where(.admin-dark) .text-pink-700 { color: #f472b6; }
    :where(.admin-dark) .text-pink-800, :where(.admin-dark) .text-pink-900 { color: #f9a8d4; }
    :where(.admin-dark) .text-cyan-600, :where(.admin-dark) .text-cyan-700 { color: #22d3ee; }
    :where(.admin-dark) .text-cyan-800, :where(.admin-dark) .text-cyan-900 { color: #67e8f9; }
    :where(.admin-dark) .text-sky-600, :where(.admin-dark) .text-sky-700 { color: #38bdf8; }
    :where(.admin-dark) .text-sky-800, :where(.admin-dark) .text-sky-900 { color: #7dd3fc; }
    :where(.admin-dark) .text-rose-600, :where(.admin-dark) .text-rose-700 { color: #fb7185; }
    :where(.admin-dark) .text-rose-800, :where(.admin-dark) .text-rose-900 { color: #fda4af; }

    /* The same for hover:text-* (links and icon buttons). */
    @media (hover: hover) {
        :where(.admin-dark) .hover\:text-blue-600:hover,
        :where(.admin-dark) .hover\:text-blue-700:hover,
        :where(.admin-dark) .hover\:text-blue-800:hover,
        :where(.admin-dark) .hover\:text-blue-900:hover { color: #bfdbfe; }
        :where(.admin-dark) .hover\:text-green-700:hover,
        :where(.admin-dark) .hover\:text-green-800:hover { color: #bbf7d0; }
        :where(.admin-dark) .hover\:text-red-600:hover,
        :where(.admin-dark) .hover\:text-red-700:hover,
        :where(.admin-dark) .hover\:text-red-800:hover { color: #fecaca; }
        :where(.admin-dark) .hover\:text-yellow-700:hover,
        :where(.admin-dark) .hover\:text-yellow-800:hover { color: #fef08a; }
        :where(.admin-dark) .hover\:text-purple-700:hover,
        :where(.admin-dark) .hover\:text-purple-800:hover { color: #e9d5ff; }
        :where(.admin-dark) .hover\:text-indigo-700:hover,
        :where(.admin-dark) .hover\:text-indigo-800:hover { color: #c7d2fe; }
    }
}

/* Loading shimmer for the financial KPIs (defined in AdminDashboard.razor). */
.admin-dark .admin-financial-skeleton__track {
    background: linear-gradient(90deg, #1c1c24 0%, #2a2a34 50%, #1c1c24 100%);
    background-size: 200% 100%;
}

.admin-dark .admin-financial-skeleton__shine {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.03) 20%,
        rgba(255, 255, 255, 0.10) 50%,
        rgba(255, 255, 255, 0.03) 80%,
        rgba(255, 255, 255, 0) 100%
    );
}

/* Thin dark scrollbars for the wide admin tables. */
.admin-dark ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.admin-dark ::-webkit-scrollbar-thumb {
    background: #2a2a34;
    border-radius: 9999px;
}

.admin-dark ::-webkit-scrollbar-track {
    background: transparent;
}

/*
 * Unlayered overrides for Bootstrap (see note 3 at the top). Unlayered rules
 * also beat Tailwind's layered utilities, so this block is kept to surfaces
 * that must never be white and to form controls.
 */
.admin-dark {
    /* Bootstrap components (form-switch, etc.) read these. */
    --bs-body-bg: #16161c;
    --bs-body-color: #f4f4f5;
    --bs-border-color: rgba(255, 255, 255, 0.15);
    --bs-secondary-bg: #22222b;
}

.admin-dark .bg-white {
    background-color: #16161c !important;
}

/* Bootstrap's reboot is unlayered, so it beats these Tailwind utilities:
   label { display: inline-block } (checkbox lands on the text baseline, not centred),
   button { border-radius: 0; font-size: inherit } (pills and "?" became square, 16px text). */
.admin-dark label.inline-flex {
    display: inline-flex;
}

.admin-dark button.rounded-full {
    border-radius: 9999px;
}

.admin-dark button.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

.admin-dark button.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* The "?" metric help: a small round button. app.css gives every button a 44px minimum on
   phones; keep that tap area with an invisible ring instead of drawing a 44px square. */
.admin-dark button.admin-help-btn {
    position: relative;
    min-width: 0;
    min-height: 0;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    line-height: 1;
}

.admin-dark button.admin-help-btn::before {
    content: "";
    position: absolute;
    inset: -10px;
}

/* Form controls: always a dark field with white text, also when the markup says bg-white. */
.admin-dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="color"]):not([type="file"]),
.admin-dark select,
.admin-dark textarea {
    background-color: #16161c;
    color: #ffffff;
    color-scheme: dark;
}

.admin-dark option {
    background-color: #16161c;
    color: #ffffff;
}

.admin-dark input:disabled,
.admin-dark select:disabled,
.admin-dark textarea:disabled {
    background-color: #22222b;
    color: #a1a1aa;
}

/* Date pickers: the chosen date in white (Chrome/Safari draw each part
   separately), and a red highlight on the part being edited. */
.admin-dark input::-webkit-datetime-edit,
.admin-dark input::-webkit-datetime-edit-fields-wrapper,
.admin-dark input::-webkit-datetime-edit-day-field,
.admin-dark input::-webkit-datetime-edit-month-field,
.admin-dark input::-webkit-datetime-edit-year-field,
.admin-dark input::-webkit-datetime-edit-hour-field,
.admin-dark input::-webkit-datetime-edit-minute-field,
.admin-dark input::-webkit-datetime-edit-text {
    color: #ffffff;
}

.admin-dark input::-webkit-datetime-edit-day-field:focus,
.admin-dark input::-webkit-datetime-edit-month-field:focus,
.admin-dark input::-webkit-datetime-edit-year-field:focus,
.admin-dark input::-webkit-datetime-edit-hour-field:focus,
.admin-dark input::-webkit-datetime-edit-minute-field:focus {
    background-color: #c8102e;
    color: #ffffff;
    border-radius: 3px;
}

.admin-dark input::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

/* Bootstrap switches/checkboxes: dark when off, Dannebrog red when on. */
.admin-dark .form-check-input {
    background-color: #22222b;
    border-color: rgba(255, 255, 255, 0.25);
}

.admin-dark .form-check-input:checked {
    background-color: #c8102e;
    border-color: #c8102e;
}

.admin-dark .form-check-input:focus {
    border-color: #e8384f;
    box-shadow: 0 0 0 0.25rem rgba(200, 16, 46, 0.3);
}

.admin-dark .form-switch .form-check-input:not(:checked) {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255, 255, 255, 0.6%29'/%3e%3c/svg%3e");
}
