@tailwind base;
@tailwind components;
@tailwind utilities;

[x-cloak] {
    display: none !important;
}

.datepicker {
    z-index: 3000 !important;
}

@layer components {
    /*
     * Meeting attendees bulk actions: @tailwindcss/forms can reset submit buttons; keep label + fill visible
     * in light and dark admin without relying on hover.
     */
    #meeting-attendees-bulk-toolbar button[type='submit'][data-bulk-action='approve'] {
        border-width: 0 !important;
        background-color: theme('colors.emerald.700') !important;
        color: #fff !important;
    }

    #meeting-attendees-bulk-toolbar button[type='submit'][data-bulk-action='approve']:hover {
        background-color: theme('colors.emerald.800') !important;
    }

    html.dark #meeting-attendees-bulk-toolbar button[type='submit'][data-bulk-action='approve'] {
        background-color: theme('colors.emerald.600') !important;
    }

    html.dark #meeting-attendees-bulk-toolbar button[type='submit'][data-bulk-action='approve']:hover {
        background-color: theme('colors.emerald.500') !important;
    }

    #meeting-attendees-bulk-toolbar button[type='submit'][data-bulk-action='unapprove'] {
        border-width: 0 !important;
        background-color: theme('colors.slate.700') !important;
        color: #fff !important;
    }

    #meeting-attendees-bulk-toolbar button[type='submit'][data-bulk-action='unapprove']:hover {
        background-color: theme('colors.slate.800') !important;
    }

    html.dark #meeting-attendees-bulk-toolbar button[type='submit'][data-bulk-action='unapprove'] {
        background-color: theme('colors.slate.600') !important;
    }

    html.dark #meeting-attendees-bulk-toolbar button[type='submit'][data-bulk-action='unapprove']:hover {
        background-color: theme('colors.slate.500') !important;
    }

    /*
     * Select2 — systemadmin (main.admin-main). Scope by main, not .admin-select2, so modals and filters match.
     * Dropdown is portaled to body: dark styles use html.dark + .admin-select2-dropdown (not main.admin-main).
     */
    main.admin-main .select2-container {
        @apply block w-full max-w-full align-middle;
    }

    main.admin-main .select2-container--default .select2-selection--single {
        box-sizing: border-box;
        min-height: 2.5rem;
        height: 2.5rem;
        @apply flex items-center rounded-md border bg-white text-sm text-gray-900 shadow-sm;
        border-color: theme('colors.gray.300');
    }

    main.admin-main .select2-container--default .select2-selection--single .select2-selection__rendered {
        @apply min-w-0 flex-1 truncate pl-3 pr-8 text-sm text-gray-900;
        padding-top: 0;
        padding-bottom: 0;
        line-height: 2.5rem;
    }

    main.admin-main .select2-container--default .select2-selection--single .select2-selection__placeholder {
        @apply text-gray-500;
    }

    main.admin-main .select2-container--default .select2-selection--single .select2-selection__arrow {
        @apply h-full;
        height: 2.5rem;
        top: 0;
        right: 0.25rem;
    }

    main.admin-main .select2-container--default .select2-selection--single .select2-selection__arrow b {
        @apply border-gray-400;
        margin-top: -0.25rem;
    }

    /* Match x-text-input focus ring */
    main.admin-main .select2-container--default.select2-container--focus .select2-selection--single,
    main.admin-main .select2-container--default.select2-container--open .select2-selection--single {
        @apply border-indigo-500 ring-1 ring-indigo-500;
    }

    main.admin-main .select2-container--default .select2-selection--multiple {
        @apply min-h-10 rounded-md border bg-white py-1.5 pl-2 pr-2 text-sm text-gray-900 shadow-sm;
        border-color: theme('colors.gray.300');
    }

    main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__rendered {
        @apply m-0 block p-0;
    }

    main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice {
        /* Select2 places .choice__remove absolute left:0 - keep left padding for label text (symmetric Tailwind px-* breaks this). */
        box-sizing: border-box;
        margin-top: 0.125rem;
        margin-bottom: 0.125rem;
        padding: 0.125rem 0.375rem 0.125rem 1.375rem;
        position: relative;
        @apply mr-1 rounded border bg-gray-50 text-sm text-gray-800;
        border-color: theme('colors.gray.200');
    }

    main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        height: 1.25rem;
        width: 1.125rem;
        margin: 0 !important;
        padding: 0 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: none;
        border-right: 1px solid theme('colors.gray.200');
        border-radius: 0;
        font-size: 0.875rem;
        line-height: 1;
        cursor: pointer;
        background-color: transparent;
        color: theme('colors.gray.500');
        appearance: none;
        -webkit-appearance: none;
    }

    main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover,
    main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:focus {
        outline: none;
        color: theme('colors.gray.800');
        background-color: theme('colors.gray.100');
    }

    main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice__display {
        padding: 0;
        margin: 0;
    }

    main.admin-main .select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
        @apply text-sm text-gray-900 placeholder:text-gray-400;
        height: 1.75rem;
        margin-top: 0.125rem;
    }

    main.admin-main .select2-container--default.select2-container--focus:not(.select2-container--open) .select2-selection--multiple,
    main.admin-main .select2-container--default.select2-container--open .select2-selection--multiple {
        @apply border-indigo-500 ring-1 ring-indigo-500;
    }

    .select2-dropdown.admin-select2-dropdown {
        @apply overflow-hidden rounded-md border bg-white text-sm shadow-md;
        border-color: theme('colors.gray.300');
    }

    .select2-dropdown.admin-select2-dropdown .select2-search--dropdown {
        @apply border-b p-2;
        border-bottom-color: theme('colors.gray.200');
    }

    .select2-dropdown.admin-select2-dropdown .select2-search--dropdown .select2-search__field {
        box-sizing: border-box;
        @apply h-10 w-full rounded-md border px-3 text-sm text-gray-900 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500;
        border-color: theme('colors.gray.300');
    }

    .select2-dropdown.admin-select2-dropdown .select2-results__option {
        @apply px-3 py-2 text-sm;
    }

    .select2-dropdown.admin-select2-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
        @apply bg-slate-700 text-white;
    }

    /* Dark: same surface as html.dark main.admin-main input (slate-800 / slate-600 border) */
    html.dark main.admin-main .select2-container--default .select2-selection--single,
    html.dark main.admin-main .select2-container--default .select2-selection--multiple {
        @apply border-slate-600 bg-slate-800 text-slate-100;
    }

    html.dark main.admin-main .select2-container--default .select2-selection--single .select2-selection__rendered {
        @apply text-slate-100;
    }

    html.dark main.admin-main .select2-container--default .select2-selection--single .select2-selection__placeholder {
        @apply text-slate-400;
    }

    html.dark main.admin-main .select2-container--default .select2-selection--single .select2-selection__arrow b {
        @apply border-slate-400;
    }

    html.dark main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice {
        @apply border-slate-600 bg-slate-700 text-slate-200;
    }

    html.dark main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
        border-right-color: theme('colors.slate.600');
        color: theme('colors.slate.400');
    }

    html.dark main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover,
    html.dark main.admin-main .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:focus {
        background-color: theme('colors.slate.600');
        color: theme('colors.slate.100');
    }

    html.dark main.admin-main .select2-container--default.select2-container--focus .select2-selection--single,
    html.dark main.admin-main .select2-container--default.select2-container--open .select2-selection--single,
    html.dark main.admin-main .select2-container--default.select2-container--focus .select2-selection--multiple,
    html.dark main.admin-main .select2-container--default.select2-container--open .select2-selection--multiple {
        @apply border-indigo-400 ring-indigo-400;
    }

    /* Dropdown is under <body>; must not use main.admin-main ancestor */
    html.dark .select2-dropdown.admin-select2-dropdown {
        @apply border-slate-600 bg-slate-800 text-slate-100;
    }

    html.dark .select2-dropdown.admin-select2-dropdown .select2-search--dropdown {
        @apply border-slate-700;
    }

    html.dark .select2-dropdown.admin-select2-dropdown .select2-search--dropdown .select2-search__field {
        @apply border-slate-600 bg-slate-900 text-slate-100 focus:border-indigo-400 focus:ring-indigo-400;
    }

    html.dark .select2-dropdown.admin-select2-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
        @apply bg-slate-600 text-white;
    }

    /* Select2: stack above fixed modals (z-50) */
    .select2-container--open {
        z-index: 10050 !important;
    }

    .select2-dropdown {
        z-index: 10051 !important;
    }

    /*
     * Admin sidebar — desktop collapse (narrow icon rail). Mobile drawer unchanged.
     */
    @media (min-width: 768px) {
        aside.admin-sidebar.sidebar-collapsed .sidebar-brand-text {
            @apply hidden;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-brand-row {
            @apply justify-center px-2;
        }

        aside.admin-sidebar.sidebar-collapsed #admin-sidebar-nav {
            @apply px-2;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-nav-section-label,
        aside.admin-sidebar.sidebar-collapsed .sidebar-nav-text,
        aside.admin-sidebar.sidebar-collapsed .sidebar-nav-shortcut {
            @apply hidden;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-group-chevron {
            @apply hidden;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-group-summary {
            @apply justify-center px-2;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-details-inner {
            @apply hidden;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-footer-text,
        aside.admin-sidebar.sidebar-collapsed .sidebar-user-meta {
            @apply hidden;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-footer-link {
            @apply justify-center px-2;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-footer {
            @apply px-2;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-user-card {
            @apply justify-center border-0 bg-transparent p-0 shadow-none;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-top-link {
            @apply justify-center;
        }

        aside.admin-sidebar.sidebar-collapsed .sidebar-child-link {
            @apply justify-center;
        }
    }

    /*
     * Admin sidebar nav — scrollbar gutter always reserved (no layout shift on hover).
     * Thumb appears on sidebar hover; track width stays constant (WebKit 4px; Firefox thin).
     */
    #admin-sidebar-nav {
        scrollbar-width: thin;
        scrollbar-color: transparent transparent;
    }

    aside.admin-sidebar:hover #admin-sidebar-nav {
        scrollbar-color: rgb(148 163 184 / 0.55) transparent;
    }

    html.dark aside.admin-sidebar:hover #admin-sidebar-nav {
        scrollbar-color: rgb(100 116 139 / 0.65) transparent;
    }

    #admin-sidebar-nav::-webkit-scrollbar {
        width: 4px;
        height: 0;
    }

    #admin-sidebar-nav::-webkit-scrollbar-track {
        background: transparent;
    }

    #admin-sidebar-nav::-webkit-scrollbar-thumb {
        border-radius: 9999px;
        background-color: transparent;
    }

    aside.admin-sidebar:hover #admin-sidebar-nav::-webkit-scrollbar-thumb {
        background-color: rgb(148 163 184 / 0.55);
    }

    html.dark aside.admin-sidebar:hover #admin-sidebar-nav::-webkit-scrollbar-thumb {
        background-color: rgb(100 116 139 / 0.72);
    }
}

