/* Custom styles for Flight School Scheduling System */

/* Primary Color Variables
   Default values defined here, overridden dynamically in base.html from admin settings. */
:root {
    --bs-primary: #15135F;
    --bs-primary-rgb: 21, 19, 95;
    --bs-primary-dark: #100e4a;
    --bs-link-color: var(--bs-primary);
    --bs-link-hover-color: var(--bs-primary-dark);
    --sidebar-width: 220px;
}

.bg-primary {
    background-color: var(--bs-primary) !important;
}

.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary-dark);
    --bs-btn-hover-border-color: var(--bs-primary-dark);
    --bs-btn-active-bg: var(--bs-primary-dark);
    --bs-btn-active-border-color: var(--bs-primary-dark);
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-bg: var(--bs-primary);
    --bs-btn-active-border-color: var(--bs-primary);
}

/* Nav pills active state */
.nav-pills {
    --bs-nav-pills-link-active-bg: var(--bs-primary);
}

/* Form check inputs (checkboxes and radio buttons) */
.form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}
.form-check-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Pagination active state */
.page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}
.page-link:hover, .page-link:focus {
    color: var(--bs-primary);
}

/* Form control focus states (global) */
.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Accordion expanded state */
.accordion-button:not(.collapsed) {
    color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}
.accordion-button:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Flatpickr date picker theming */
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange {
    background: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
}
.flatpickr-calendar {
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: none;
}
.flatpickr-day.today {
    background-color: #e7f1ff !important;
    border-color: #e7f1ff !important;
    color: #000 !important;
}
.flatpickr-day.today.selected {
    background: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: white !important;
}
.flatpickr-day:hover {
    background: #e9ecef !important;
    border-color: #e9ecef !important;
}
.flatpickr-day.selected:hover {
    background: #0b5ed7 !important;
    border-color: #0b5ed7 !important;
}
/* Compact flatpickr alt-inputs to match form-control-sm */
.flatpickr-input.form-control-sm + .form-control {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    height: calc(1.5em + 0.5rem + 2px);
}

/* TomSelect theming */
.ts-wrapper .ts-control .item {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: white !important;
}
.ts-wrapper.focus .ts-control {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

.text-primary {
    color: var(--bs-primary) !important;
}

.border-primary {
    border-color: var(--bs-primary) !important;
}

a {
    color: var(--bs-primary);
}

a:hover {
    color: var(--bs-primary-dark);
}

/* ── Modern Navbar ─────────────────────────────────── */
.navbar-modern {
    background: var(--navbar-bg, var(--bs-primary));
    padding: 0.1rem 0.5rem;
    height: 56px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
    border: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1045;
}

.navbar-modern .navbar-brand img {
    transition: opacity 0.2s;
}
.navbar-modern .navbar-brand:hover img {
    opacity: 0.85;
}

/* Hamburger icon */
.navbar-modern .navbar-toggler {
    border: none;
    padding: 0.35rem 0.5rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.3rem;
}
.navbar-modern .navbar-toggler:focus {
    box-shadow: none;
}

/* Nav links */
.navbar-modern .nav-link {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    transition: color 0.15s, background-color 0.15s;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.navbar-modern .nav-link i {
    font-size: 1.1rem;
    opacity: 0.8;
}

.navbar-modern .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar-modern .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.18);
}

/* ── Module Switcher (Segmented Control) ── */
.module-switcher {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.module-switcher .module-opt {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.28rem 0.75rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    transition: color 0.2s, background 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    border: none;
    background: transparent;
    letter-spacing: 0.01em;
}

.module-switcher .module-opt i {
    font-size: 0.82rem;
    opacity: 0.85;
}

.module-switcher .module-opt:hover:not(.active) {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.08);
}

