/* Admin CSS Customizations */
body {
    background-color: #f3f4f6;
    /* Tailwind gray-100 */
}

/* Custom Scrollbar for Admin
   (used to be a 6px almost invisible bar: wide tables and the side menu looked like they
    could not be scrolled at all) */
* {
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 transparent;
}

html.dark * {
    scrollbar-color: #64748b transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* Dark mode scrollbar */
html.dark ::-webkit-scrollbar-track {
    background: transparent;
}

html.dark ::-webkit-scrollbar-thumb {
    background: #64748b;
    border: 2px solid transparent;
    background-clip: padding-box;
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* Side menu: always scrollable, with room reserved for the bar so the menu never jumps */
#sidebar-menu-container {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

/* Wide tables: the scroll area itself is capped in height, so its horizontal bar stays on screen
   instead of sitting at the very bottom of a 50-row page. Drag or use the wheel to pan (see
   admin-table-scroll.js), and the Action column stays pinned on the right. */
.table-scroll-x {
    overflow: auto;
    max-height: calc(100dvh - 300px);
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
}

.table-scroll-x.is-drag-scrolling {
    cursor: grabbing;
    user-select: none;
}

/* header stays visible while scrolling inside the box */
.table-scroll-x table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f8fafc;
}

html.dark .table-scroll-x table thead th {
    background: #16202f;
}

/* Edge arrows (added by admin-table-scroll.js) */
.table-scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.92);
    color: #475569;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.table-scroll-arrow:hover {
    transform: translateY(-50%) scale(1.06);
}

.table-scroll-arrow-left { left: 8px; }
.table-scroll-arrow-right { right: 8px; }

.table-scroll-arrow.is-hidden {
    opacity: 0;
    pointer-events: none;
}

html.dark .table-scroll-arrow {
    background: rgba(15, 23, 42, 0.92);
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.25);
}

@media (max-width: 640px) {
    .table-scroll-x {
        max-height: none;
        cursor: auto;
    }

    .table-scroll-arrow { display: none; }
}

table.sticky-action th:last-child,
table.sticky-action td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #ffffff;
    box-shadow: -10px 0 12px -10px rgba(15, 23, 42, 0.35);
}

table.sticky-action thead th:last-child {
    z-index: 4;
    background: #f8fafc;
}

html.dark table.sticky-action th:last-child,
html.dark table.sticky-action td:last-child {
    background: #0f172a;
    box-shadow: -10px 0 12px -10px rgba(0, 0, 0, 0.6);
}

html.dark table.sticky-action thead th:last-child {
    background: #16202f;
}

@media (max-width: 640px) {
    /* on a phone the pinned column would eat most of the screen */
    table.sticky-action th:last-child,
    table.sticky-action td:last-child {
        position: static;
        box-shadow: none;
    }
}

/* Smooth transitions for sidebar */
.sidebar-transition {
    transition: all 0.3s ease-in-out;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* NProgress Customization */
#nprogress .bar {
    background: #6366f1 !important;
    /* brand-500 */
    height: 3px !important;
}

#nprogress .peg {
    box-shadow: 0 0 10px #6366f1, 0 0 5px #6366f1 !important;
}

#nprogress .spinner-icon {
    border-top-color: #6366f1 !important;
    border-left-color: #6366f1 !important;
}

/* SweetAlert2 Dark Mode Support */
html.dark .swal2-popup {
    background-color: #0f172a !important;
    /* slate-900 */
    color: #f8fafc !important;
    /* slate-50 */
    border: 1px solid #1e293b !important;
    /* slate-800 */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.2) !important;
}

html.dark .swal2-title {
    color: #f1f5f9 !important;
    /* slate-100 */
}

html.dark .swal2-html-container {
    color: #cbd5e1 !important;
    /* slate-300 */
}

html.dark .swal2-success-circular-line-left,
html.dark .swal2-success-circular-line-right,
html.dark .swal2-success-fix {
    display: none !important;
    background: transparent !important;
}

