/*
 * Admin panel styles — white & purple theme
 * admin.css is loaded after styles.css so :root overrides take effect on admin pages only.
 */

/* ── Purple accent: override Bootstrap primary ───────────────────── */
:root {
    --bs-primary:          #8B5CF6;
    --bs-primary-rgb:      139, 92, 246;
    --bs-link-color:       #8B5CF6;
    --bs-link-hover-color: #7C3AED;

    --ap:          #8B5CF6;
    --ap-mid:      #A78BFA;
    --ap-dark:     #7C3AED;
    --ap-light:    #EDE9FE;
    --ap-xlight:   #F5F3FF;

    --sidebar-w:           260px;
    --sidebar-collapsed-w: 64px;
    --topbar-h:            64px;

    --admin-bg:      #F1F5F9;
    --admin-surface: #FFFFFF;
    --admin-text:    #1E293B;
    --admin-muted:   #64748B;
    --admin-border:  #E2E8F0;
}

/* ── Body ─────────────────────────────────────────────────────────── */
.admin-body {
    background: var(--admin-bg);
    color: var(--admin-text);
    font-family: 'Montserrat', sans-serif;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--ap-xlight);
    border-right: 1px solid #E2D9FB;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.22s ease, transform 0.25s ease;
    overflow-x: hidden;
}

/* ── Collapsed sidebar (desktop icon-only mode) ───────────────────── */
@media (min-width: 992px) {
    .admin-sidebar.collapsed {
        width: var(--sidebar-collapsed-w);
    }

    .admin-sidebar.collapsed .sidebar-brand span,
    .admin-sidebar.collapsed .sidebar-section-label,
    .admin-sidebar.collapsed .sidebar-link span {
        display: none;
    }

    .admin-sidebar.collapsed .sidebar-header {
        padding: 1.25rem 0;
        justify-content: center;
        display: flex;
    }

    .admin-sidebar.collapsed .sidebar-brand {
        justify-content: center;
    }

    .admin-sidebar.collapsed .sidebar-link {
        justify-content: center;
        padding: 0.75rem 0;
        border-left-width: 0;
        border-bottom: none;
    }

    .admin-sidebar.collapsed .sidebar-link.active,
    .admin-sidebar.collapsed .sidebar-link:hover {
        border-left-width: 0;
        border-radius: 8px;
        margin: 0 8px;
    }

    .admin-sidebar.collapsed .sidebar-link i {
        width: auto;
        font-size: 1.05rem;
        margin: 0;
    }

    .admin-sidebar.collapsed .sidebar-footer {
        padding: 0.75rem 0;
    }

    .admin-main-wrapper.sidebar-collapsed {
        margin-left: var(--sidebar-collapsed-w);
    }
}

.admin-main-wrapper {
    transition: margin-left 0.22s ease;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--admin-border);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--ap);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.25;
}

.sidebar-brand i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.sidebar-brand:hover {
    color: var(--ap-dark);
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-section-label {
    padding: 0.75rem 1.25rem 0.3rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--admin-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: var(--admin-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.sidebar-link i {
    width: 1.25em;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: var(--ap-light);
    color: var(--ap);
    border-left-color: var(--ap);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--ap-light);
    color: var(--ap);
    border-left-color: var(--ap);
    font-weight: 600;
}

.sidebar-footer {
    padding: 0.75rem 0;
    border-top: 1px solid var(--admin-border);
    flex-shrink: 0;
}

/* ── Sidebar overlay (mobile tap-to-close) ────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
}

.sidebar-overlay.visible {
    display: block;
}

/* ── Main wrapper ─────────────────────────────────────────────────── */
.admin-main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.operator-mode .admin-main-wrapper {
    margin-left: 0;
}

/* ── Top bar ──────────────────────────────────────────────────────── */
.admin-topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    background: var(--admin-surface);
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 900;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    padding: 0.45rem 0.55rem;
    cursor: pointer;
    color: var(--admin-muted);
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: var(--ap-light);
    color: var(--ap);
}

.sidebar-toggle-btn i {
    font-size: 1.15rem;
}

.topbar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--ap);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
}

