/**
 * Reusable Components
 * Cards, buttons, badges, forms, and other UI components
 */

/* === CARDS === */
.card {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
    border: none;
    background-color: var(--bg-card);
}

.card-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0 !important;
}

.card-body {
    padding: var(--spacing-lg);
}

/* Navigation Cards */
.nav-card {
    height: 100%;
    text-align: center;
    padding: 25px 15px;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.nav-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    color: var(--primary-color);
    text-decoration: none;
}

.nav-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    color: var(--primary-color);
}

.nav-title {
    font-size: 1.2rem;
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--spacing-sm);
}

.nav-description {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* === BUTTONS ===
   Interactive feel: lift + soft shadow on hover, press-down on click. Applies to every .btn
   regardless of variant (including Bootstrap's own untouched variants like .btn-warning/.btn-info),
   since this is the base rule and only transform/transition/shadow are universal — colors are
   only overridden for the specific variants below. */
.btn {
    padding: 0.5rem 1.15rem;
    border-radius: var(--border-radius);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    display: inline-block;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast),
        background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    border: 1px solid transparent;
    cursor: pointer;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-outline-success {
    background-color: transparent;
    color: var(--status-success-text);
    border-color: var(--status-success-text);
}

.btn-outline-success:hover {
    background-color: var(--status-success);
    color: white;
}

.btn-secondary {
    background-color: var(--status-secondary);
    color: white;
    border-color: var(--status-secondary);
}

.btn-secondary:hover {
    background-color: #5a6268;
    border-color: #545b62;
    color: white;
}

.btn-danger {
    background-color: var(--status-danger);
    color: white;
    border-color: var(--status-danger);
}

.btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
    color: white;
}

/* Brand button — the app's actual red identity, used for primary calls-to-action on migrated
   pages (e.g. pageHeader()'s action buttons) without touching --primary-color/.btn-primary,
   which the 6 pre-existing shared-header pages already depend on being Bootstrap-blue. */
.btn-brand {
    background: linear-gradient(135deg, var(--brand-color) 0%, var(--brand-dark) 100%);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(var(--brand-color-rgb), 0.25);
}

.btn-brand:hover:not(:disabled) {
    box-shadow: 0 4px 14px rgba(var(--brand-color-rgb), 0.4);
    color: #fff;
}

.btn-outline-brand {
    background: transparent;
    color: var(--brand-color-text);
    border-color: var(--brand-color-text);
}

.btn-outline-brand:hover:not(:disabled) {
    background: var(--brand-color);
    color: #fff;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: var(--border-radius-xl);
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
}

.bg-primary { background-color: var(--primary-color) !important; }
.bg-success { background-color: var(--status-success) !important; }
.bg-warning { background-color: var(--status-warning) !important; }
.bg-danger { background-color: var(--status-danger) !important; }
.bg-secondary { background-color: var(--status-secondary) !important; }

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: var(--border-radius-xl);
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
}

/* Small colored-initials avatar for a person's display name - emitted by the app-wide
   avatarHtml() (includes/avatar.php) / AppUtils.avatarHtml() (assets/js/common.js) helpers.
   Piloted 2026-08-13 in modules/sales-call (dashboard leaderboard/map, weekly report team-status
   board), promoted here app-wide 2026-08-14 so any module can call the helper and get a
   correctly-styled badge with no per-module CSS of its own. */
.avatar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

/* Period-over-period trend badge next to a stat value - emitted by the app-wide trendHtml()
   (includes/trend.php) / AppUtils.trendHtml() (assets/js/common.js) helpers. Semantic red/green/
   muted, not the stat card's own icon color - a trend answers "better or worse than before", a
   different question than the card's own identity color. Piloted 2026-08-13 in modules/sales-call
   as .sales-trend, promoted here app-wide 2026-08-14 once modules/meeting-room needed it too. */