html.dark .swal2-icon.swal2-info,
html.dark .swal2-icon.swal2-question,
html.dark .swal2-icon.swal2-warning,
html.dark .swal2-icon.swal2-error {
    background-color: transparent !important;
}

/* =========================================================
   GLOBAL RESPONSIVE LAYOUT UTILITIES
   ========================================================= */

/* Prevent flex child blowouts and enable clean truncation */
.min-w-0 {
    min-width: 0 !important;
}

.flex-item-safe {
    min-width: 0 !important;
    flex-shrink: 1;
}

.truncate-safe {
    min-width: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Standard Page Header (Stacks gracefully on mobile/window shrink) */
.admin-page-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
    .admin-page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* Standard Stats / KPI Grid (1 col mobile, 2 col tablet, 4 col desktop) */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
    .admin-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (min-width: 1024px) {
    .admin-stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Adaptive Card Grid (auto-fits card size, never squishes or overflows) */
.admin-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 1.25rem;
}
@media (max-width: 640px) {
    .admin-cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Standard Filter / Search Toolbar */
.admin-filter-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (min-width: 768px) {
    .admin-filter-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* Universal Responsive Table Wrapper & Minimum Table Width Protection */
.admin-table-responsive,
.table-responsive-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    border-radius: 1rem;
}

/* Ensure data tables maintain legible column widths on small screens */
.admin-table-responsive > table:not(.table-no-min-w),
.table-responsive-container > table:not(.table-no-min-w) {
    min-width: 640px;
}

@media (min-width: 1024px) {
    .admin-table-responsive > table:not(.table-force-scroll),
    .table-responsive-container > table:not(.table-force-scroll) {
        min-width: 100%;
    }
}

/* Swipeable horizontal pill toolbars for mobile */
.mobile-toolbar-scroll {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    gap: 0.5rem;
    padding-bottom: 4px;
    scrollbar-width: none; /* Firefox */
}

.mobile-toolbar-scroll::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

/* Responsive Modal Card Standardization (Supports both .admin-modal-* and .modal-responsive-*) */
.admin-modal-card,
.modal-responsive-card {
    width: 100%;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border-radius: 1.25rem;
}

.admin-modal-body,
.modal-responsive-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-modal-footer,
.modal-responsive-footer {
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .admin-modal-card,
    .modal-responsive-card {
        width: calc(100vw - 1.25rem) !important;
        max-width: 100% !important;
        max-height: 92dvh !important;
        margin: auto !important;
        border-radius: 1rem !important;
    }

    .admin-modal-body,
    .modal-responsive-body {
        padding: 1rem !important;
    }

    .admin-modal-footer,
    .modal-responsive-footer {
        padding: 0.75rem 1rem !important;
        background: inherit !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10 !important;
    }
}

/* Hide scrollbar utility */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* =======================================================
   LIQUID GLASS SWEETALERT2 THEME
   ======================================================= */

/* Backdrop with liquid dark blur */
.swal2-container.swal2-backdrop-show {
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.72) 0%, rgba(3, 7, 18, 0.88) 100%) !important;
    backdrop-filter: blur(14px) saturate(190%) !important;
    -webkit-backdrop-filter: blur(14px) saturate(190%) !important;
}