/*
 * Dark utility overrides: use [class~="…"] instead of .utility so Tailwind does not treat these
 * as circular @apply references alongside Select2 rules that @apply the same utilities.
 */
html.dark main.admin-main [class~='border-gray-200'],
html.dark main.admin-main [class~='border-gray-300'] {
    border-color: theme('colors.slate.600');
}

html.dark main.admin-main [class~='border-slate-100'] {
    border-color: theme('colors.slate.700');
}

html.dark main.admin-main [class~='border-slate-200'] {
    border-color: theme('colors.slate.600');
}

html.dark main.admin-main [class~='bg-white'] {
    background-color: theme('colors.slate.900');
}

html.dark main.admin-main [class~='bg-gray-50'],
html.dark main.admin-main [class~='bg-slate-50'],
html.dark main.admin-main [class~='bg-slate-100'] {
    background-color: theme('colors.slate.800');
}

html.dark main.admin-main [class~='text-slate-900'] {
    color: theme('colors.slate.100');
}

html.dark main.admin-main [class~='text-slate-800'] {
    color: theme('colors.slate.200');
}

html.dark main.admin-main [class~='text-slate-700'] {
    color: theme('colors.slate.300');
}

html.dark main.admin-main [class~='text-slate-500'] {
    color: theme('colors.slate.400');
}