.trend-badge {
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.trend-up { color: var(--status-success-text); }
.trend-down { color: var(--status-danger-text); }
.trend-flat { color: var(--text-muted); }

/* Subtle staggered entrance for a row of cards on first paint - fades/slides in instead of
   popping onto the page all at once. Runs once on load only (plain CSS animation, not re-applied
   on data refresh), so it never re-triggers on pull-to-refresh or filter changes. Piloted
   2026-08-13 in modules/sales-call as .sales-fade-in-row, promoted here app-wide 2026-08-14 once
   modules/meeting-room needed it too. */
.fade-in-row > [class*="col-"] {
    animation: fade-in-up 0.35s ease-out both;
}

.fade-in-row > [class*="col-"]:nth-child(1) { animation-delay: 0s; }
.fade-in-row > [class*="col-"]:nth-child(2) { animation-delay: 0.06s; }
.fade-in-row > [class*="col-"]:nth-child(3) { animation-delay: 0.12s; }
.fade-in-row > [class*="col-"]:nth-child(4) { animation-delay: 0.18s; }

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .fade-in-row > [class*="col-"] {
        animation: none;
    }
}

/* Room Status Badges */
.status-vacant-ready { background-color: var(--status-vacant-ready); color: white; }
.status-vacant-clean { background-color: var(--status-vacant-clean); color: white; }
.status-vacant-dirty { background-color: var(--status-vacant-dirty); color: white; }
.status-occupied-ready { background-color: var(--status-occupied-ready); color: white; }
.status-occupied-clean { background-color: var(--status-occupied-clean); color: white; }
.status-occupied-dirty { background-color: var(--status-occupied-dirty); color: white; }
.status-maintenance { background-color: var(--status-maintenance); color: white; }
.status-unknown { background-color: var(--status-unknown); color: white; }

/* Room Type Badge */
.roomtype-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: var(--font-weight-medium);
    background-color: #e7f1ff;
    color: var(--primary-color);
    border: 1px solid #b3d9ff;
}

/* Occupancy Badges */
.occ-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: var(--border-radius-xl);
}

.occ-high {
    color: var(--occ-high) !important;;
}

.occ-medium {
    color: var(--occ-medium) !important;;
}

.occ-low {
    color: var(--occ-low) !important;;
}

/* === FORMS === */
.form-control, .form-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-label {
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--spacing-xs);
    display: block;
}

.filter-section {
    background-color: var(--secondary-color);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
}

/* === TABLE CARD / DETAIL CARD ===
   Previously undefined here — every module page hardcoded its own copy of this exact look
   (`border-radius: 15px; padding: 2rem; box-shadow: 0 4px 20px rgba(0,0,0,0.1);`, see e.g.
   maintenance-ticket-list.css/maintenance-parts-view.css) instead of sharing one token-driven
   definition. Values below match what was already hardcoded everywhere (so this is not a visual
   change for existing pages, just a shared source of truth going forward) — a page's own CSS can
   still override, but new pages no longer need to redefine this from scratch. */
.table-card,
.detail-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: var(--shadow-md);
}

/* Date Selector */
.date-selector {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.date-selector label {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 0;
    white-space: nowrap;
}

/* === ALERTS === */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    border: 1px solid transparent;
}

.alert-info {
    background-color: var(--alert-info-bg);
    border-color: var(--alert-info-border);
    color: var(--alert-info-text);
}

.alert-warning {
    background-color: var(--alert-warning-bg);
    border-color: var(--alert-warning-border);
    color: var(--alert-warning-text);
}

.alert-success {
    background-color: var(--alert-success-bg);
    border-color: var(--alert-success-border);
    color: var(--alert-success-text);
}

.alert-danger {
    background-color: var(--alert-danger-bg);
    border-color: var(--alert-danger-border);
    color: var(--alert-danger-text);
}

/* .stats-row wraps the Bootstrap .row.g-3 of .stat-card columns. Spacing to whatever comes next
   (a table-card, a filter-section, ...) has to live here, not on .stat-card's own margin-bottom -
   once .stat-card stretches to height:100% of its (flex-stretched) column, a margin-bottom on the
   card itself no longer reliably produces visible space below the row. */
.stats-row {
    margin-bottom: var(--spacing-lg);
}