.topbar-brand-link:hover {
    color: var(--ap-dark);
    text-decoration: none;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ── User dropdown button ─────────────────────────────────────────── */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: none;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    padding: 0.4rem 0.85rem 0.4rem 0.6rem;
    cursor: pointer;
    color: var(--admin-text);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.user-menu-btn:hover,
.user-menu-btn.show {
    background: var(--ap-light);
    border-color: var(--ap);
    color: var(--ap);
}

.user-avatar-icon {
    font-size: 1.45rem;
    color: var(--ap);
    flex-shrink: 0;
}

.user-display-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-menu {
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    padding: 0.4rem;
    min-width: 180px;
}

.user-dropdown-menu .dropdown-item {
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    color: var(--admin-text);
    transition: background 0.12s, color 0.12s;
}

.user-dropdown-menu .dropdown-item:hover {
    background: var(--ap-light);
    color: var(--ap);
}

.user-dropdown-menu .dropdown-item.text-danger:hover {
    background: #FEE2E2;
    color: #DC2626 !important;
}

.user-dropdown-menu .dropdown-divider {
    margin: 0.3rem 0;
    border-color: var(--admin-border);
}

/* ── Flash notification (top-center) ──────────────────────────────── */
#adminNotification {
    position: fixed;
    top: calc(var(--topbar-h) + 1rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    min-width: 280px;
    max-width: 420px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
}

#adminNotification.visible {
    opacity: 1;
    pointer-events: auto;
}

#adminNotification .message {
    padding: 14px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 10px;
}

#adminNotification .message.success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #6EE7B7;
}

#adminNotification .message.error {
    background-color: #FEE2E2;
    color: #7F1D1D;
    border: 1px solid #FCA5A5;
}

#adminNotification .message.warning {
    background-color: #FEF3C7;
    color: #78350F;
    border: 1px solid #FCD34D;
}

/* ── Content area ─────────────────────────────────────────────────── */
.admin-content {
    flex: 1;
    padding: 2rem;
}

/* ── Page title ───────────────────────────────────────────────────── */
.admin-page-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    color: var(--admin-text);
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--admin-border);
    border-radius: 10px;
}

.card-header-dark {
    background-color: #212529;
    color: #fff;
    border-radius: 9px 9px 0 0 !important;
}

.card-header-purple {
    background-color: var(--ap) !important;
    color: #fff !important;
    border-radius: 9px 9px 0 0 !important;
}

.card-header-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
}

/* ── Fix Bootstrap 5 btn-primary / btn-outline-primary to use our purple ── */
.btn-primary {
    --bs-btn-color:                 #fff;
    --bs-btn-bg:                    var(--ap);
    --bs-btn-border-color:          var(--ap);
    --bs-btn-hover-color:           #fff;
    --bs-btn-hover-bg:              var(--ap-dark);
    --bs-btn-hover-border-color:    var(--ap-dark);
    --bs-btn-active-color:          #fff;
    --bs-btn-active-bg:             var(--ap-dark);
    --bs-btn-active-border-color:   var(--ap-dark);
    --bs-btn-disabled-color:        #fff;
    --bs-btn-disabled-bg:           var(--ap);
    --bs-btn-disabled-border-color: var(--ap);
    --bs-btn-focus-shadow-rgb:      124, 58, 237;
}

.btn-outline-primary {
    --bs-btn-color:               var(--ap);
    --bs-btn-border-color:        var(--ap);
    --bs-btn-hover-bg:            var(--ap);
    --bs-btn-hover-border-color:  var(--ap);
    --bs-btn-active-bg:           var(--ap);
    --bs-btn-active-border-color: var(--ap);
    --bs-btn-focus-shadow-rgb:    124, 58, 237;
}

/* ── Table header (dark for contrast, legacy) ─────────────────────── */
.table-dark-header {
    background-color: #212529;
}

/* ── Purple table header (new) ─────────────────────────────────────── */
.table-purple-header {
    background-color: var(--ap);
}

