/* =========================================================
   File: theme-premium-extras.css
   Purpose:
   Premium UI Enhancements + Final Stable Fixes
========================================================= */

:root {
    --theme-grad-primary: linear-gradient(135deg, #111827 0%, #7f1d1d 100%);
    --theme-grad-secondary: linear-gradient(135deg, #1f2937 0%, #0f172a 100%);
    --theme-grad-success: linear-gradient(135deg, #059669 0%, #065f46 100%);
    --theme-grad-warning: linear-gradient(135deg, #d97706 0%, #92400e 100%);
    --theme-grad-danger: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%);
    --theme-grad-info: linear-gradient(135deg, #0ea5e9 0%, #0369a1 100%);
    --theme-grad-purple: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
    --theme-grad-light: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    --theme-grad-soft: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);

    --theme-radius: 8px;
    --theme-radius-lg: 16px;
    --theme-input-height: 33px;

    --theme-shadow-sm: 0 8px 20px rgba(15, 23, 42, 0.06);
    --theme-shadow-md: 0 12px 30px rgba(15, 23, 42, 0.10);
    --theme-shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.14);

    --theme-text-dark: #0f172a;
    --theme-text-muted: #64748b;
    --theme-border: #dbe3ee;
    --theme-border-soft: #e8eef5;

    --theme-topbar-height: 48px;
    --theme-sidebar-expanded-width: var(--sidebar-width, 240px);
    --theme-sidebar-collapsed-width: 4.6rem;
    --theme-live-sidebar-width: var(--sidebar-width, 240px);
    --theme-live-sidebar-collapsed-width: 4.6rem;
    --theme-live-header-height: 48px;
    --theme-colvis-z: 999999;
}

/* =========================================================
   GLOBAL LAYER SAFETY
========================================================= */
html,
body,
.wrapper,
.content-wrapper,
.content,
.content .container-fluid,
.card,
.card-body,
.card-header,
.dataTables_wrapper,
.dataTables_wrapper .row,
.dataTables_wrapper .col-12,
.dataTables_wrapper .dt-buttons,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_paginate,
.dataTables_wrapper .dataTables_info {
    overflow: visible !important;
}

.content-wrapper,
.content,
.content .container-fluid,
.card,
.card-body,
.card-header {
    position: relative;
    z-index: auto !important;
}

/* =========================================================
   FIXED TOP NAVBAR
========================================================= */
.main-header,
.main-header.navbar {
    background: var(--theme-grad-primary) !important;
    color: #fff !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14) !important;
    overflow: visible !important;
    min-height: var(--theme-live-header-height) !important;
    height: var(--theme-live-header-height) !important;
    max-height: var(--theme-live-header-height) !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    z-index: 1065 !important;
    display: flex !important;
    align-items: stretch !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

body.layout-fixed.layout-navbar-fixed .main-header,
body.layout-navbar-fixed .main-header {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: var(--theme-live-sidebar-width, var(--theme-sidebar-expanded-width)) !important;
    width: calc(100% - var(--theme-live-sidebar-width, var(--theme-sidebar-expanded-width))) !important;
    margin-left: 0 !important;
}

body.layout-fixed.layout-navbar-fixed.sidebar-collapse .main-header,
body.layout-navbar-fixed.sidebar-collapse .main-header,
body.layout-fixed.layout-navbar-fixed.sidebar-mini.sidebar-collapse .main-header,
body.layout-navbar-fixed.sidebar-mini.sidebar-collapse .main-header {
    left: var(--theme-live-sidebar-collapsed-width, var(--theme-sidebar-collapsed-width)) !important;
    width: calc(100% - var(--theme-live-sidebar-collapsed-width, var(--theme-sidebar-collapsed-width))) !important;
    margin-left: 0 !important;
}

.main-header .container-fluid {
    height: 100% !important;
    min-height: var(--theme-live-header-height) !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
    position: relative;
    z-index: 1066;
}

.main-header .navbar-nav {
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    flex-direction: row !important;
    overflow: visible !important;
}

.main-header .nav-item,
.main-header .dropdown {
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    overflow: visible !important;
}

.main-header .nav-link,
.main-header .navbar-brand,
.main-header .dropdown-toggle {
    color: #fff !important;
}

.main-header .nav-link {
    min-height: var(--theme-live-header-height) !important;
    height: var(--theme-live-header-height) !important;
    display: inline-flex !important;
    align-items: center !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.main-header .dropdown-menu {
    position: absolute !important;
    z-index: 999999 !important;
    border-radius: 14px;
    border: 1px solid #eef2f7;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.main-header .dropdown-item:hover {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

@media (max-width: 991.98px) {
    body.layout-fixed.layout-navbar-fixed .main-header,
    body.layout-navbar-fixed .main-header {
        left: 0 !important;
        width: 100% !important;
        margin-left: 0 !important;
    }
}

/* =========================================================
   CONTENT OFFSET FOR FIXED NAVBAR
========================================================= */
body.layout-fixed.layout-navbar-fixed .content-wrapper,
body.layout-fixed.layout-navbar-fixed .main-footer,
body.layout-navbar-fixed .content-wrapper,
body.layout-navbar-fixed .main-footer {
    margin-top: var(--theme-live-header-height) !important;
}

body.layout-fixed.layout-navbar-fixed .content-header,
body.layout-navbar-fixed .content-header {
    padding-top: 12px !important;
}

/* Sidebar stays in place */
body.layout-fixed.layout-navbar-fixed .main-sidebar,
body.layout-navbar-fixed .main-sidebar {
    margin-top: 0 !important;
}

/* Prevent page horizontal overflow */
html,
body,
.wrapper,
.content-wrapper {
    overflow-x: hidden !important;
}

/* =========================================================
   SIDEBAR BRAND USER BLOCK
========================================================= */
.brand-link {
    min-height: 45px !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    overflow: hidden;
}

.brand-image-wrap {
    width: 34px;
    min-width: 34px;
    height: 34px;
}

.brand-image-xs {
    width: 34px !important;
    height: 34px !important;
    object-fit: cover;
}

.brand-text-wrap {
    min-width: 0;
}

.brand-text-wrap .brand-text {
    font-size: 16px;
    color: #ffffff !important;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-text-wrap small {
    font-size: 11px;
    display: block;
}

/* =========================================================
   CARDS
========================================================= */
.card {
    background: var(--theme-grad-light);
    border-radius: 14px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: var(--theme-shadow-sm);
}

.card-header {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    border-bottom: 1px solid var(--theme-border-soft) !important;
}

.card-title,
.card h3,
.card h4,
.card h5,
.card h6 {
    color: var(--theme-text-dark);
    font-weight: 700;
}

/* =========================================================
   STATS CARDS
========================================================= */
.mini-stat-card {
    color: #fff;
    border: 0 !important;
    overflow: hidden;
    position: relative;
    box-shadow: var(--theme-shadow-md) !important;
}

.mini-stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.03) 100%);
    pointer-events: none;
}

.row.g-2.mb-2 .col-xl-3:nth-child(1) .mini-stat-card {
    background: var(--theme-grad-info) !important;
}

.row.g-2.mb-2 .col-xl-3:nth-child(2) .mini-stat-card {
    background: var(--theme-grad-success) !important;
}

.row.g-2.mb-2 .col-xl-3:nth-child(3) .mini-stat-card {
    background: var(--theme-grad-warning) !important;
}

.row.g-2.mb-2 .col-xl-3:nth-child(4) .mini-stat-card {
    background: var(--theme-grad-purple) !important;
}

.mini-stat-card .text-muted,
.mini-stat-card .small,
.mini-stat-card h3,
.mini-stat-card i,
.mini-stat-card .mini-stat-icon {
    color: #fff !important;
    position: relative;
    z-index: 1;
}

.mini-stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0.10) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}