/* === STAT CARDS ===
   Modernized in place: same markup contract (.stat-card > .stat-title + .stat-value + .stat-icon)
   so existing pages don't need markup changes, just get a refreshed look — soft shadow instead of
   flat fill, hover lift, a brand-colored accent bar that appears on hover, and the icon repositioned
   as a large low-opacity corner watermark instead of a floated inline icon. */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    position: relative;
    overflow: hidden;
    /* Bootstrap's .row stretches columns to equal height by default, but that stretch stops at
       the column div - without this, a card whose own content happens to be taller (long label,
       wrapped text) still renders shorter/taller than its row siblings. */
    height: 100%;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-color), var(--brand-dark));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    background-color: var(--bg-card);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-xs);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: var(--font-weight-medium);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-color);
}

.stat-icon {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    float: none;
    font-size: 2.25rem;
    opacity: 0.12;
    color: var(--brand-color);
}

/* Occupancy Classes */
.occ-high .stat-value { color: var(--occ-high) !important; }
.occ-medium .stat-value { color: var(--occ-medium) !important; }
.occ-low .stat-value { color: var(--occ-low) !important; }

/* === HEADER CARD (used by pageHeader() in includes/layout/page.php) === */
.header-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl) var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--brand-color);
    transition: padding 0.18s ease;
}

.header-card h1 {
    color: var(--text-color);
    font-weight: var(--font-weight-bold);
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.25rem;
    transition: font-size 0.18s ease;
}

/* Scrolled-past state (assets/js/common.js toggles .is-condensed): shrink the block so the
   sticky sub-nav below isn't riding under a tall title on a long page. Subtitle folds away,
   title steps down a size. Skipped entirely under prefers-reduced-motion (JS opts out). */
.header-card.is-condensed {
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-md);
}

.header-card.is-condensed h1 {
    font-size: 1.3rem;
    margin-bottom: 0;
}

.header-card.is-condensed p {
    display: none;
}

/* Icon-badge treatment for the h1 icon (pageHeader()'s $icon, or a hand-written <i> in a
   page-local header) — a colored rounded chip instead of a bare colored glyph, matching the
   same visual language as the offcanvas nav icons below. */
.header-card h1 i:first-child {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: var(--border-radius);
    background: rgba(var(--brand-color-rgb), 0.1);
    color: var(--brand-color);
    font-size: 1.05rem;
    flex-shrink: 0;
    margin-right: 0 !important;
}

/* === PRIORITY BADGE === */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--border-radius-pill);
    font-weight: var(--font-weight-semibold);
    font-size: 0.75rem;
    color: #fff;
    text-transform: uppercase;
}

.priority-badge {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.priority-low { background: var(--status-success); }
.priority-medium { background: var(--status-warning); }
.priority-high { background: var(--status-danger); }
.priority-urgent {
    background: #9c27b0;
    animation: priority-pulse 2s infinite;
}

@keyframes priority-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* === META BADGE ===
   Same size/shape as .priority-badge, for non-priority metadata pills shown alongside it
   (ticket category, assigned engineer, days-open, etc. - see ticket_view.php/ticket_list.php/
   ticket_engineer.php) that previously fell back to Bootstrap's default .badge (different
   padding/radius) or one-off classes like .days-badge, making the same header row look like 3
   unrelated badge systems. Defaults to a neutral fill; add a themed .bg-* class (already
   redefined above to use this app's color tokens) for a semantic variant. */
.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--border-radius-pill);
    font-weight: var(--font-weight-semibold);
    font-size: 0.75rem;
    text-transform: uppercase;
    background: var(--secondary-color);
    color: var(--text-muted);
}

.meta-badge.bg-primary,
.meta-badge.bg-success,
.meta-badge.bg-warning,
.meta-badge.bg-danger,
.meta-badge.bg-secondary {
    color: #fff;
}

/* === APP SHELL (shared navbar + content wrapper, includes/layout/page.php) === */
.app-navbar {
    background: linear-gradient(135deg, var(--brand-color) 0%, var(--brand-dark) 100%) !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    /* Fixed-tier so the bar and its module-switcher dropdown stay above the sticky sub-nav row
       (.module-subnav-wrap, --z-sticky) once a page is scrolled. Bootstrap's .navbar is only
       position:relative with z-index:auto, which lost to the sub-nav's stacking context. The
       offcanvas drawer is rendered as a sibling *after* </nav> (see navbar.php) so this z-index
       doesn't trap it under its own body-level backdrop. */
    position: relative;
    z-index: var(--z-fixed);
}

.app-navbar .navbar-brand {
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.2px;
}