.table-purple-header th {
    color: #fff;
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: none !important;
    padding: 0.9rem 0.75rem;
    white-space: nowrap;
}

.table thead.table-dark th a,
.table thead th a,
.table thead.table-purple-header th a {
    color: #fff !important;
    text-decoration: none;
}

.table thead th a:hover,
.table thead.table-purple-header th a:hover {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* ── Sticky actions column ─────────────────────────────────────────── */
.table-actions-sticky {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    border-left: 2px solid var(--admin-border) !important;
}

.table-purple-header .table-actions-sticky {
    background: var(--ap);
    border-left-color: rgba(255, 255, 255, 0.25) !important;
}

.table-hover tbody tr:hover .table-actions-sticky {
    background: var(--ap-xlight);
}

.table-actions-sticky:has(.show) {
    z-index: 20;
}

/* ── Actions dropdown button ───────────────────────────────────────── */
.btn-actions-drop {
    background: transparent;
    border: 1.5px solid var(--ap);
    color: var(--ap);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    padding: 0.35rem 0.8rem;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
}

.btn-actions-drop:hover,
.btn-actions-drop:focus,
.btn-actions-drop.show {
    background: var(--ap);
    color: #fff;
    border-color: var(--ap);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.28);
}

.actions-menu {
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
    padding: 0.4rem;
    min-width: 175px;
}

.actions-menu .dropdown-item {
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    color: var(--admin-text);
    display: flex;
    align-items: center;
    transition: background 0.12s, color 0.12s;
}

.actions-menu .dropdown-item i {
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.actions-menu .dropdown-item:hover {
    background: var(--ap-light);
    color: var(--ap);
}

.actions-menu .dropdown-item.text-danger {
    color: #DC2626;
}

.actions-menu .dropdown-item.text-danger:hover {
    background: #FEE2E2;
    color: #DC2626 !important;
}

.actions-menu .dropdown-divider {
    margin: 0.3rem 0;
    border-color: var(--admin-border);
}

/* ── Table row refinements ─────────────────────────────────────────── */
.table tbody td {
    vertical-align: middle;
    border-color: var(--admin-border);
}

.table-hover tbody tr:hover {
    background-color: var(--ap-xlight);
}

/* ── Constrain wide columns so actions remain reachable ────────────── */
.col-client {
    min-width: 160px;
    max-width: 200px;
}

.col-route {
    min-width: 170px;
    max-width: 230px;
}

.col-duration {
    min-width: 110px;
    max-width: 150px;
    white-space: nowrap;
}

.col-client-inner,
.col-route-inner {
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-blue {
    color: #0d6efd !important;
}
.link-blue:hover {
    color: #0a58ca !important;
}

/* ── Search button: match purple theme ─────────────────────────────── */
.table-search-form .btn-dark {
    background-color: var(--ap);
    border-color: var(--ap);
    color: #fff;
}

.table-search-form .btn-dark:hover {
    background-color: var(--ap-dark);
    border-color: var(--ap-dark);
}

/* ── Content links (exclude buttons — they manage their own colour) ── */
.admin-content a:not(.btn) {
    color: var(--ap);
}

.admin-content a:not(.btn):hover {
    color: var(--ap-dark);
}

/* Keep table header links white regardless */
.admin-content .table thead a,
.admin-content .table thead a:hover {
    color: #fff !important;
}

/* ── Table toolbar ────────────────────────────────────────────────── */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.table-search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 220px;
    max-width: 440px;
}

.table-search-input {
    border-radius: 6px 0 0 6px !important;
}

.table-search-form .input-group .btn {
    border-radius: 0 6px 6px 0;
}

.table-clear-btn {
    white-space: nowrap;
}

/* ── Pagination footer ────────────────────────────────────────────── */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-limit-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.table-limit-select {
    width: auto;
    min-width: 68px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid var(--admin-border);
    background-color: #fff;
    color: var(--admin-text);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    cursor: pointer;
    user-select: none;
}

.btn-page:hover {
    background-color: var(--ap-light);
    border-color: var(--ap);
    color: var(--ap);
    text-decoration: none;
}

.btn-page.active {
    background-color: var(--ap);
    border-color: var(--ap);
    color: #fff;
    min-width: 56px;
    font-weight: 600;
    cursor: default;
}

.btn-page.disabled {
    color: #CBD5E1;
    border-color: var(--admin-border);
    background-color: #F8FAFC;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Table action buttons ─────────────────────────────────────────── */
.table .btn-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
}

/* ── ContentBlocks editor ─────────────────────────────────────────── */
.contentBlocks .ck-editor__editable_inline {
    min-height: 25rem;
}

.contentBlocks input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
}