/* =========================================================
   INPUTS
========================================================= */
.form-control,
.form-select,
select {
    height: var(--theme-input-height) !important;
    min-height: var(--theme-input-height) !important;
    border-radius: var(--theme-radius) !important;
    padding: 0 10px !important;
    font-size: 13px;
    border: 1px solid var(--theme-border) !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
}

.form-select:not([multiple]):not([size]),
select:not([multiple]):not([size]) {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    padding-right: 2.25rem !important;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 7.5L10 12L14.5 7.5' stroke='%23111827' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    background-repeat: no-repeat, repeat !important;
    background-position: right 0.75rem center, 0 0 !important;
    background-size: 14px 14px, 100% 100% !important;
}

textarea.form-control {
    height: auto !important;
    min-height: 80px !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

.form-control:focus,
.form-select:focus,
select:focus {
    background: #111827 !important;
    color: #fff !important;
    box-shadow: none !important;
    border-color: #111827 !important;
}

.form-select:not([multiple]):not([size]):focus,
select:not([multiple]):not([size]):focus {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 7.5L10 12L14.5 7.5' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
        linear-gradient(180deg, #111827 0%, #111827 100%) !important;
}

body :is(.modal, .premium-unit-lightbox, #theme-modal-select-arrow-scope) .form-select:not([multiple]):not([size]),
body :is(.modal, .premium-unit-lightbox, #theme-modal-select-arrow-scope) select:not([multiple]):not([size]) {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    padding-right: 2.25rem !important;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 7.5L10 12L14.5 7.5' stroke='%23111827' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    background-repeat: no-repeat, repeat !important;
    background-position: right 0.75rem center, 0 0 !important;
    background-size: 14px 14px, 100% 100% !important;
}

body :is(.modal, .premium-unit-lightbox, #theme-modal-select-arrow-scope) .form-select:not([multiple]):not([size]):focus,
body :is(.modal, .premium-unit-lightbox, #theme-modal-select-arrow-scope) select:not([multiple]):not([size]):focus {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5.5 7.5L10 12L14.5 7.5' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
        linear-gradient(180deg, #111827 0%, #111827 100%) !important;
}

/* =========================================================
   PLUS BUTTON GROUP FIX
========================================================= */
.premium-group-field {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
}

.premium-group-field .form-select,
.premium-group-field .form-control {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-right: 0 !important;
}

.premium-plus-btn {
    width: var(--theme-input-height);
    min-width: var(--theme-input-height);
    height: var(--theme-input-height);
    border-radius: 0 var(--theme-radius) var(--theme-radius) 0;
    border: 1px solid var(--theme-border);
    border-left: 1px solid #cfd8e3;
    background: var(--theme-grad-primary);
    color: #fff;
    font-weight: 700;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    vertical-align: middle;
}

/* =========================================================
   LIGHTBOX
========================================================= */
.premium-lightbox {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 999990;
}

.premium-lightbox.show {
    display: block;
}

.premium-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.68);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1;
}

.premium-lightbox-dialog-wrap {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.premium-lightbox-dialog {
    width: 650px;
    max-width: 100%;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--theme-shadow-lg);
    animation: fadeInUp 0.25s ease;
}

.premium-lightbox-header {
    padding: 14px 16px;
    background: var(--ts-modal-header-bg, var(--ts-navbar-bg, var(--theme-grad-primary)));
    color: var(--ts-modal-header-text, #fff);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.premium-lightbox-title {
    margin: 0;
    font-size: 16px;
    color: #fff;
}

.premium-lightbox-text {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.85;
}

.premium-lightbox-close {
    border: 0;
    background: rgba(255,255,255,0.14);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.premium-lightbox-body {
    padding: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.premium-form-block {
    border: 1px solid var(--theme-border-soft);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    padding: 14px;
}

.premium-form-label {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
    display: inline-block;
}

.premium-lightbox-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 12px;
}

.premium-lightbox-note {
    margin: 0;
    font-size: 12px;
    color: var(--theme-text-muted);
}

.premium-btn {
    height: 33px;
    padding: 0 14px;
    border-radius: 10px;
    border: 0;
    font-size: 13px;
    font-weight: 600;
}

.premium-btn-dark {
    background: var(--theme-grad-primary);
    color: #fff;
}

.premium-btn-light {
    background: linear-gradient(180deg, #e5e7eb 0%, #dbe2ea 100%);
    color: #111827;
}
/* =========================================================
   MINI POPUP
========================================================= */
.premium-mini-popup {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 999995;
}

.premium-mini-popup.show {
    display: block;
}

.premium-mini-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.42);
    z-index: 1;
}

.premium-mini-popup-dialog-wrap {
    position: relative;
    z-index: 3;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.premium-mini-popup-dialog {
    width: 380px;
    max-width: 100%;
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--theme-shadow-lg);
}

/* =========================================================
   DATATABLE FINAL FIX
========================================================= */
.theme-datatable-wrapper {
    width: 100%;
    position: relative;
}

/* .table-responsive must keep horizontal scrolling for wide tables.
   We deliberately do NOT force overflow:visible here — that was the
   long-standing bug that made wide DataTables spill out of the card
   instead of scrolling. */
.table-responsive {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
}

/* Tables fill the wrapper at minimum, but are allowed to grow wider
   than the wrapper when their columns need more room (the
   .table-responsive parent then provides horizontal scroll). The
   element-qualified selectors beat Bootstrap's `.w-100` utility. */
table.dataTable,
table.theme-datatable {
    min-width: 100% !important;
    width: auto !important;
}

.theme-datatable th,
.theme-datatable td {
    vertical-align: middle !important;
}

.theme-datatable th.dt-checkbox-col,
.theme-datatable td.dt-checkbox-col {
    width: 42px !important;
    text-align: center !important;
}

.theme-datatable th.dt-action-col,
.theme-datatable td.dt-action-col {
    text-align: center !important;
    position: relative !important;
}

.theme-datatable .dt-action-col .dropdown-menu {
    z-index: 999999 !important;
}

/* =========================================================
   CUSTOM COLUMN VISIBILITY MENU (FINAL FIX)
========================================================= */
.theme-custom-colvis-menu {
    position: fixed;
    min-width: 240px;
    max-width: 320px;
    border: 1px solid #e5ebf2;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 20px 44px rgba(15, 23, 42, 0.20);
    padding: 8px;
    z-index: 999999;
}

.theme-custom-colvis-item {
    width: 100%;
    border: 0;
    background: transparent;
    color: #334155;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    padding: 10px;
    cursor: pointer;
}

.theme-custom-colvis-item:hover {
    background: #f1f5f9;
}

.dt-colvis-check {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dt-colvis-check.is-active {
    background: #16a34a;
    color: #fff;
}

.dt-colvis-check.is-inactive {
    background: #dc2626;
    color: #fff;
}

/* =========================================================
   ULTRA SMOOTH SIDEBAR + NAVBAR ANIMATION
========================================================= */
.main-header {
    transition: left 0.25s ease, width 0.25s ease !important;
}

.main-sidebar {
    transition: width 0.25s ease !important;
}

.content-wrapper {
    transition: margin-left 0.25s ease !important;
}

/* Smooth icon animation */
.navbar-nav .nav-link i {
    transition: transform 0.2s ease;
}

.sidebar-collapse .navbar-nav .nav-link i {
    transform: scale(0.9);
}

/* =========================================================
   RESPONSIVE FIXES
========================================================= */
@media (max-width: 991.98px) {
    .main-header {
        left: 0 !important;
        width: 100% !important;
    }
}

@media (max-width: 575.98px) {
    .theme-custom-colvis-menu {
        max-width: calc(100vw - 20px);
    }
}
/* =========================================================
   MINI POPUP
========================================================= */
.premium-mini-popup {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 999995;
}

.premium-mini-popup.show {
    display: block;
}

.premium-mini-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.42);
    z-index: 1;
}

.premium-mini-popup-dialog-wrap {
    position: relative;
    z-index: 3;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.premium-mini-popup-dialog {
    width: 380px;
    max-width: 100%;
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--theme-shadow-lg);
}

.premium-mini-popup-title {
    margin: 0;
    font-size: 16px;
    color: var(--theme-text-dark);
}

.premium-mini-popup-text {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--theme-text-muted);
}

.premium-mini-popup-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

/* =========================================================
   DATATABLE FINAL FIX (DUPLICATE — kept tightened only)
========================================================= */
.theme-datatable th.dt-checkbox-col,
.theme-datatable td.dt-checkbox-col {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    text-align: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.theme-datatable th.dt-checkbox-col input,
.theme-datatable td.dt-checkbox-col input,
.theme-datatable th.dt-checkbox-col #checkAllRows,
.theme-datatable td.dt-checkbox-col .theme-row-check {
    display: inline-block;
    margin: 0 auto !important;
    vertical-align: middle;
}

.theme-datatable th.dt-action-col,
.theme-datatable td.dt-action-col {
    text-align: center !important;
    white-space: nowrap !important;
    position: relative !important;
}

.theme-datatable .dt-action-col .dropdown {
    position: relative !important;
    display: inline-block !important;
}

.theme-datatable .dt-action-col .dropdown-menu {
    top: calc(100% + 4px) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    min-width: 130px;
    z-index: 999999 !important;
    position: absolute !important;
}

.theme-datatable td .dropdown-menu,
.theme-datatable .dropdown-menu,
.show-on-top {
    z-index: 999999 !important;
}

.dataTables_wrapper,
.dataTables_wrapper .row,
.dataTables_wrapper .col-12,
.dataTables_wrapper .dt-buttons,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length,
.card,
.card-body,
.card-header {
    overflow: visible !important;
}

.dataTables_wrapper .dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    position: relative !important;
    /* Keep the toolbar low so the AdminLTE sidebar (z-index ~1037)
       can correctly slide over the buttons on mobile.
       The column-visibility popup (.dt-button-collection) is portaled
       to <body> with its own z-index, so it still appears on top. */
    z-index: 1 !important;
}

/* When the mobile sidebar is open, force any DataTable controls
   to stay underneath it, no matter what local z-index a vendor
   stylesheet might apply. */
body.sidebar-open .dataTables_wrapper,
body.sidebar-open .dataTables_wrapper .dt-buttons,
body.sidebar-open .dataTables_wrapper .dataTables_length,
body.sidebar-open .dataTables_wrapper .dataTables_filter,
body.sidebar-open .dataTables_wrapper .dataTables_info,
body.sidebar-open .dataTables_wrapper .dataTables_paginate,
body.sidebar-open .theme-dt-toolbar,
body.sidebar-open .theme-dt-toolbar .dt-buttons {
    z-index: 0 !important;
}

/* AdminLTE sidebar should always render above the page content
   (and above any DataTable toolbar), on every screen size. */
body .main-sidebar {
    z-index: 1040 !important;
}

.dataTables_wrapper .dt-buttons .btn {
    border-radius: 999px !important;
    border: 1px solid #dbe2ea !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
    color: #334155 !important;
    font-weight: 600;
    min-height: 34px;
    padding: 0 14px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    transition: background-color 0.22s ease, color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease !important;
}

.dataTables_wrapper .dt-buttons .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.10);
}