.navbar-brand-logo {
    height: 28px;
    width: 28px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 6px;
    margin-top: -4px;
    /* Same mark as the favicon/manifest icon (assets/images/logo-sm.png) - kept at its own natural
       colors (not recolored to the app's green brand tokens), since this is the actual hotel logo,
       not a UI element. */
    background: #fff;
    border-radius: var(--border-radius-sm);
    padding: 3px;
}

.app-navbar .navbar-toggler {
    border: none;
    box-shadow: none !important;
}

/* Desktop module switcher — jump straight to another module without opening the offcanvas.
   Hidden below lg: the hamburger/offcanvas + the mobile bottom-nav already cover that width. */
.app-module-switch {
    margin-left: 0.75rem;
}

.app-module-switch > .dropdown-toggle {
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    padding: 0.3rem 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 15rem;
}

.app-module-switch > .dropdown-toggle:hover,
.app-module-switch > .dropdown-toggle:focus,
.app-module-switch.show > .dropdown-toggle {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.app-module-switch > .dropdown-toggle > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-module-switch .dropdown-menu {
    max-height: 75vh;
    overflow-y: auto;
    min-width: 15rem;
}

.app-module-switch .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.app-module-switch .dropdown-item i:first-child {
    width: 1.25rem;
    text-align: center;
    color: var(--text-muted);
}

.app-module-switch .dropdown-item.active {
    font-weight: var(--font-weight-semibold);
}

.app-module-switch .dropdown-item.active i:first-child {
    color: inherit;
}

@media (max-width: 991.98px) {
    .app-module-switch {
        display: none !important;
    }
}

/* Shared sizing for the icon-only buttons at the right of the bar (theme, notif bell slot). */
.app-navbar-icon {
    padding: 0.375rem 0.5rem;
    line-height: 1;
}

.app-navbar-icon,
.app-navbar-icon:hover,
.app-navbar-icon:focus {
    color: #fff;
}

.app-navbar-icon:hover,
.app-navbar-icon:focus {
    background: rgba(255, 255, 255, 0.15);
}

/* Live clock, right side of the bar - time only; the full day+date is on its hover title (set by
   assets/js/common.js). Kept off small screens: the mobile bar is tight and the phone's own
   status bar already shows the time. Hidden via its own scoped @media rule rather than a
   d-none/d-md-flex combo - base.css redeclares .d-none last, breaking that combo (Part F). */
.app-nav-clock {
    display: inline-flex;
    align-items: center;
    color: #fff;
    line-height: 1;
    user-select: none;
}

@media (max-width: 767.98px) {
    .app-nav-clock {
        display: none !important;
    }
}

.app-nav-clock-time {
    font-size: 0.9rem;
    font-weight: var(--font-weight-semibold);
    font-variant-numeric: tabular-nums;
}

.app-theme-toggle {
    color: #fff;
    border: none;
    box-shadow: none !important;
    padding: 0.375rem 0.5rem;
    line-height: 1;
}

.app-theme-toggle:hover,
.app-theme-toggle:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

.app-offcanvas {
    background: linear-gradient(180deg, var(--brand-color) 0%, var(--brand-dark) 100%);
    color: #fff;
    max-width: 300px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.25);
}

.app-offcanvas .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    margin-bottom: var(--spacing-sm);
}

.app-offcanvas .nav-link {
    color: rgba(255, 255, 255, 0.85);
    padding: 0.6rem var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    position: relative;
    transition: background-color var(--transition-fast), padding-left var(--transition-fast);
}

.app-offcanvas .nav-link i {
    width: 1.75em;
    height: 1.75em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.12);
    margin-right: var(--spacing-sm);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.app-offcanvas .nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    padding-left: calc(var(--spacing-md) + 4px);
}

.app-offcanvas .nav-link.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-weight: var(--font-weight-semibold);
}

.app-offcanvas .nav-link.active::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: #fff;
    border-radius: 3px;
}

.app-offcanvas .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.25);
}

.app-content {
    max-width: 1800px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

/* === MOBILE BOTTOM TAB BAR (includes/layout/bottom-nav.php) === */
.app-bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-fixed);
    background: var(--bg-card);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0.5rem 0.25rem;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.app-bottom-nav-item i {
    font-size: 1.15rem;
}