.module-switcher .module-opt.active {
    color: var(--navbar-bg, var(--bs-primary));
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.module-switcher .module-opt.active i {
    opacity: 1;
}

/* Sidebar variant (white background context) */
.module-switcher-sidebar {
    display: flex;
    align-items: center;
    background: rgba(var(--navbar-bg-rgb, var(--bs-primary-rgb)), 0.07);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.module-switcher-sidebar .module-opt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.3rem 0;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--navbar-bg, var(--bs-primary));
    opacity: 0.55;
    text-decoration: none;
    transition: opacity 0.2s, background 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    border: none;
    background: transparent;
    flex: 1;
}

.module-switcher-sidebar .module-opt i {
    font-size: 0.82rem;
}

.module-switcher-sidebar .module-opt:hover:not(.active) {
    opacity: 0.75;
    background: rgba(var(--navbar-bg-rgb, var(--bs-primary-rgb)), 0.05);
}

.module-switcher-sidebar .module-opt.active {
    opacity: 1;
    background: var(--navbar-bg, var(--bs-primary));
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* User avatar in navbar */
.nav-avatar {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: border-color 0.15s;
}

.nav-avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    transition: border-color 0.15s;
}

.nav-link-user {
    gap: 0.5rem !important;
    padding: 0.3rem 0.55rem !important;
    border-radius: 20px !important;
    font-size: 1rem !important;
}

.nav-link-user.show,
.nav-link-user.show:hover,
.nav-link-user.show:focus {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-link-user:hover .nav-avatar,
.nav-link-user:hover .nav-avatar-placeholder {
    border-color: rgba(255, 255, 255, 0.6);
}

/* Admin inbox */
.nav-inbox-toggle {
    color: rgba(255, 255, 255, 0.75) !important;
    padding: 0.3rem 0.55rem !important;
    border-radius: 6px;
    transition: color 0.15s, background-color 0.15s;
}
.nav-inbox-toggle i {
    font-size: 1.75rem !important;
    line-height: 1;
    vertical-align: middle;
}
.nav-inbox-toggle:hover,
.nav-inbox-toggle.show {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.1);
}
.nav-inbox-badge {
    font-size: 0.6rem !important;
    padding: 0.2em 0.45em !important;
    line-height: 1;
    min-width: 1.1em;
    pointer-events: none;
}
.nav-inbox-dropdown {
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
}
.nav-inbox-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    white-space: normal;
    line-height: 1.3;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}
.nav-inbox-dropdown .dropdown-item small {
    font-size: 0.75rem;
}