.dataTables_wrapper .dt-buttons .buttons-colvis,
.dataTables_wrapper .dt-buttons .btn-danger,
.dataTables_wrapper .dt-buttons .theme-custom-colvis-toggle {
    background: var(--theme-grad-danger) !important;
    border: none !important;
    color: #fff !important;
}

/* =========================================================
   CUSTOM COLUMN VISIBILITY MENU
========================================================= */
.theme-custom-colvis-menu {
    position: fixed;
    min-width: 240px;
    max-width: 320px;
    border: 1px solid #e5ebf2;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 20px 44px rgba(15, 23, 42, 0.20);
    padding: 8px;
    z-index: 999999;
    animation: premiumDropdownIn 0.18s ease;
}

.theme-custom-colvis-item {
    width: 100%;
    border: 0;
    background: transparent;
    color: #334155;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.theme-custom-colvis-item:hover {
    background: #f1f5f9;
    transform: translateX(2px);
}

.theme-custom-colvis-label {
    font-size: 13px;
    line-height: 1.2;
}

.dt-colvis-check {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dt-colvis-check.is-active {
    background: #16a34a;
    color: #fff;
}

.dt-colvis-check.is-inactive {
    background: #dc2626;
    color: #fff;
}

/* =========================================================
   ULTRA SMOOTH SIDEBAR + NAVBAR ANIMATION
========================================================= */
body,
.wrapper,
.main-sidebar,
.main-header,
.content-wrapper,
.main-footer,
.brand-link,
.nav-sidebar .nav-link,
.nav-treeview,
.nav-treeview .nav-link,
.navbar-nav .nav-link {
    transition:
        left 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        width 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        margin-left 0.26s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.22s ease,
        transform 0.22s ease,
        box-shadow 0.22s ease,
        background-color 0.22s ease,
        color 0.22s ease,
        border-color 0.22s ease !important;
}

.main-sidebar {
    will-change: width, transform;
}

.main-header {
    will-change: left, width;
}

.content-wrapper,
.main-footer {
    will-change: margin-left;
}

.nav-sidebar .nav-link:hover {
    transform: translateX(2px);
}

.nav-sidebar .nav-link.active {
    box-shadow: 0 8px 18px rgba(13, 110, 253, 0.18);
}

.brand-link:hover .brand-image-xs {
    transform: scale(1.04);
}

.main-header .nav-link:hover {
    transform: translateY(-1px);
}

.main-header .navbar-nav .nav-link i {
    transition: transform 0.2s ease;
}

.main-header .navbar-nav .nav-link:hover i {
    transform: scale(1.08);
}

/* =========================================================
   RESPONSIVE APP SHELL FIT FIX
   Keeps content, fixed header and sidebar in one layout grid.
   Content must never slide underneath the sidebar on narrow views.
========================================================= */
:root {
    --theme-mobile-sidebar-width: clamp(218px, 34vw, var(--theme-sidebar-expanded-width, 240px));
}

body.layout-fixed .main-sidebar,
body.layout-navbar-fixed .main-sidebar {
    width: var(--theme-live-sidebar-width, var(--theme-sidebar-expanded-width)) !important;
    max-width: calc(100vw - 16px);
}

@media (min-width: 992px) {
    body.layout-fixed .content-wrapper,
    body.layout-fixed .main-footer,
    body.layout-navbar-fixed .content-wrapper,
    body.layout-navbar-fixed .main-footer {
        margin-left: var(--theme-live-sidebar-width, var(--theme-sidebar-expanded-width)) !important;
        width: auto !important;
        min-width: 0;
    }

    body.layout-fixed.sidebar-collapse .content-wrapper,
    body.layout-fixed.sidebar-collapse .main-footer,
    body.layout-navbar-fixed.sidebar-collapse .content-wrapper,
    body.layout-navbar-fixed.sidebar-collapse .main-footer {
        margin-left: var(--theme-live-sidebar-collapsed-width, var(--theme-sidebar-collapsed-width)) !important;
    }
}

@media (max-width: 991.98px) {
    body.layout-fixed .main-sidebar,
    body.layout-navbar-fixed .main-sidebar {
        width: var(--theme-mobile-sidebar-width) !important;
        max-width: calc(100vw - 16px);
        transform: translateX(-100%);
    }

    body.sidebar-open.layout-fixed .main-sidebar,
    body.sidebar-open.layout-navbar-fixed .main-sidebar {
        transform: translateX(0);
    }

    body.layout-fixed .content-wrapper,
    body.layout-fixed .main-footer,
    body.layout-navbar-fixed .content-wrapper,
    body.layout-navbar-fixed .main-footer {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0;
    }

    body.sidebar-open.layout-fixed .content-wrapper,
    body.sidebar-open.layout-fixed .main-footer,
    body.sidebar-open.layout-navbar-fixed .content-wrapper,
    body.sidebar-open.layout-navbar-fixed .main-footer {
        margin-left: var(--theme-mobile-sidebar-width) !important;
        width: calc(100% - var(--theme-mobile-sidebar-width)) !important;
    }

    body.layout-fixed.layout-navbar-fixed .main-header,
    body.layout-navbar-fixed .main-header {
        left: 0 !important;
        width: 100% !important;
    }

    body.sidebar-open.layout-fixed.layout-navbar-fixed .main-header,
    body.sidebar-open.layout-navbar-fixed .main-header {
        left: var(--theme-mobile-sidebar-width) !important;
        width: calc(100% - var(--theme-mobile-sidebar-width)) !important;
    }

    .content-wrapper .content,
    .content-wrapper .content .container-fluid {
        min-width: 0;
    }
}

@media (max-width: 575.98px) {
    :root {
        --theme-mobile-sidebar-width: min(82vw, 248px);
    }

    body.sidebar-open.layout-fixed .content-wrapper,
    body.sidebar-open.layout-fixed .main-footer,
    body.sidebar-open.layout-navbar-fixed .content-wrapper,
    body.sidebar-open.layout-navbar-fixed .main-footer,
    body.sidebar-open.layout-fixed.layout-navbar-fixed .main-header,
    body.sidebar-open.layout-navbar-fixed .main-header {
        min-width: 0;
    }
}

/* =========================================================
   ALERT DEMO SECTION
========================================================= */
.alert-demo-grid .btn {
    min-height: 36px;
}

/* =========================================================
   TRACKING / DIAGRAM PREVIEW
========================================================= */
.premium-demo-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}