.app-bottom-nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-bottom-nav-item.active,
.app-bottom-nav-item:hover {
    color: var(--brand-color);
    text-decoration: none;
}

@media (max-width: 767.98px) {
    .app-bottom-nav {
        display: flex;
    }

    .app-content {
        padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0));
    }
}

/* === RESPONSIVE DATA VIEW: card-list companion for a DataTable (opt-in, see
   assets/js/datatables-helper.js's cardContainer/cardTemplate options). Pages that don't use
   this pattern are unaffected — .dt-desktop-only only hides at mobile width when a page has
   explicitly opted a table wrapper into it. === */
.data-card-list {
    display: none;
}

@media (max-width: 767.98px) {
    .data-card-list {
        display: block;
    }

    .dt-desktop-only {
        display: none;
    }
}

.data-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.data-card:hover,
.data-card:active {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.data-card-body {
    flex: 1;
    min-width: 0;
}

.data-card-title {
    font-weight: var(--font-weight-semibold);
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.data-card-chevron {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* === EMPTY STATE: shared "nothing here yet" block for sections/lists that would otherwise
   render as blank space or a bare foreach with no fallback (e.g. ticket_view.php's Parts
   Used/Cost Summary/Attachments/Timeline/Chat before this). Icon + short muted text, optional
   subtle action link — generic enough to reuse anywhere in the app, not maintenance-specific. */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2rem;
    opacity: 0.35;
    margin-bottom: var(--spacing-sm);
}

.empty-state-text {
    font-size: 0.9rem;
    margin: 0;
}

.empty-state-action {
    display: inline-block;
    margin-top: var(--spacing-sm);
    font-size: 0.85rem;
    color: var(--brand-color);
    text-decoration: none;
}

.empty-state-action:hover {
    text-decoration: underline;
}

/* Subtle entrance animation for the main content blocks — one-shot fade+slide on load, staggered
   across stat-cards so a row of stats animates in like a modern dashboard rather than popping in
   all at once. Safe to apply broadly: `animation: ... both` only runs once on paint, doesn't
   re-trigger, and degrades to nothing (still visible, just no motion) if a browser ignores it. */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-card,
.stat-card,
.table-card,
.detail-card,
.filter-section {
    animation: fadeSlideUp 0.35s ease both;
}

.stat-card:nth-child(1) { animation-delay: 0.02s; }
.stat-card:nth-child(2) { animation-delay: 0.06s; }
.stat-card:nth-child(3) { animation-delay: 0.10s; }
.stat-card:nth-child(4) { animation-delay: 0.14s; }
.stat-card:nth-child(5) { animation-delay: 0.18s; }
.stat-card:nth-child(6) { animation-delay: 0.22s; }
.stat-card:nth-child(n+7) { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
    .header-card, .stat-card, .table-card, .detail-card, .filter-section {
        animation: none;
    }
    .btn:hover:not(:disabled), .stat-card:hover, .nav-card:hover {
        transform: none;
    }
}

@media (max-width: 576px) {
    .app-content {
        padding: var(--spacing-md) var(--spacing-sm);
    }

    .header-card {
        padding: var(--spacing-md);
        border-left-width: 3px;
    }

    .header-card h1 {
        font-size: 1.3rem;
        gap: 0.5rem;
    }

    /* Smaller icon chip on a phone - it was a 2.35rem block eating width next to a wrapping title. */
    .header-card h1 i:first-child {
        width: 1.9rem;
        height: 1.9rem;
        font-size: 0.9rem;
    }

    /* Actions: one horizontally-scrollable row of compact buttons instead of full-width buttons
       stacking into 2-3 rows. pageHeader()'s .header-action-compact "back" button still collapses
       to icon-only (rule further down), so the real page actions get the visible space. */
    .header-card-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        align-self: stretch;
        gap: 0.4rem;
    }

    .header-card-actions::-webkit-scrollbar {
        display: none;
    }

    .header-card-actions .btn {
        flex: 0 0 auto;
        padding: 0.4rem 0.7rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }
}

/* Decorative icon-prefix boxes on form inputs (.input-group-text, used throughout the
   maintenance forms) cost real width on a phone for no functional gain — drop them at mobile
   widths and let the input itself reclaim the space and its own full border-radius. Purely
   additive: only fires if a page's .input-group markup exists, no page-side changes needed. */
@media (max-width: 767.98px) {
    .input-group-text {
        display: none;
    }

    .input-group > .form-control,
    .input-group > .form-select {
        border-left: 1px solid var(--border-color) !important;
        border-radius: var(--border-radius) !important;
    }

    /* Tap-target minimum: iOS HIG/Material both recommend >=44px for anything tappable.
       Bootstrap's default control/button height (~38-40px) and .btn-sm (~31px, used for
       card-list row actions, see design-system.md#card-list-companion) both fall short on a
       phone. Scoped to mobile only so desktop density (already tested) doesn't change. */
    .form-control,
    .form-select,
    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 44px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* === SYNC INFO === */
.sync-info {
    margin-top: var(--spacing-sm);
    font-size: 0.9rem;
    color: var(--text-muted);
    background-color: var(--secondary-color);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
}

.sync-versi-badge {
    display: inline-block;
    background-color: var(--status-success);
    color: white;
    padding: 4px 8px;
    border-radius: var(--border-radius-xl);
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
    margin-left: var(--spacing-sm);
}

/* === RESPONSIVE === */
@media (max-width: 992px) {
    .date-selector {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .nav-card {
        margin-bottom: var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    .card-header h4 {
        font-size: 1.2rem;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    .badge {
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    .card {
        margin-bottom: var(--spacing-md);
    }

    .card-body {
        padding: var(--spacing-sm);
    }
}

/* Internal-only engineering notes (equipment handover notes + ticket internal
   notes, added 2026-08-01) - shared here rather than in a page-specific CSS
   file since both modules/maintenance/inventory_view.php and
   modules/maintenance/ticket_view.php|ticket_engineer.php use it. Amber
   accent is deliberately different from the public ticket-chat bubbles, so
   it reads as visually distinct from anything the requester can also see. */
.internal-notes-card {
    border-left: 4px solid var(--accent-color);
}

.internal-only-badge {
    font-size: 0.65rem;
    vertical-align: middle;
    font-weight: var(--font-weight-normal);
}

.internal-note-item {
    background: var(--accent-light);
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.internal-note-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
}

.internal-note-text {
    font-size: 0.9rem;
    white-space: pre-wrap;
}
/* ===== Module sub-nav (includes/layout/subnav.php) ===== */
/* Desktop: wrap-able pill row (+ dropdown pills for groups). Mobile: one horizontally-scrollable
   pill line (.module-subnav-strip) - a single row that scrolls, not a 6-9 pill wall that wraps
   into 3-4 lines. Both sit inside .module-subnav-wrap, which is sticky so the row stays reachable
   as you scroll a long page. Scoped @media display toggles (NOT `d-none d-md-flex` - base.css
   declares .d-none last, breaking that combo; see docs/pilot-rollout-checklist.md Part F). */
.module-subnav-wrap {
    position: sticky;
    top: 0;
    /* Sticky-tier: above page content, below .app-navbar (--z-fixed) so the navbar's
       module-switcher dropdown isn't clipped behind this row. */
    z-index: var(--z-sticky);
    background: var(--bg-primary);
    margin-bottom: 1rem;
    padding-top: 0.5rem;
}

.module-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.module-subnav-group .dropdown-menu {
    max-height: 70vh;
    overflow-y: auto;
}

.module-subnav-group .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.module-subnav-group .dropdown-item.active {
    font-weight: 600;
}

/* Mobile strip: one line, scrolls horizontally, no visible scrollbar. Pills don't shrink. */
.module-subnav-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
}

.module-subnav-strip::-webkit-scrollbar {
    display: none;
}

.module-subnav-strip .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .module-subnav { display: none !important; }
}

@media (min-width: 768px) {
    .module-subnav-strip { display: none !important; }
}

/* Header-card "back" action: icon-only on a phone so it doesn't consume a row next to the
   page's real primary action. Scoped @media, not d-none utilities (Part F). */
@media (max-width: 575.98px) {
    .header-action-compact .header-action-label {
        display: none;
    }
    .header-action-compact i {
        margin-right: 0 !important;
    }
}