/* Modern dropdown menu */
.navbar-dropdown {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 0.35rem;
    margin-top: 0.4rem;
    min-width: 200px;
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.navbar-dropdown .dropdown-header {
    padding: 0.5rem 0.85rem 0.25rem;
    color: #374151;
    font-size: 0.9rem;
}

.navbar-dropdown .dropdown-item {
    color: #374151;
    font-size: 0.9rem;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    transition: background-color 0.12s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-dropdown .dropdown-item i {
    font-size: 1rem;
    color: #6b7280;
    width: 1.1rem;
    text-align: center;
}

.navbar-dropdown .dropdown-item:hover,
.navbar-dropdown .dropdown-item:focus {
    background-color: #f3f4f6;
    color: #111827;
}

.navbar-dropdown .dropdown-item:hover i {
    color: #374151;
}

.navbar-dropdown .dropdown-divider {
    margin: 0.25rem 0.5rem;
    border-color: #e5e7eb;
}

/* Mobile navbar tweaks */
@media (max-width: 991.98px) {
    .navbar-modern .navbar-brand img {
        height: 32px !important;
    }
    .nav-avatar, .nav-avatar-placeholder {
        width: 30px !important;
        height: 30px !important;
    }
    .nav-link-user {
        padding: 0.35rem 0.5rem !important;
    }
    .nav-link-user::after {
        display: none !important;
    }
    .nav-link-user + .navbar-dropdown {
        position: absolute !important;
        background: #fff !important;
        border: 1px solid rgba(0,0,0,0.1) !important;
        box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15) !important;
        border-radius: 8px !important;
    }
    .nav-link-user + .navbar-dropdown .dropdown-item {
        color: #212529 !important;
    }
    .nav-link-user + .navbar-dropdown .dropdown-item:hover {
        background: #f8f9fa !important;
        color: #212529 !important;
    }
    .nav-link-user + .navbar-dropdown .dropdown-item i {
        color: #6c757d !important;
    }
    .nav-link-user + .navbar-dropdown .dropdown-header {
        color: #212529 !important;
    }
    .nav-link-user + .navbar-dropdown .dropdown-divider {
        border-color: #e5e7eb !important;
    }
    .nav-link-user + .navbar-dropdown .text-danger-emphasis {
        color: var(--bs-danger) !important;
    }
    .nav-inbox-toggle i {
        font-size: 1.3rem !important;
    }
    .dev-banner-mobile-hide {
        display: none !important;
    }
    .navbar-modern .navbar-collapse {
        padding: 0.5rem 0 0.75rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        margin-top: 0.5rem;
    }
    .navbar-modern .nav-link {
        padding: 0.55rem 0.75rem;
        border-radius: 8px;
    }
    .navbar-modern .navbar-nav.gap-1 {
        gap: 0.15rem !important;
    }
    .nav-link-user {
        border-radius: 8px !important;
    }
    .navbar-dropdown {
        border: none;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.06);
        border-radius: 8px;
    }
    .navbar-dropdown .dropdown-item {
        color: rgba(255, 255, 255, 0.8);
    }
    .navbar-dropdown .dropdown-item:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }
    .navbar-dropdown .dropdown-item i {
        color: rgba(255, 255, 255, 0.6);
    }
    .navbar-dropdown .dropdown-header {
        color: rgba(255, 255, 255, 0.6);
    }
    .navbar-dropdown .dropdown-divider {
        border-color: rgba(255, 255, 255, 0.1);
    }
    .navbar-dropdown .text-danger-emphasis {
        color: rgba(255, 255, 255, 0.8) !important;
    }
}

/* ── Sidebar Navigation ──────────────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    bottom: 0;
    width: var(--sidebar-width);
    background: #fff;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid #e5e7eb;
}

.sidebar-menu {
    list-style: none;
    padding: 1.5rem 0.5rem 0.5rem;
    margin: 0;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    color: var(--navbar-bg, var(--bs-primary));
    font-size: 1.05rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s, background-color 0.15s;
    margin-bottom: 2px;
    white-space: nowrap;
}

.sidebar-link i {
    font-size: 1.3rem;
    color: var(--navbar-bg, var(--bs-primary));
    opacity: 0.6;
    width: 1.4rem;
    text-align: center;
}

.sidebar-link:hover {
    color: var(--navbar-bg, var(--bs-primary));
    background-color: rgba(var(--navbar-bg-rgb, var(--bs-primary-rgb)), 0.06);
    text-decoration: none;
}

.sidebar-link:hover i {
    opacity: 0.85;
}

.sidebar-link.active {
    color: var(--navbar-bg, var(--bs-primary));
    background-color: rgba(var(--navbar-bg-rgb, var(--bs-primary-rgb)), 0.1);
    font-weight: 600;
}

.sidebar-link.active i {
    opacity: 1;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1035;
}

/* Sidebar bottom section */
.sidebar-bottom {
    padding: 0 0.5rem 0.5rem;
    border-top: 1px solid #e5e7eb;
    margin-top: auto;
}

/* Sidebar toggle button */
.sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    width: 100%;
    border: none;
    border-radius: 6px;
    background: none;
    color: #9ca3af;
    font-size: 1.05rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
    white-space: nowrap;
}

.sidebar-toggle i {
    font-size: 1.3rem;
    width: 1.4rem;
    text-align: center;
}

.sidebar-toggle:hover {
    color: #6b7280;
    background-color: #f3f4f6;
}