.premium-demo-section-title .icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-grad-primary);
    color: #fff;
    box-shadow: var(--theme-shadow-sm);
    flex: 0 0 34px;
}

.premium-demo-subtitle {
    margin: 0;
    color: var(--theme-text-muted);
    font-size: 12px;
}

.tracking-preview-wrap {
    display: grid;
    grid-template-columns: 1.45fr 0.95fr;
    gap: 12px;
}

.tracking-map-card,
.diagram-canvas-card,
.tracking-info-card,
.diagram-info-card,
.tracking-mini-card {
    border-radius: 18px;
    border: 1px solid #e7ecf2;
    background: var(--theme-grad-soft);
    box-shadow: var(--theme-shadow-sm);
}

.tracking-map-card {
    position: relative;
    min-height: 420px;
    overflow: hidden;
}

.tracking-map-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.10) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.10) 1px, transparent 1px);
    background-size: 38px 38px;
    opacity: 0.7;
}

.tracking-map-shape {
    position: absolute;
    border-radius: 999px;
    filter: blur(20px);
    opacity: 0.65;
}

.tracking-map-shape.one {
    width: 140px;
    height: 140px;
    left: 8%;
    top: 9%;
    background: rgba(59, 130, 246, 0.18);
}

.tracking-map-shape.two {
    width: 160px;
    height: 160px;
    right: 12%;
    top: 10%;
    background: rgba(16, 185, 129, 0.16);
}