.content-blocks-icon-preview {
    margin-bottom: 1rem;
}

.content-blocks--image-preview-default {
    max-width: 300px;
    margin-bottom: 1rem;
}

/* ── Email/mailto links ───────────────────────────────────────────── */
.mailto-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.mailto-link:hover {
    color: inherit;
    text-decoration: none;
}

.mailto-icon {
    color: var(--ap);
    background: var(--ap-light);
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 0.65rem;
    transition: background 0.15s, color 0.15s;
}

.mailto-link:hover .mailto-icon {
    background: var(--ap);
    color: #fff;
}

/* ── Tooltips ─────────────────────────────────────────────────────── */
.tooltip .tooltip-inner {
    font-size: 0.72rem;
    padding: 2px 6px;
    background-color: #333;
    color: #fff;
    border-radius: 3px;
    max-width: 160px;
    box-shadow: none;
}

.tooltip .tooltip-arrow::before {
    display: none;
}

/* ── Dashboard ────────────────────────────────────────────────────── */
.dash-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

.dash-date {
    color: var(--admin-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* Stat cards */
.dash-stat-card {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
    transition: box-shadow 0.15s;
}

.dash-stat-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.dash-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.dash-icon-purple  { background: #EDE9FE; color: #7C3AED; }
.dash-icon-indigo  { background: #E0E7FF; color: #4338CA; }
.dash-icon-emerald { background: #D1FAE5; color: #065F46; }
.dash-icon-amber   { background: #FEF3C7; color: #92400E; }

.dash-stat-body {
    flex: 1;
}

.dash-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--admin-text);
    line-height: 1;
}

.dash-stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--admin-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.2rem;
}

.dash-stat-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ap);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.dash-stat-link:hover {
    color: var(--ap-dark);
    text-decoration: none;
}

/* Section title inside cards */
.dash-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--admin-muted);
    margin-bottom: 0;
}

/* Booking pipeline cells */
.dash-pipeline-cell {
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
}

.dash-pipeline-count {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.dash-pipeline-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-top: 0.25rem;
}

.dash-pipeline-pending   { background: #FEF9C3; color: #713F12; }
.dash-pipeline-confirmed { background: #EDE9FE; color: #5B21B6; }
.dash-pipeline-completed { background: #DCFCE7; color: #14532D; }
.dash-pipeline-cancelled { background: #F1F5F9; color: #475569; }

/* Card header for recent panels */
.dash-card-header {
    background: none;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--admin-text);
    padding: 0.85rem 1.25rem;
}

.dash-card-header-link {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ap);
    text-decoration: none;
}

.dash-card-header-link:hover {
    color: var(--ap-dark);
    text-decoration: none;
}

/* Recent record list */
.dash-record-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dash-record-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--admin-border);
    transition: background 0.12s;
}

.dash-record-item:last-child {
    border-bottom: none;
}

.dash-record-item:hover {
    background: var(--ap-xlight);
}

.dash-record-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}

