:root {
    --admin-bg: #f4f6f9;
    --admin-surface: #ffffff;
    --admin-border: #e6e8ec;
    --admin-text: #1f2328;
    --admin-text-muted: #6b7280;

    --admin-sidebar-bg: #0b1220;
    --admin-sidebar-border: #1e293b;
    --admin-sidebar-text: #cbd5e1;
    --admin-sidebar-muted: #64748b;
    --admin-sidebar-active-bg: rgba(255, 255, 255, 0.06);
    --admin-sidebar-hover-bg: rgba(255, 255, 255, 0.04);

    --admin-sidebar-width: 250px;
    --admin-topbar-height: 60px;
}

html, body {
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.admin-body {
    background-color: var(--admin-bg);
    color: var(--admin-text);
    min-height: 100vh;
    margin: 0;
}

/* ===== Shell ===== */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--admin-sidebar-width);
    transition: margin-left 0.2s ease;
}

.admin-main {
    flex: 1;
    min-height: calc(100vh - var(--admin-topbar-height));
}

/* ===== Sidebar ===== */
.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--admin-sidebar-width);
    background: var(--admin-sidebar-bg);
    color: var(--admin-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.2s ease;
}

.admin-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    height: var(--admin-topbar-height);
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--admin-sidebar-border);
}

.admin-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.admin-brand:hover {
    color: #ffffff;
}

.admin-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 0.95rem;
}

.admin-sidebar-collapse {
    display: none;
    background: transparent;
    border: none;
    color: var(--admin-sidebar-text);
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.admin-nav {
    flex: 1;
    padding: 1.25rem 0.75rem;
    overflow-y: auto;
}

.admin-nav-section + .admin-nav-section {
    margin-top: 1.5rem;
}

.admin-nav-section-title {
    padding: 0 0.75rem 0.5rem;
    color: var(--admin-sidebar-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.125rem;
    color: var(--admin-sidebar-text);
    text-decoration: none;
    border-radius: 7px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.admin-nav-item i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    color: var(--admin-sidebar-muted);
    transition: color 0.12s ease;
}

.admin-nav-item:hover {
    background-color: var(--admin-sidebar-hover-bg);
    color: #ffffff;
}

.admin-nav-item:hover i {
    color: #ffffff;
}

.admin-nav-item.active {
    background-color: var(--admin-sidebar-active-bg);
    color: #ffffff;
}

.admin-nav-item.active i {
    color: #ffffff;
}

.admin-sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--admin-sidebar-border);
    font-size: 0.85rem;
}

.admin-user-label {
    color: var(--admin-sidebar-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.125rem;
}

.admin-user-name {
    color: #ffffff;
    font-weight: 500;
}

.admin-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1035;
}