.tracking-map-shape.three {
    width: 120px;
    height: 120px;
    left: 20%;
    bottom: 10%;
    background: rgba(245, 158, 11, 0.16);
}

.tracking-svg {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 420px;
    display: block;
}

.tracking-floating-card {
    position: absolute;
    z-index: 3;
    left: 18px;
    top: 18px;
    width: 295px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    background: linear-gradient(180deg, rgba(255,255,255,0.94) 0%, rgba(255,255,255,0.86) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    padding: 16px;
}

.tracking-floating-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.tracking-floating-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--theme-grad-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tracking-label-sm,
.tracking-mini-label {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.tracking-title-sm,
.tracking-route-title,
.tracking-mini-value,
.tracking-stat-value {
    color: #111827;
    font-weight: 700;
}

.tracking-route-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tracking-route-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
    padding-bottom: 14px;
}

.tracking-route-list li:last-child {
    padding-bottom: 0;
}

.tracking-route-list li:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 18px;
    width: 2px;
    height: calc(100% - 8px);
    border-left: 2px dashed #cbd5e1;
}

.tracking-dot {
    width: 10px;
    height: 10px;
    margin-top: 4px;
    border-radius: 50%;
    flex: 0 0 10px;
}

.tracking-dot.start {
    background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
}

.tracking-dot.end {
    background: #111827;
}