/* Collapsed sidebar */
.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-toggle span {
    display: none;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 0.6rem;
}

.sidebar.collapsed .sidebar-toggle {
    justify-content: center;
    padding: 0.6rem;
}

.sidebar.collapsed .sidebar-menu {
    padding: 0.5rem 0.35rem;
}

.sidebar.collapsed .sidebar-bottom {
    padding: 0 0.35rem 0.5rem;
}

.sidebar.collapsed ~ .content-wrapper {
    margin-left: 60px;
}

/* Sidebar collapsed tooltips */
.sidebar-tooltip {
    position: fixed;
    background: #1f2937;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 1060;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-tooltip.show {
    opacity: 1;
}

/* ── Sidebar Collapsible Groups ───────────────────── */
.sidebar-group-toggle {
    cursor: pointer;
}

.sidebar-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    opacity: 0.4;
}

.sidebar-group.open > .sidebar-group-toggle .sidebar-chevron {
    transform: rotate(90deg);
}

.sidebar-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.sidebar-group.open > .sidebar-group-items {
    max-height: 500px;
}

.sidebar-group-items .sidebar-link {
    padding-left: 2.2rem;
    font-size: 0.95rem;
}

.sidebar-group-items .sidebar-link i {
    font-size: 1.1rem;
}

/* Collapsed sidebar: expand groups inline (icons only) */
.sidebar.collapsed .sidebar-chevron {
    display: none;
}

.sidebar.collapsed .sidebar-group.open > .sidebar-group-items {
    max-height: 500px;
}

/* ── Content wrapper (sidebar offset) ────────────── */
.content-wrapper {
    margin-left: var(--sidebar-width);
    padding-top: 56px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Transitions enabled only after JS has set the initial state */
.sidebar.sidebar-ready {
    transition: width 0.2s ease;
}
.sidebar.sidebar-ready ~ .content-wrapper {
    transition: margin-left 0.2s ease;
}

/* ── Sidebar mobile rules ────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar-backdrop.show {
        display: block;
    }
    .content-wrapper {
        margin-left: 0;
    }
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bs-primary) 0%, var(--bs-primary-dark) 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

/* General */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Navbar customization */
.navbar-brand {
    font-weight: 600;
    padding: 0.35rem 0;
}

/* Card improvements */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    font-weight: 500;
}

/* Table improvements */
.table th {
    font-weight: 600;
    white-space: nowrap;
}

/* Badge improvements */
.badge {
    font-weight: 500;
}

/* Form controls */
.form-label {
    font-weight: 500;
}

/* Calendar styles */
.fc-event {
    border-radius: 3px;
    padding: 2px 4px;
}

.fc-toolbar-title {
    font-size: 1.25rem !important;
}