html.dark main.admin-main [class~='text-slate-400'] {
    color: theme('colors.slate.500');
}

html.dark main.admin-main [class~='text-slate-300'] {
    color: theme('colors.slate.500');
}

html.dark main.admin-main [class~='text-gray-900'] {
    color: theme('colors.slate.100');
}

html.dark main.admin-main [class~='text-gray-800'] {
    color: theme('colors.slate.200');
}

html.dark main.admin-main [class~='text-gray-700'] {
    color: theme('colors.slate.300');
}

html.dark main.admin-main [class~='text-gray-600'] {
    color: theme('colors.slate.400');
}

html.dark main.admin-main [class~='text-gray-500'] {
    color: theme('colors.slate.500');
}

html.dark main.admin-main [class~='from-slate-50'] {
    --tw-gradient-from: theme('colors.slate.800') var(--tw-gradient-from-position);
    --tw-gradient-to: rgb(15 23 42 / 0) var(--tw-gradient-to-position);
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-via), var(--tw-gradient-to);
}

html.dark main.admin-main [class~='to-white'] {
    --tw-gradient-to: theme('colors.slate.900') var(--tw-gradient-to-position);
}

html.dark main.admin-main [class~='hover:bg-gray-50']:hover {
    background-color: theme('colors.slate.700');
}