.tracking-route-text,
.tracking-meta-item span,
.diagram-info-item {
    color: #64748b;
}

.tracking-side-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tracking-info-card,
.diagram-info-card,
.tracking-mini-card {
    padding: 16px;
}

.tracking-driver-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.tracking-driver-avatar {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #eceff4 0%, #cfd8e3 100%);
    color: #111827;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.tracking-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.tracking-stat-box {
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 14px;
    border: 1px solid #edf2f7;
}

.tracking-progress-card {
    border: 1px solid #e9eef4;
    border-radius: 16px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.tracking-progress-bar {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(180deg, #edf2f7 0%, #e5ebf2 100%);
    overflow: hidden;
}

.tracking-progress-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--theme-grad-danger);
}

.tracking-meta-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.tracking-meta-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
}

.tracking-meta-item strong {
    color: #111827;
    text-align: right;
}

.diagram-preview-wrap {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 12px;
}

.diagram-canvas-scroll {
    overflow-x: auto;
    padding: 12px;
}

.diagram-svg {
    width: 100%;
    min-width: 860px;
    height: auto;
    display: block;
}

.diagram-info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.diagram-info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: 14px;
    background: linear-gradient(180deg, #f8fafc 0%, #f3f6fa 100%);
    border: 1px solid #edf2f7;
    padding: 12px 14px;
    font-size: 13px;
}