.dash-avatar-purple  { background: #EDE9FE; color: #7C3AED; }
.dash-avatar-emerald { background: #D1FAE5; color: #065F46; }

.dash-record-info {
    flex: 1;
    min-width: 0;
}

.dash-record-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--admin-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-record-name a {
    color: var(--admin-text);
    text-decoration: none;
}

.dash-record-name a:hover {
    color: var(--ap);
}

.dash-record-meta {
    font-size: 0.78rem;
    color: var(--admin-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-record-time {
    font-size: 0.78rem;
    color: var(--admin-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Auth pages ───────────────────────────────────────────────────── */
.auth-body {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 60%, #ddd6fe 100%);
    min-height: 100vh;
}

.auth-page-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 2rem 0;
}

.auth-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(124, 58, 237, 0.1);
}

.auth-logo-icon {
    width: 64px;
    height: 64px;
    background: var(--ap-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
}

.auth-logo-icon i {
    font-size: 1.75rem;
    color: var(--ap);
}

.auth-title {
    color: #1e293b;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}

.auth-subtitle {
    color: #64748b;
    font-size: 0.95rem;
}

.auth-form-label {
    color: #374151;
    font-weight: 600;
    font-size: 0.875rem;
    display: block;
    margin-bottom: 0.35rem;
}

.auth-link {
    color: var(--ap) !important;
    font-weight: 600;
    text-decoration: none;
}

.auth-link:hover {
    color: var(--ap-dark) !important;
    text-decoration: underline;
}

.btn-auth-submit {
    background-color: var(--ap);
    border-color: var(--ap);
    color: #fff;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.02em;
    padding: 0.7rem 2rem;
    border-radius: 8px;
    width: 100%;
    font-size: 1rem;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn-auth-submit:hover:not(:disabled) {
    background-color: var(--ap-dark);
    border-color: var(--ap-dark);
    color: #fff;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.btn-auth-submit:disabled {
    background-color: var(--ap);
    border-color: var(--ap);
    color: #fff;
    opacity: 0.55;
    cursor: not-allowed;
}

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .admin-main-wrapper {
        margin-left: 0 !important;
    }
}

@media (max-width: 767.98px) {
    .admin-content {
        padding: 1rem;
    }

    .admin-topbar {
        padding: 0 1rem;
    }

    .user-display-name {
        display: none;
    }

    #adminNotification {
        top: calc(var(--topbar-h) + 0.5rem);
        left: 1rem;
        right: 1rem;
        transform: none;
        max-width: none;
        min-width: 0;
        max-width: none;
    }

    .table-pagination {
        flex-direction: column;
        align-items: center;
        gap: 0.6rem;
    }

    .btn-page {
        min-width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .btn-page.active {
        min-width: 48px;
    }

    h2 {
        font-size: 1.4rem;
    }

    .text-nowrap .btn-sm {
        padding: 0.2rem 0.35rem;
        font-size: 0.75rem;
    }
}

/* ── Remove sticky actions column on tablet and below ─────────────────
   position: sticky + right: 0 overlaps the adjacent column on screens where
   the table slightly overflows — turning it off lets the column sit normally
   so users horizontally scroll to reach it (standard tablet/phone UX).      */
@media (max-width: 991.98px) {
    .table-actions-sticky {
        position: static !important;
        border-left: none !important;
        box-shadow: none !important;
        z-index: auto !important;
    }
}

@media (max-width: 575.98px) {
    .table-search-form {
        max-width: 100%;
        flex: 1 1 100%;
    }

    /* ── Reduce col-client min-width on very small screens ───────────── */
    .col-client {
        min-width: 120px;
    }

    /* ── Page header: stack action buttons below title on xs ────────── */
    .row > .col-auto {
        flex: 0 0 100%;
        max-width: 100%;
        padding-top: 0.5rem;
    }

    /* ── Wrap all flex button groups on xs (view pages, form headers) ── */
    .row > .col-auto .d-flex,
    .mb-3.d-flex,
    .d-flex.gap-2,
    .d-flex.gap-3 {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }

    /* ── Ensure no element causes full-page horizontal scroll ────────── */
    .admin-content {
        overflow-x: hidden;
    }

    /* ── Cards / enquiry summary cards don't force overflow ─────────── */
    .card {
        min-width: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   Operator Availability Calendar
   ═══════════════════════════════════════════════════════════════════ */

/* Scrollable container so grid never breaks the page layout */
.avail-grid-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* The grid table */
.avail-table {
    border-collapse: collapse;
    min-width: 480px; /* prevents column collapse on very small phones */
    width: 100%;
    table-layout: fixed;
}

/* Time label column — sticky so it stays visible on horizontal scroll */
.avail-time-label {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    width: 52px;
    min-width: 52px;
    padding: 2px 6px 2px 0;
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
}

/* The empty corner header cell also needs sticky + a slightly higher z-index
   so it sits above the day headers when scrolling */
thead .avail-time-label {
    z-index: 3;
    background: #fff;
}

.avail-time-text {
    font-size: 0.7rem;
    color: var(--admin-muted);
    font-weight: 500;
}

/* Day header cells */
.avail-day-header {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 2px 6px;
    color: var(--admin-text);
    border-bottom: 2px solid var(--admin-border);
}

.avail-day-header.avail-today {
    color: var(--ap);
    border-bottom-color: var(--ap);
}

/* Cell wrapper */
.avail-cell-wrap {
    padding: 2px;
}

/* Base cell — used for both <button> (editable) and <div> (read-only) */
.avail-cell {
    display: block;
    width: 100%;
    min-width: 36px;
    height: 36px;
    border-radius: 5px;
    border: 1px solid var(--admin-border);
    background: #F8FAFC;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.08s;
    padding: 0;
    /* Reset browser button styles */
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    box-sizing: border-box;
}

button.avail-cell:not(:disabled):not(.avail-cell--past):hover {
    background: var(--ap-light);
    border-color: var(--ap-mid);
    transform: scale(1.06);
}

.avail-cell--available {
    background: #DCFCE7;
    border-color: #22C55E;
}

button.avail-cell--available:not(:disabled):not(.avail-cell--past):hover {
    background: #BBF7D0;
    border-color: #16A34A;
    transform: scale(1.06);
}

/* Past cells: diagonal stripe pattern — clearly "locked" but still light */
.avail-cell--past {
    background: repeating-linear-gradient(
        -45deg,
        #EEF2F7,
        #EEF2F7 4px,
        #DDE3ED 4px,
        #DDE3ED 8px
    );
    border-color: #CBD5E1;
    cursor: not-allowed;
    pointer-events: none;
}

.avail-cell--past.avail-cell--available {
    background: repeating-linear-gradient(
        -45deg,
        #DCFCE7,
        #DCFCE7 4px,
        #BBF7D0 4px,
        #BBF7D0 8px
    );
    border-color: #86EFAC;
}

.avail-cell--readonly {
    cursor: default;
    pointer-events: none;
}

/* Legend swatches */
.avail-legend {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
    border: 1px solid var(--admin-border);
}

.avail-cell--booked {
    background: #DDD6FE; border-color: var(--ap); display: flex;
    align-items: center; justify-content: center; text-decoration: none;
    font-size: 10px; font-weight: 700; color: var(--ap-dark); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.avail-cell--booked:hover { background: var(--ap); color: #fff; }

.avail-legend--available { background: #DCFCE7; border-color: #22C55E; }
.avail-legend--booked    { background: #DDD6FE; border-color: var(--ap); }
.avail-legend--empty     { background: #F8FAFC; }
.avail-legend--past      {
    background: repeating-linear-gradient(-45deg, #EEF2F7, #EEF2F7 4px, #DDE3ED 4px, #DDE3ED 8px);
    border-color: #CBD5E1;
}

/* Touch-friendly: ensure cells are at least 44x44 on touch devices */
@media (pointer: coarse) {
    .avail-cell { height: 44px; }
    .avail-time-label { width: 44px; font-size: 0.65rem; }
}

/* ── Operator topnav (horizontal links in topbar for operator role) ── */
.operator-topnav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1rem;
}

.operator-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--admin-text);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.operator-nav-link:hover {
    background: var(--ap-light);
    color: var(--ap);
    text-decoration: none;
}

.operator-nav-link.active {
    background: var(--ap-light);
    color: var(--ap);
}

.operator-nav-link span {
    display: none; /* show only icon on very small screens */
}

@media (min-width: 480px) {
    .operator-nav-link span { display: inline; }
}

/* ── Confirm bar ─────────────────────────────────────────────────── */
.avail-confirm-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.avail-status-text {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ── Availability badge next to operator checkboxes ─────────────── */
.avail-badge .badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25em 0.55em;
}

/* ── Form validation error messages ─────────────────────────────── */
.form-error-msg {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.825rem;
    font-weight: 500;
    color: #dc3545;
    background: #fff5f5;
    border: 1px solid #f5c2c7;
    border-radius: 0.375rem;
    padding: 0.35rem 0.65rem;
}

/* ── Vehicle conflict + availability badges: wrap on mobile ─────── */
.vehicle-conflict-badge,
.avail-badge {
    max-width: 100%;
}

.vehicle-conflict-badge .badge,
.avail-badge .badge {
    white-space: normal;
    word-break: break-word;
    text-align: left;
    display: inline-block;
    max-width: 100%;
    line-height: 1.4;
}

.vehicle-checkbox-item,
.operator-checkbox-item {
    min-width: 0;
}

/* ── Toggle switches: purple + bigger tap target ─────────────────── */
.form-switch {
    padding-left: 3.5em;
}
.form-switch .form-check-input {
    width: 2.75em;
    height: 1.5em;
    margin-top: 0.15em;
    margin-left: -3.5em;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--ap);
    border-color: var(--ap);
}

.form-check-input:focus {
    border-color: var(--ap);
    box-shadow: 0 0 0 0.2rem rgba(139, 92, 246, 0.25);
}

.form-check-label {
    cursor: pointer;
}

/* ── Operator bottom nav (mobile) ────────────────────────────────── */
/* Hidden by default; JS moves it to <body> and shows it on mobile   */
.op-bottom-nav {
    display: none;
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 9999;
    background: #fff;
    border-top: 1px solid var(--admin-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    height: 72px;
    align-items: stretch;
    /* safe-area inset for notched phones */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.op-bottom-nav.is-ready {
    display: flex !important;
}

.op-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #94A3B8;
    text-decoration: none;
    border: none;
    background: none;
    padding: 8px 4px;
    cursor: pointer;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
    white-space: nowrap;
}

.op-bottom-nav__item i {
    font-size: 1.5rem;
    display: block;
}

.op-bottom-nav__item.active,
.op-bottom-nav__item:hover { color: var(--ap); }

/* ── Floating confirm button (mobile availability page) ──────────── */
.op-float-confirm {
    display: none;
    position: fixed !important;
    bottom: 84px;       /* sits above the 72px bottom nav */
    right: 1rem;
    z-index: 9998;
    background: #fff;
    border: 2px solid var(--ap);
    color: var(--ap);
    border-radius: 2rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.25);
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .avail-page .op-float-confirm {
        display: inline-flex !important;
        align-items: center;
        gap: 0.4rem;
    }
}

.op-float-confirm.is-dirty {
    border-color: #D97706;
    color: #D97706;
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.25);
}

.op-float-confirm.is-saved {
    background: #16A34A;
    border-color: #16A34A;
    color: #fff;
    box-shadow: 0 4px 16px rgba(22, 163, 74, 0.25);
}

/* Profile dropdown inherits item styles */
.op-bottom-nav__profile-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #94A3B8;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    height: 100%;
}

.op-bottom-nav__profile-btn i {
    font-size: 1.5rem;
    display: block;
}

/* ── Operator topbar: slim on mobile ─────────────────────────────── */
@media (max-width: 767.98px) {
    .operator-mode .admin-topbar {
        height: 52px;
        padding: 0 1rem;
    }

    .operator-mode .op-brand-label {
        font-size: 0.9rem;
    }

    /* Bottom padding so content clears the nav bar */
    .operator-mode .admin-content {
        padding-bottom: 82px;
    }
}

/* ── Repeated day-of-week bars inside each section (mobile only) ─── */
.avail-section-daybar {
    display: none;
}

@media (max-width: 767.98px) {
    .avail-section-daybar {
        display: table-row;
    }

    .avail-day-mini-header {
        text-align: center;
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--admin-muted);
        padding: 4px 2px 3px;
        background: #F8FAFC;
        border-bottom: 1px solid var(--admin-border);
        line-height: 1.3;
    }

    .avail-day-mini-header.avail-today {
        color: var(--ap);
    }
}

/* ── Availability grid section dividers ──────────────────────────── */
.avail-section-row td {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 6px;
    border-top: 2px solid var(--admin-border);
    color: var(--admin-muted);
    user-select: none;
}

.avail-section-row--overnight td { background: #EFF6FF; }
.avail-section-row--day td        { background: #F8FAFC; }
.avail-section-row--night td      { background: #FDF4FF; }

/* ── Collapsible section headers ─────────────────────────────────── */
.avail-collapse-icon {
    float: right;
    transition: transform 0.2s ease;
    margin-top: 1px;
}

.avail-section-row.is-collapsed .avail-collapse-icon {
    transform: rotate(-90deg);
}

/* ── Floating edit button (mobile availability page) ────────────── */
.op-float-edit {
    display: none;
    position: fixed !important;
    bottom: 84px;
    left: 1rem;
    z-index: 9998;
    background: #fff;
    border: 2px solid var(--ap);
    color: var(--ap);
    border-radius: 2rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.25);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    align-items: center;
    gap: 0.4rem;
}

@media (max-width: 767.98px) {
    .avail-page .op-float-edit {
        display: inline-flex !important;
        align-items: center;
        gap: 0.4rem;
    }
}

.op-float-edit.is-exit {
    background: var(--ap);
    color: #fff;
}

/* ── Edit mode styles (mobile) ───────────────────────────────────── */
@media (max-width: 767.98px) {
    /* View mode: cells non-interactive so grid scrolls freely */
    .avail-table:not(.edit-mode) .avail-cell[data-date] {
        pointer-events: none;
        cursor: default;
    }

    /* Edit mode: cells interactive, grid gets purple outline */
    .avail-table.edit-mode .avail-cell[data-date] {
        pointer-events: auto;
        cursor: pointer;
    }

    .avail-table.edit-mode {
        outline: 2px solid var(--ap);
        outline-offset: 2px;
        border-radius: 4px;
    }
}

/* ── Index table cards: clip inner table corners to card radius ──── */
.index-table-card {
    overflow: hidden;
}

/* ── Route Information Widget ────────────────────────────────────── */
.route-info-widget {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-start;
    margin-top: 0.75rem;
}

.route-stat {
    flex: 1 1 120px;
    min-width: 100px;
}

.route-stat .route-stat-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.15rem;
}

.route-stat .route-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.route-maps-btn {
    flex: 0 0 auto;
    align-self: flex-end;
}

@media (max-width: 575.98px) {
    .route-maps-btn {
        width: 100%;
        text-align: center;
    }
}

/* ── Archive Files Page ──────────────────────────────────────────── */
.files-drop-zone {
    border: 2px dashed var(--ap);
    border-radius: 12px;
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    margin-bottom: 2rem;
    background: #faf9ff;
    user-select: none;
}
.files-drop-zone:hover,
.files-drop-zone--over {
    background: #f0eaff;
    border-color: #5a1a8a;
}
.files-drop-icon {
    font-size: 2.5rem;
    color: var(--ap);
    display: block;
    margin-bottom: 0.75rem;
}
.files-drop-label {
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.3rem;
}
.files-drop-hint {
    font-size: 0.82rem;
    color: #6c757d;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.file-card {
    position: relative;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 10px;
    padding: 1.25rem 0.75rem 0.9rem;
    text-align: center;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.file-card:hover {
    box-shadow: 0 4px 14px rgba(90,26,138,0.12);
    border-color: var(--ap);
}
.file-card-icon {
    font-size: 2.4rem;
    margin-bottom: 0.6rem;
    line-height: 1;
}
.file-card-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.25rem;
}
.file-card-meta {
    font-size: 0.72rem;
    color: #6c757d;
}
.file-card-delete {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    color: #dc3545;
    font-size: 0.75rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    z-index: 1;
}
.file-card-delete:hover {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

@media (max-width: 575.98px) {
    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}