/* Liquid Glass Modal Popup */
.swal2-popup,
.swal2-popup.liquid-glass-popup {
    background: rgba(15, 23, 42, 0.78) !important;
    backdrop-filter: blur(32px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(32px) saturate(200%) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 28px !important;
    padding: 2.2rem 2.4rem !important;
    box-shadow: 
        0 30px 70px -15px rgba(0, 0, 0, 0.85),
        0 0 50px -10px rgba(99, 102, 241, 0.2),
        inset 0 1px 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -1px 2px 0 rgba(0, 0, 0, 0.45) !important;
    color: #ffffff !important;
    overflow: hidden !important;
    position: relative !important;
}

/* Specular liquid sheen highlight */
.swal2-popup::before,
.swal2-popup.liquid-glass-popup::before {
    content: '';
    position: absolute;
    top: 0;
    left: 12%;
    right: 12%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    pointer-events: none;
}

/* Soft ambient background glow */
.swal2-popup::after,
.swal2-popup.liquid-glass-popup::after {
    content: '';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    height: 160px;
    background: radial-gradient(ellipse, rgba(99, 102, 241, 0.18), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Title Styling */
.swal2-title,
.liquid-glass-title {
    font-family: 'Prompt', 'Inter', sans-serif !important;
    font-weight: 800 !important;
    font-size: 1.6rem !important;
    color: #ffffff !important;
    padding: 0.6rem 0 0.4rem !important;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.6) !important;
    letter-spacing: -0.02em !important;
    position: relative;
    z-index: 1;
}

/* Content / HTML / Body text */
.swal2-html-container,
.liquid-glass-html {
    font-family: 'Prompt', 'Inter', sans-serif !important;
    color: rgba(226, 232, 240, 0.88) !important;
    font-size: 0.96rem !important;
    line-height: 1.65 !important;
    margin: 0.5rem 0 1.6rem !important;
    position: relative;
    z-index: 1;
}

/* Icons Liquid Glow */
.swal2-icon {
    font-size: 1rem !important;
    border-width: 3px !important;
    margin: 1.2rem auto 0.8rem !important;
    width: 5em !important;
    height: 5em !important;
    box-sizing: content-box !important;
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.04) !important;
    backdrop-filter: blur(12px) !important;
}

/* Warning Icon */
.swal2-icon.swal2-warning {
    border-color: rgba(245, 158, 11, 0.85) !important;
    color: #fbbf24 !important;
    box-shadow: 0 0 35px rgba(245, 158, 11, 0.35), inset 0 0 20px rgba(245, 158, 11, 0.2) !important;
    filter: drop-shadow(0 0 12px rgba(245, 158, 11, 0.45));
}

/* Success Icon - Pure Clean Liquid Glass (No broken mask slices) */
.swal2-icon.swal2-success {
    border: 3px solid rgba(16, 185, 129, 0.85) !important;
    color: #34d399 !important;
    background: radial-gradient(circle at center, rgba(16, 185, 129, 0.22) 0%, rgba(16, 185, 129, 0.04) 65%, transparent 100%) !important;
    box-shadow: 0 0 35px rgba(16, 185, 129, 0.4), inset 0 0 15px rgba(16, 185, 129, 0.2) !important;
    filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.45));
    border-radius: 50% !important;
    overflow: hidden !important;
}

/* Hide legacy opaque cutting masks and duplicate rings completely */
.swal2-icon.swal2-success .swal2-success-circular-line-left,
.swal2-icon.swal2-success .swal2-success-circular-line-right,
.swal2-icon.swal2-success .swal2-success-fix,
.swal2-icon.swal2-success .swal2-success-ring {
    display: none !important;
    background: transparent !important;
    border: none !important;
    opacity: 0 !important;
}

/* Crisp Neon Glowing Checkmark */
.swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: #34d399 !important;
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.95) !important;
    border-radius: 4px !important;
    z-index: 5 !important;
}

/* Error Icon */
.swal2-icon.swal2-error {
    border-color: rgba(244, 63, 94, 0.85) !important;
    color: #fb7185 !important;
    box-shadow: 0 0 35px rgba(244, 63, 94, 0.35), inset 0 0 20px rgba(244, 63, 94, 0.2) !important;
    filter: drop-shadow(0 0 12px rgba(244, 63, 94, 0.45));
}
.swal2-icon.swal2-error [class^='swal2-x-mark-line'] {
    background-color: #fb7185 !important;
}