/* Status colors */
.status-scheduled { background-color: var(--bs-primary); }
.status-checked-out { background-color: #ffc107; }
.status-completed { background-color: #198754; }
.status-cancelled { background-color: #6c757d; }
.status-no-show { background-color: #dc3545; }

/* Currency status */
.currency-current { color: #198754; }
.currency-expiring { color: #ffc107; }
.currency-expired { color: #dc3545; }

/* Balance colors */
.balance-positive { color: #198754; }
.balance-negative { color: #dc3545; }
.balance-zero { color: #6c757d; }

/* Quick action buttons */
.btn-action {
    min-width: 100px;
}

/* ── Mobile responsive adjustments ────────────────── */

/* Tablets and below (≤768px) */
@media (max-width: 768px) {
    .table-responsive .table {
        font-size: 0.875rem;
    }

    .card-body {
        padding: 1rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    /* Filter bars: stack vertically */
    .d-flex.flex-wrap.gap-3,
    .d-flex.gap-3.align-items-end {
        flex-direction: column;
        align-items: stretch !important;
    }

    .d-flex.flex-wrap.gap-3 > *,
    .d-flex.gap-3.align-items-end > * {
        min-width: 100% !important;
    }
}

/* Phones (≤576px) */
@media (max-width: 576px) {
    /* -- Modals -- */
    /* Constrain large modals to near-full-width on phones */
    .modal-lg .modal-content,
    .modal-xl .modal-content {
        margin: 0;
    }
    .modal-lg,
    .modal-xl {
        max-width: calc(100vw - 1rem);
        margin-left: auto;
        margin-right: auto;
    }

    /* Let date/time inputs fill available width instead of fixed 120px */
    .modal-body input[style*="max-width: 120px"],
    .modal-body select[style*="max-width: 120px"],
    .modal-body input[style*="max-width:120px"],
    .modal-body select[style*="max-width:120px"] {
        max-width: 100% !important;
    }

    /* Modal body padding - reduce on small screens */
    .modal-body {
        padding: 0.75rem;
    }

    .modal-header {
        padding: 0.75rem;
    }

    .modal-footer {
        padding: 0.5rem 0.75rem;
    }

    /* -- Touch targets -- */
    /* Ensure small buttons are large enough for touch (min 36px) */
    .btn-sm {
        min-height: 36px;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }

    /* Action buttons in tables/cards - ensure tappable */
    .btn-sm.py-0 {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
        min-height: 32px;
    }

    /* -- Tables -- */
    .table-responsive .table {
        font-size: 0.8rem;
    }

    .table th, .table td {
        padding: 0.35rem 0.4rem;
    }

    /* -- Cards -- */
    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.5rem 0.75rem;
    }

    /* -- Headings -- */
    h5 {
        font-size: 1.1rem;
    }

    /* -- Forms -- */
    .form-control-sm, .form-select-sm {
        font-size: 0.85rem;
    }

    /* -- Page container -- */
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* -- Login page -- */
    .login-card {
        padding: 1.5rem;
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }

    /* -- Dropdowns -- */
    .dropdown-menu {
        min-width: auto !important;
        max-width: calc(100vw - 2rem);
    }

    /* Calendar filter dropdowns */
    .filter-menu {
        min-width: auto !important;
        max-width: calc(100vw - 2rem);
    }

    /* -- Stat cards -- */
    .stat-card .stat-value {
        font-size: 1.25rem;
    }

    .stat-card .stat-label {
        font-size: 0.7rem;
    }

    /* -- Tabs -- */
    .nav-tabs {
        font-size: 0.85rem;
    }

    .nav-tabs .nav-link {
        padding: 0.4rem 0.6rem;
    }

    /* -- Badge sizing -- */
    .badge {
        font-size: 0.65rem;
    }

    /* -- Profile photo cropper modal -- */
    #cropperModal .modal-body {
        padding: 0.5rem;
    }
}

/* ── MX Module Styles ────────────────────────────── */

/* Sidebar badge positioning */
.sidebar-link.position-relative .badge {
    line-height: 1;
}

/* Collapsed sidebar: hide badge text */
.sidebar.collapsed .sidebar-link .badge {
    position: static !important;
    display: inline-block;
    margin-left: 0;
    font-size: 0.5rem !important;
    padding: 0.15em 0.35em !important;
}

/* MX filter bar responsive */
@media (max-width: 768px) {
    .card-body.d-flex.flex-wrap.gap-2 {
        flex-direction: column;
        align-items: stretch !important;
    }
    .card-body.d-flex.flex-wrap.gap-2 > div {
        width: 100%;
    }
    .card-body.d-flex.flex-wrap.gap-2 input,
    .card-body.d-flex.flex-wrap.gap-2 select {
        max-width: 100% !important;
    }

    /* Date preset buttons: wrap nicely */
    .d-flex.flex-wrap.gap-1 .date-preset {
        flex: 0 0 auto;
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    /* MX tables horizontal scroll smoothness */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    /* Inspection matrix scroll */
    .matrix-cell {
        width: 28px;
        height: 28px;
        font-size: 0.55rem;
    }
}

@media (max-width: 576px) {
    /* Stat card value reduction on small screens (already in base) */
    .stat-card .stat-sub {
        font-size: 0.65rem;
    }

    /* Date presets even smaller on phones */
    .date-preset {
        font-size: 0.65rem !important;
        padding: 0.15rem 0.4rem !important;
    }
}

/* Print styles */
@media print {
    .navbar, .btn, .no-print, .sidebar, .sidebar-backdrop {
        display: none !important;
    }

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

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* Loading spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* HTMX loading indicator */
.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

/* Squawk severity */
.squawk-grounding {
    border-left: 4px solid #dc3545;
}

.squawk-normal {
    border-left: 4px solid #ffc107;
}

/* Stripe Elements */
#card-element {
    min-height: 40px;
}

/* Footer */
.footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* List group enhancements */
.list-group-item-action:hover {
    background-color: #f8f9fa;
}

/* Breadcrumb */
.breadcrumb {
    background: none;
    padding: 0;
    margin-bottom: 0.5rem;
}

/* Alert dismissible button fix */
.alert-dismissible .btn-close {
    padding: 1rem;
}

/* User Form Styles */
.user-form .card {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
}

.user-form .card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.user-form .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
}

.user-form .card-header h6 {
    font-weight: 600;
    color: #333;
}

.user-form .input-group-text {
    background-color: #f8f9fa;
    border-right: none;
    color: #6c757d;
}

.user-form .input-group .form-control {
    border-left: none;
}

.user-form .input-group .form-control:focus {
    border-color: #ced4da;
    box-shadow: none;
}

.user-form .input-group:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.15);
    border-radius: 0.375rem;
}

.user-form .input-group:focus-within .input-group-text {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.user-form .input-group:focus-within .form-control {
    border-color: var(--bs-primary);
}

/* Setup option cards */
.setup-option {
    display: block;
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    background-color: #fff;
    color: #6c757d;
}

.setup-option i {
    color: #adb5bd;
    transition: color 0.2s ease;
}

.setup-option small {
    color: #6c757d;
}

.setup-option:hover {
    border-color: var(--bs-primary);
    background-color: #fff;
}

.setup-option:hover i {
    color: var(--bs-primary);
}

.btn-check:checked + .setup-option {
    border-color: var(--bs-primary);
    background-color: var(--bs-primary);
    color: #fff;
}

.btn-check:checked + .setup-option i {
    color: #fff;
}

.btn-check:checked + .setup-option small {
    color: rgba(255, 255, 255, 0.8);
}

/* Form switch styling */
.user-form .form-switch {
    padding-left: 3rem;
}

.user-form .form-switch .form-check-input {
    width: 2.5rem;
    height: 1.25rem;
    margin-left: -3rem;
    cursor: pointer;
}

.user-form .form-switch .form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.user-form .form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Password field transition */
#passwordField {
    transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
    overflow: hidden;
    max-height: 300px;
    opacity: 1;
}

#passwordField.hidden {
    opacity: 0;
    max-height: 0;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Role checkbox cards */
.role-option {
    display: block;
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    background-color: #fff;
    color: #6c757d;
    min-height: 70px;
}

.role-option i {
    color: #adb5bd;
    transition: color 0.2s ease;
}

.role-option .role-description {
    color: #6c757d;
    font-size: 0.75rem;
    line-height: 1.2;
}

.role-option:hover {
    border-color: var(--bs-primary);
    background-color: #fff;
}

.role-option:hover i {
    color: var(--bs-primary);
}

.btn-check:checked + .role-option {
    border-color: var(--bs-primary);
    background-color: var(--bs-primary);
    color: #fff;
}

.btn-check:checked + .role-option i {
    color: #fff;
}

.btn-check:checked + .role-option .role-description {
    color: rgba(255, 255, 255, 0.8);
}

/* Role validation error state */
#roleSelectionContainer.is-invalid .role-option {
    border-color: #dc3545;
}

#roleValidationError {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}