.diagram-info-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #8b0000;
    margin-top: 4px;
    flex: 0 0 10px;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 1199.98px) {
    .tracking-preview-wrap,
    .diagram-preview-wrap {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 991.98px) {
    .tracking-floating-card {
        position: relative;
        left: auto;
        top: auto;
        width: calc(100% - 24px);
        margin: 12px;
    }

    .tracking-svg {
        height: 360px;
    }
}

@media (max-width: 767.98px) {
    .premium-lightbox-dialog {
        width: 100%;
    }

    .premium-lightbox-header,
    .premium-lightbox-body,
    .premium-mini-popup-dialog {
        padding: 14px;
    }

    .premium-lightbox-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .premium-lightbox-footer .d-flex {
        width: 100%;
    }

    .premium-lightbox-footer .d-flex .btn,
    .premium-btn {
        flex: 1 1 auto;
    }

    .tracking-stat-grid {
        grid-template-columns: 1fr;
    }

    .tracking-meta-item {
        flex-direction: column;
        gap: 4px;
    }

    .tracking-meta-item strong {
        text-align: left;
    }
}

@media (max-width: 575.98px) {
    .main-header .dropdown-menu {
        min-width: 220px;
    }

    .tracking-svg {
        height: 300px;
    }

    .tracking-mini-card,
    .tracking-info-card,
    .diagram-info-card,
    .tracking-map-card,
    .diagram-canvas-card {
        border-radius: 16px;
    }

    .theme-custom-colvis-menu {
        min-width: 220px;
        max-width: calc(100vw - 24px);
    }
}

@keyframes fadeInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes premiumDropdownIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