html.dark main.admin-main [class~='hover:bg-blue-100']:hover {
    background-color: rgb(30 58 138 / 0.4);
}

html.dark main.admin-main [class~='hover:text-gray-800']:hover {
    color: theme('colors.slate.200');
}

html.dark main.admin-main input:not([type='checkbox']):not([type='radio']),
html.dark main.admin-main textarea,
html.dark main.admin-main select {
    border-color: theme('colors.slate.600');
    background-color: theme('colors.slate.800');
    color: theme('colors.slate.100');
}

html.dark main.admin-main input::placeholder,
html.dark main.admin-main textarea::placeholder {
    color: theme('colors.slate.500');
}

html.dark main.admin-main tr[class~='border-t'] {
    border-color: theme('colors.slate.700');
}

html.dark .guest-shell {
    background-color: theme('colors.slate.950');
}

html.dark .guest-shell .guest-card {
    border-color: theme('colors.slate.700');
    background-color: theme('colors.slate.900');
    box-shadow:
        0 10px 15px -3px rgb(0 0 0 / 0.2),
        0 4px 6px -4px rgb(0 0 0 / 0.2);
}

html.dark .guest-shell .guest-card label {
    color: theme('colors.slate.300');
}

html.dark .guest-shell .guest-card [class~='text-gray-600'] {
    color: theme('colors.slate.400');
}

html.dark .guest-shell .guest-card input[type='email'],
html.dark .guest-shell .guest-card input[type='password'],
html.dark .guest-shell .guest-card input[type='text'] {
    border-color: theme('colors.slate.600');
    background-color: theme('colors.slate.800');
    color: theme('colors.slate.100');
}

html.dark .guest-shell .guest-card input[type='checkbox'] {
    border-color: theme('colors.slate.600');
    background-color: theme('colors.slate.800');
}

html.dark .guest-shell .guest-card [class~='text-gray-600'][href] {
    color: theme('colors.slate.400');
}

html.dark .guest-shell .guest-card [class~='text-gray-600'][href]:hover {
    color: theme('colors.slate.200');
}

/*
 * Device configuration — parliamentarian biometric column icons.
 * Use explicit colors so SVG stroke (currentColor) is correct even when Tailwind
 * does not emit utilities from dynamic Blade class branches.
 */
.device-profile-biometric-icon--idle {
    color: #d1d5db;
}

html.dark main.admin-main .device-profile-biometric-icon--idle {
    color: #64748b;
}

.device-profile-biometric-icon--ok {
    color: #16a34a;
}

html.dark main.admin-main .device-profile-biometric-icon--ok {
    color: #22c55e;
}

.device-profile-biometric-icon--pending {
    color: #ca8a04;
}

html.dark main.admin-main .device-profile-biometric-icon--pending {
    color: #facc15;
}