/* ===== Topbar ===== */
.admin-topbar {
    height: var(--admin-topbar-height);
    background: var(--admin-sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.admin-topbar-toggle {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 1.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
}

.admin-topbar-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.admin-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.admin-user-menu {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: none;
    color: #cbd5e1;
    padding: 0.35rem 0.6rem;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.admin-user-menu:hover,
.admin-user-menu[aria-expanded="true"] {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.admin-user-menu > .bi-person-circle {
    font-size: 1.5rem;
}

.admin-user-menu-caret {
    font-size: 0.65rem;
    opacity: 0.85;
}

/* ===== Flash messages ===== */
.message {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.7rem 0.75rem 0.7rem 0.9rem;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.4;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.message-icon {
    font-size: 1.05rem;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.message-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.message-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.55;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: opacity 0.12s ease, background-color 0.12s ease;
}

.message-close:hover,
.message-close:focus {
    opacity: 1;
    background-color: rgba(15, 23, 42, 0.06);
    outline: none;
}

.message.success {
    background-color: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.message.success .message-icon {
    color: #10b981;
}

.message.error {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.message.error .message-icon {
    color: #ef4444;
}

.message.info {
    background-color: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.message.info .message-icon {
    color: #3b82f6;
}

.message.warning {
    background-color: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.message.warning .message-icon {
    color: #f59e0b;
}

.message.hidden {
    display: none;
}

/* ===== Page header (title left, breadcrumb right) ===== */
.admin-page-header-main {
    min-width: 0;
    flex: 1 1 auto;
}

.admin-page-header .admin-breadcrumb {
    padding-top: 0.35rem;
}

/* ===== Breadcrumb ===== */
.admin-breadcrumb .breadcrumb {
    background-color: transparent;
    padding: 0;
    font-size: 0.8rem;
}

.admin-breadcrumb .breadcrumb-item,
.admin-breadcrumb .breadcrumb-item a {
    color: var(--admin-text-muted);
    text-decoration: none;
}

.admin-breadcrumb .breadcrumb-item a:hover {
    color: var(--admin-text);
}

.admin-breadcrumb .breadcrumb-item.active {
    color: var(--admin-text);
}

/* ===== Cards ===== */
.card {
    border-color: var(--admin-border);
    border-radius: 8px;
}

.card-title {
    font-size: 0.95rem;
}

.sticky-actions-card {
    position: sticky;
    top: calc(var(--admin-topbar-height) + 1rem);
    z-index: 2;
    background-color: #fff;
}

/* On screens below the lg breakpoint the two-column layout stacks vertically.
   By default that puts the Actions sidebar at the bottom because its column
   (col-lg-3) sits after the main content column (col-lg-9) in source order.
   Lift the sidebar column above the content on mobile so primary actions and
   "Back" navigation are reachable without scrolling past the page body. */
@media (max-width: 991.98px) {
    .row > .col-lg-3:has(> .sticky-actions-card) {
        order: -1;
    }
}

/* ===== Index page conventions ===== */
.section-divider {
    border-bottom: 1px solid var(--admin-border);
}

.filter-col-sm {
    flex: 0 0 auto !important;
    width: 140px !important;
}

.filter-col-md {
    flex: 0 0 auto !important;
    width: 160px !important;
}

/* Extra-small button — used inside .row-actions-row hover rows */
.btn-xs {
    padding: 0.15rem 0.5rem;
    font-size: 0.72rem;
    line-height: 1.4;
    border-radius: 0.25rem;
}

/* Sortable table headers (Paginator->sort()). Drop the default underline and
   link color so the label reads as a normal heading; the asc/desc arrow is
   the only colored cue that this column is sorted. */
.table thead a {
    color: inherit;
    text-decoration: none;
}

.table thead a:hover,
.table thead a:focus {
    color: inherit;
    text-decoration: none;
}

.table thead a.asc::after,
.table thead a.desc::after {
    margin-left: 0.3rem;
    color: var(--bs-primary, #fd7e14);
    font-weight: 700;
}

.table thead a.asc::after {
    content: '\2191';
}

.table thead a.desc::after {
    content: '\2193';
}

/* Bootstrap's .input-group defaults to `flex-wrap: wrap`, which strands the
   search button on its own line when the FormHelper-wrapped input doesn't
   shrink predictably on narrow viewports. Our search bars are designed to
   live on a single row (search input + button [+ optional clear]); the only
   case that genuinely needs wrapping is mobile + filter-select, handled by
   the media query below. Force nowrap as the baseline so the row stays
   intact regardless of how the inner input reports its intrinsic size. */
.input-group {
    flex-wrap: nowrap;
}

/* Make the FormHelper input wrapper grow inside .input-group so the search
   field fills the remaining horizontal space alongside filter selects.
   The `width: 1%` + `min-width: 0` pair mirrors Bootstrap's own
   `.input-group > .form-control` rule so the wrapper can shrink below its
   content's intrinsic size. */
.input-group > .input {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group > .input > .form-control {
    width: 100%;
    min-width: 0;
}

/* Bootstrap's input-group border-radius rules target direct children, but the
   FormHelper-wrapped search input sits inside a <div class="input"> wrapper,
   so the inner <input> keeps its rounded corners and breaks the row seam.
   Propagate the radius treatment to the inner form-control. */
.input-group > .input:not(:last-child) > .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group > .input:not(:first-child) > .form-control {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Bootstrap Icons' default vertical-align (-0.125em) inflates the line-box of
   an icon-only button so it renders ~2px taller than a text-only sibling
   .form-select. Use flex layout inside the button so its natural height is
   driven by the icon's intrinsic size, letting the input-group's stretch
   alignment level all children to the same height. */
.input-group > .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Mobile (< md): when a filter select is present, drop the search input to
   its own row and let the filter select(s) + buttons flow on the second row.
   Re-rounds the border-radii at the wrap points so the wrapped rows still
   read as separate controls. Scoped with :has(.form-select) so that pages
   without filter selects (search input + button only) keep the search and
   button on a single row instead of stranding the button alone. */
@media (max-width: 767.98px) {
    .input-group:has(.form-select) {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }

    .input-group:has(.form-select) > .input:first-child {
        flex: 1 0 100%;
    }

    .input-group:has(.form-select) > .input:first-child > .form-control {
        border-radius: var(--bs-border-radius, 0.375rem);
    }

    .input-group:has(.form-select) > .input:first-child ~ .form-select,
    .input-group:has(.form-select) > .input:first-child ~ .form-control {
        border-top-left-radius: var(--bs-border-radius, 0.375rem);
        border-bottom-left-radius: var(--bs-border-radius, 0.375rem);
    }

    .input-group > .filter-col-sm,
    .input-group > .filter-col-md {
        flex: 1 1 auto !important;
        width: auto !important;
    }
}

.row-actions-row {
    display: none;
    background-color: #f9fafb;
}

tr:hover + .row-actions-row,
.row-actions-row:hover {
    display: table-row;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .admin-content {
        margin-left: 0;
    }

    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
    }

    .admin-sidebar-backdrop.is-open {
        display: block;
    }

    .admin-sidebar-collapse {
        display: inline-flex;
    }
}

@media (min-width: 992px) {
    .admin-topbar-toggle {
        display: none;
    }
}

.btn-sidebar {
    background-color: #475569;
    border-color: #475569;
    color: #ffffff;
}

.btn-sidebar:hover,
.btn-sidebar:focus {
    background-color: #334155;
    border-color: #334155;
    color: #ffffff;
}

.btn-sidebar:active,
.btn-sidebar.active {
    background-color: #334155 !important;
    border-color: #334155 !important;
    color: #ffffff !important;
}

/* ── Loading overlay ──────────────────────────────────────────────────────
   Full-screen "please wait" overlay shared by every admin plugin. Rendered by
   the templates/element/admin/loading_overlay.php element and revealed by the
   shared handler in webroot/js/admin/common.js. Hidden by default via the
   [hidden] attribute. */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.55);
    backdrop-filter: blur(2px);
}

.loading-overlay[hidden] {
    display: none;
}

.loading-overlay-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 2.5rem;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    text-align: center;
    max-width: 90vw;
}

.loading-overlay-spinner {
    width: 2.5rem;
    height: 2.5rem;
    color: var(--bs-primary, #0d6efd);
}

.loading-overlay-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--bs-body-color, #212529);
}

.loading-overlay-subtitle {
    font-size: 0.875rem;
    color: var(--bs-secondary, #6c757d);
}

/* API-source panel method badge (templates/element/admin/api_endpoints.php) —
   fixed width + monospace so GET/POST/DELETE line up. */
.api-endpoint-method {
    min-width: 3.5rem;
    font-family: var(--bs-font-monospace, ui-monospace, monospace);
    letter-spacing: 0.02em;
}

/* Booking-question accordion toggle (templates/Admin/Products/view.php) —
   chevron rotates to point up while its collapse panel is open. */
.booking-question-toggle .bi {
    transition: transform 0.2s ease;
}
.booking-question-toggle[aria-expanded="true"] .bi {
    transform: rotate(180deg);
}