/* Info Icon */
.swal2-icon.swal2-info {
    border-color: rgba(59, 130, 246, 0.85) !important;
    color: #60a5fa !important;
    box-shadow: 0 0 35px rgba(59, 130, 246, 0.35), inset 0 0 20px rgba(59, 130, 246, 0.2) !important;
    filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.45));
}

/* Actions Container */
.swal2-actions,
.liquid-glass-actions {
    gap: 0.85rem !important;
    margin: 1.5rem auto 0 !important;
    width: 100% !important;
    justify-content: center !important;
    position: relative;
    z-index: 1;
}

/* Confirm Button (Liquid Glass Primary / Danger) */
.swal2-confirm,
.liquid-glass-btn-danger {
    border-radius: 16px !important;
    padding: 0.8rem 1.9rem !important;
    font-family: 'Prompt', 'Inter', sans-serif !important;
    font-size: 0.94rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em !important;
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 50%, #be123c 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
    box-shadow: 0 8px 25px -4px rgba(244, 63, 94, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.45) !important;
    color: #ffffff !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    outline: none !important;
    cursor: pointer !important;
}
.swal2-confirm:hover,
.liquid-glass-btn-danger:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 12px 32px -4px rgba(244, 63, 94, 0.72), inset 0 1px 1px rgba(255, 255, 255, 0.55) !important;
    background: linear-gradient(135deg, #fb7185 0%, #f43f5e 50%, #e11d48 100%) !important;
}
.swal2-confirm:active,
.liquid-glass-btn-danger:active {
    transform: scale(0.96) !important;
}

/* Confirm Button Variant (Primary / Non-danger) */
.liquid-glass-btn-primary {
    border-radius: 16px !important;
    padding: 0.8rem 1.9rem !important;
    font-family: 'Prompt', 'Inter', sans-serif !important;
    font-size: 0.94rem !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #4338ca 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
    box-shadow: 0 8px 25px -4px rgba(99, 102, 241, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.45) !important;
    color: #ffffff !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    outline: none !important;
    cursor: pointer !important;
}
.liquid-glass-btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 12px 32px -4px rgba(99, 102, 241, 0.72), inset 0 1px 1px rgba(255, 255, 255, 0.55) !important;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #4f46e5 100%) !important;
}
.liquid-glass-btn-primary:active {
    transform: scale(0.96) !important;
}

/* Cancel Button (Frosted Liquid Glass) */
.swal2-cancel,
.liquid-glass-btn-cancel {
    border-radius: 16px !important;
    padding: 0.8rem 1.9rem !important;
    font-family: 'Prompt', 'Inter', sans-serif !important;
    font-size: 0.94rem !important;
    font-weight: 700 !important;
    background: rgba(255, 255, 255, 0.08) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.2) !important;
    color: #cbd5e1 !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    outline: none !important;
    cursor: pointer !important;
}
.swal2-cancel:hover,
.liquid-glass-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.28) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.3) !important;
}
.swal2-cancel:active,
.liquid-glass-btn-cancel:active {
    transform: scale(0.96) !important;
}

/* Toast Variant with Liquid Glass */
.swal2-popup.swal2-toast,
.liquid-glass-toast {
    background: rgba(15, 23, 42, 0.85) !important;
    backdrop-filter: blur(28px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(28px) saturate(200%) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 20px !important;
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.75), inset 0 1px 1px rgba(255, 255, 255, 0.3) !important;
    padding: 0.9rem 1.3rem !important;
}
.swal2-popup.swal2-toast .swal2-title {
    font-size: 0.96rem !important;
    padding: 0 !important;
}

/* Smooth Liquid Animation */
@keyframes liquidPop {
    0% {
        transform: scale(0.9) translateY(18px);
        opacity: 0;
    }
    60% {
        transform: scale(1.02) translateY(-2px);
        opacity: 1;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}
.swal2-show {
    animation: liquidPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}