:root {
    --bottom-nav-height: 4rem;
    --bottom-buttons-height: 0.75rem;
    --total-bottom-height: calc(var(--bottom-nav-height) + var(--bottom-buttons-height));
    --primary-color: #8A2A2B;
    --secondary-color: #E2E8F0;
    /* Enhanced contrast text colors */
    --text-secondary: #475569;
    --text-muted: #64748B;
}

/* Global box-sizing to prevent overflow from padding */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    position: relative;
}

/* Enhanced button styles */
.btn {
    position: relative;
    min-height: 44px;
    padding: 0.5rem 1rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease-in-out, opacity 0.1s ease-in-out;
}

.btn.active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn.disabled {
    opacity: 0.65;
    pointer-events: none;
}

.btn-outline-primary.active {
    background-color: #8A2A2B !important;
    color: white !important;
    border-color: #8A2A2B !important;
}

.btn-outline-primary {
    color: #8A2A2B;
    border-color: #8A2A2B;
    transition: all 0.2s ease-in-out;
}

.btn-group {
    flex-wrap: nowrap;
}

/* Icon alignment in buttons */
.icon-small {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    display: inline-block;
    margin-right: 4px;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary.active {
    background-color: #8A2A2B;
    color: #fff;
    border-color: #8A2A2B;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(138, 42, 43, 0.2);
}

.btn-outline-primary:active {
    background-color: #6F2223 !important;
    color: #fff !important;
    border-color: #6F2223 !important;
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(138, 42, 43, 0.2);
}

.btn-danger.btn-sm {
    min-width: 80px; /* Prevents shrinking */
}

/* Ensure loading state maintains width */
.btn-danger.btn-sm.btn-loading {
    min-width: 80px;
    padding-left: 0;
    padding-right: 0;
}

/* Loading state enhancements */
.btn-loading {
    position: relative;
    pointer-events: none;
    /* Only pin width when we captured the button's real pre-loading width
       (set on .btn elements via initializeButtons / on submit). The old
       `100px` fallback ballooned small icon buttons that never had the var
       set — content is hidden with visibility:hidden, which already
       preserves the button's natural width, so no fallback is needed. */
    min-width: var(--original-width);
}

/* Maintain 100% width for w-100 buttons during loading */
.btn-loading.w-100 {
    width: 100% !important;
    min-width: unset;
}

.btn-loading > * {
    visibility: hidden;
}

.btn:active::after {
    display: none;
}

/* Or if needed, be more specific */
.fixed-bottom-buttons .btn-outline-secondary:active::after {
    display: none;
}

.btn-outline-secondary:active,
.btn-outline-secondary:active {
    background-color: #e9ecef !important;
    color: #fff !important;
    border-color: #6c757d !important;
 }

/* For the submit button */
.btn-success:active,
.btn-success.active {
    --bs-btn-active-color: #fff !important;
}

.accordion-button:not(.collapsed) {
    color: #fff;
    background-color: #8A2A2B;
    box-shadow: inset 0 calc(-1 * var(--bs-accordion-border-width)) 0 var(--bs-accordion-border-color);
}

.accordion-button:not(.collapsed)::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.btn-loading::after {
    content: '';
    position: absolute;
    left: calc(50% - 0.5rem);
    top: calc(50% - 0.5rem);
    width: 1rem;
    height: 1rem;
    border: 2px solid #fff;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spinner 0.75s linear infinite;
    visibility: visible;
}

.btn-outline-secondary.btn-loading::after {
    border-color: #ffffff;
    border-right-color: transparent;
}

.btn-primary.btn-loading {
    background-color: #8A2A2B !important;
}

.btn-danger.btn-loading {
    background-color: #dc3545 !important;
}

.btn-secondary.btn-loading {
    background-color: #F2A900 !important;
}

.btn-outline-primary.btn-loading {
    background-color: #8A2A2B !important;
    color: transparent !important;
}

.btn-outline-secondary.btn-loading {
    background-color: #6c757d !important;
    color: transparent !important;
}

.btn-outline-danger.btn-loading {
    background-color: #dc3545 !important;
    color: transparent !important;
}

.btn-outline-danger.btn-loading::after {
    border-color: #fff;
    border-right-color: transparent;
}

.btn-primary.btn-loading::after {
    border-color: #fff;
    border-right-color: transparent;
}

@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

/* Fixed bottom buttons enhancement */
.fixed-bottom-buttons {
    padding: 0.5rem;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.fixed-bottom-buttons .btn {
    margin: 0 0.25rem;
    min-width: 100px;
}

/* Change primary button background color */
.btn-primary {
    background-color: #8A2A2B !important; /* Custom color fill */
    border-color: #8A2A2B !important;    /* Match border color */
}

/* Override .btn-sm outline-primary color */
.btn-outline-primary {
    color: #8A2A2B; /* Change the text color to your primary color */
    border-color: #8A2A2B; /* Match the border color */
}

.btn-outline-primary:not(:active) {
    background-color: transparent;
    color: #8A2A2B;
}

/* Adjust small button size */
.btn-sm {
    padding: 4px 10px; /* Adjust padding to match your other buttons */
    font-size: 0.875rem; /* Ensure consistency */
    border-radius: 4px; /* Match border radius */
}

/* Optional: Change hover and focus styles */
.btn-primary:hover,
.btn-primary:focus {
    background-color: #6F2223 !important; /* Darker shade for hover */
    border-color: #6F2223 !important;
}

/* Change secondary button styles */
.btn-secondary {
    background-color: #F2A900 !important; /* Custom secondary color */
    border-color: #F2A900 !important;
    color: #fff !important;              /* Ensure contrast */
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: #D89000 !important; /* Darker shade for hover */
    border-color: #D89000 !important;
}

button:active, a:active {
    transform: scale(0.95); /* Shrinks the button slightly */
    opacity: 0.8; /* Reduces opacity */
}

/* Change checkbox border color */
input[type="checkbox"] {
    accent-color: #8A2A2B; /* This works in most modern browsers */
}

#loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* For browsers that don't support accent-color */
input[type="checkbox"]:checked {
    background-color: #8A2A2B; /* Custom background for checked state */
    border-color: #8A2A2B; /* Match border color */
}

/* Custom focus shadow */
input[type="checkbox"]:focus {
    outline: none; /* Remove default outline */
    box-shadow: 0 0 5px 2px rgba(138, 42, 43, 0.5); /* Lighter shadow */
}

/* Override Bootstrap's background image and color for checked radio buttons */
.form-check-input:checked[type="radio"] {
    background-color: #8A2A2B !important; /* Set custom fill color */
    border-color: #8A2A2B !important;    /* Set custom border color */
}

/* Optional: Customize hover effect */
.form-check-input[type="radio"]:hover {
    border-color: #6F2223; /* Darker border color on hover */
}

/* Optional: Focus state customization */
.form-check-input[type="radio"]:focus {
    outline: none;
    box-shadow: 0 0 5px 2px rgba(138, 42, 43, 0.5); /* Light focus shadow */
}

@media screen {
    body {
        margin: 0;
        padding: 0;
        background:
            radial-gradient(1100px 600px at -10% -20%, #FCE7E7 0%, transparent 55%),
            radial-gradient(800px 500px at 110% 10%, #FFF1D6 0%, transparent 60%),
            linear-gradient(180deg, #FAF7F4 0%, #F2F3F5 100%);
        background-attachment: fixed;
    }
}

@media print {
    body { background: #fff !important; }
    .home-widget, .home-stat-card, .home-quick-action { background: #fff !important; backdrop-filter: none !important; box-shadow: none !important; }
}

.table-responsive {
    overflow-x: auto;
}


.card-body {
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

#crewForm {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.employee-list-container {
    flex: 1;
    overflow-y: auto;
    margin-bottom: calc(var(--bottom-buttons-height) + 1rem);
    /* Add padding at the bottom to prevent content from being cut off */
    padding-bottom: 1rem;
}

.list-group {
    margin-bottom: 0;
}

.app-container {
    min-height: 100vh;
    padding-bottom: var(--total-bottom-height);
    position: relative;
    overflow-x: hidden;
    max-width: 100%;
}

.main-content {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0rem;
    padding-bottom: calc(var(--total-bottom-height) + 1rem);
    overflow-x: hidden;
    box-sizing: border-box;
}

/* ==========================================================================
   Full-Height Layout Fix
   When pages use full-height containers (CRUD, timesheets, review, wizard,
   crew builder), remove the extra padding that causes scroll-past-content issues.
   ========================================================================== */

/* Remove padding from app-container when full-height layouts are present */
.app-container:has(.crud-container),
.app-container:has(.ts-container),
.app-container:has(.review-container),
.app-container:has(.wiz-container),
.app-container:has(.crew-builder),
.app-container:has(.sr-viewport-contained) {
    padding-bottom: 0;
    overflow: hidden;
    height: 100vh;
}

/* Remove padding from main-content when full-height layouts are present */
.main-content:has(.crud-container),
.main-content:has(.ts-container),
.main-content:has(.review-container),
.main-content:has(.wiz-container),
.main-content:has(.crew-builder),
.main-content:has(.sr-viewport-contained) {
    padding-bottom: 0;
    height: calc(100vh - env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Prevent body scroll on full-height layout pages */
body:has(.crud-container),
body:has(.ts-container),
body:has(.review-container),
body:has(.wiz-container),
body:has(.crew-builder),
body:has(.sr-viewport-contained) {
    overflow: hidden;
}

body.dev-mode-active .app-container:has(.crud-container),
body.dev-mode-active .app-container:has(.ts-container),
body.dev-mode-active .app-container:has(.review-container),
body.dev-mode-active .app-container:has(.wiz-container),
body.dev-mode-active .app-container:has(.crew-builder),
body.dev-mode-active .app-container:has(.sr-viewport-contained) {
    height: calc(100vh - 32px);
}

body.dev-mode-active .main-content:has(.crud-container),
body.dev-mode-active .main-content:has(.ts-container),
body.dev-mode-active .main-content:has(.review-container),
body.dev-mode-active .main-content:has(.wiz-container),
body.dev-mode-active .main-content:has(.crew-builder),
body.dev-mode-active .main-content:has(.sr-viewport-contained) {
    height: calc(100vh - 32px - env(safe-area-inset-bottom, 0px));
}

/* Mobile dev banner is smaller (28px) */
@media (max-width: 480px) {
    body.dev-mode-active .app-container:has(.crud-container),
    body.dev-mode-active .app-container:has(.ts-container),
    body.dev-mode-active .app-container:has(.review-container),
    body.dev-mode-active .app-container:has(.wiz-container),
    body.dev-mode-active .app-container:has(.crew-builder),
    body.dev-mode-active .app-container:has(.sr-viewport-contained) {
        height: calc(100vh - 28px);
    }

    body.dev-mode-active .main-content:has(.crud-container),
    body.dev-mode-active .main-content:has(.ts-container),
    body.dev-mode-active .main-content:has(.review-container),
    body.dev-mode-active .main-content:has(.wiz-container),
    body.dev-mode-active .main-content:has(.crew-builder),
    body.dev-mode-active .main-content:has(.sr-viewport-contained) {
        height: calc(100vh - 28px - env(safe-area-inset-bottom, 0px));
    }
}

/* Ensure no horizontal overflow on mobile */
@media (max-width: 767px) {
    .main-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100vw !important;
    }
}

/* Logo styling */
.logo {
    width: 50px;
    height: auto;
    border-radius: 4px;
}

/* App title styling */
.app-title {
    font-family: 'Roboto', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #8A2A2B;
    margin: 0;
    line-height: 1.2;
}

/* Tagline styling */
.app-tagline {
    font-family: 'Roboto', sans-serif;
    font-size: 1rem;
    color: var(--text-secondary, #475569);
    margin: 0;
    margin-top: 0.25rem; /* Space between title and tagline */
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
    padding-bottom: env(safe-area-inset-bottom);
    /* Fix iOS Safari scroll jumping - force GPU layer */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.bottom-nav svg {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted, #64748B);
    padding: 0.5rem 0.25rem;
    transition: color 0.3s ease;
    flex: 1;
    min-width: 0;
    text-align: center;
}

/* Reset button styles for nav-item buttons */
button.nav-item {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.nav-item span {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Smaller text on very narrow screens */
@media (max-width: 360px) {
    .nav-item span {
        font-size: 0.65rem;
    }
}

.nav-item i,
.nav-item svg {
    width: 1.5rem !important;
    height: 1.5rem !important;
    min-width: 1.5rem;
    max-width: 1.5rem;
    min-height: 1.5rem;
    max-height: 1.5rem;
    flex-shrink: 0;
    display: block;
}

.nav-item.active {
    color: var(--primary-color);
    font-weight: 600;
    position: relative;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2.5rem;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px 3px 0 0;
}

.nav-item.active i,
.nav-item.active svg {
    stroke-width: 2.5;
}

/* Loading state for nav items */
.nav-item-loading {
    opacity: 0.6;
}

/* PWA-specific adjustments for iOS safe areas */
@media (display-mode: standalone) {
    .bottom-nav {
        /* Additional padding for PWA mode on iOS */
        padding-bottom: max(env(safe-area-inset-bottom), 0.5rem);
    }
}

/* More Menu Bottom Sheet */
.more-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.more-menu-overlay.active {
    opacity: 1;
    visibility: visible;
    touch-action: none;
}

.more-menu-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 1rem 1rem 0 0;
    z-index: 1101;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

.more-menu-sheet.active {
    transform: translateY(0);
}

.more-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: white;
}

.more-menu-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.more-menu-content {
    padding: 0.5rem 0;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    color: #374151;
    text-decoration: none;
    transition: background 0.15s;
}

.more-menu-item:hover,
.more-menu-item:active {
    background: #f3f4f6;
    color: #374151;
    text-decoration: none;
}

.more-menu-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    flex-shrink: 0;
}

.more-menu-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.5rem 0;
}

.more-menu-section-title {
    padding: 0.75rem 1.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Hide more menu on desktop - direct link works there */
@media (min-width: 769px) {
    .more-menu-overlay,
    .more-menu-sheet {
        display: none !important;
    }

    .bottom-nav button.nav-item {
        /* Convert button back to link behavior on desktop */
        cursor: pointer;
    }
}

/* ==========================================================================
   Desktop sidebar layout: hide bottom nav, shift main content right
   ========================================================================== */
@media (min-width: 769px) {
    /* Bottom nav is replaced by the sidebar on desktop */
    .bottom-nav {
        display: none !important;
    }

    /* Zero out bottom-nav reservation so full-height containers
       (.crud-container, .ts-container, .wiz-container, .review-container,
       .crew-builder, .sr-viewport-contained) fill the viewport instead of
       leaving a 4rem strip of body color at the bottom. */
    .app-container.has-sidebar {
        padding-bottom: 0;
        --bottom-nav-height: 0px;
        --total-bottom-height: 0px;
    }

    /* Shift main content right of the sidebar and shrink to fit the remaining viewport */
    .app-container.has-sidebar .main-content {
        margin-left: var(--app-sidebar-width, 260px);
        width: calc(100% - var(--app-sidebar-width, 260px));
        max-width: calc(100% - var(--app-sidebar-width, 260px));
        min-height: 100vh;
        padding-bottom: 1rem;
        transition: margin-left 0.2s ease, width 0.2s ease, max-width 0.2s ease;
    }

    .sidebar-collapsed .app-container.has-sidebar .main-content {
        margin-left: var(--app-sidebar-collapsed-width, 64px);
        width: calc(100% - var(--app-sidebar-collapsed-width, 64px));
        max-width: calc(100% - var(--app-sidebar-collapsed-width, 64px));
    }

    /* Full-height layouts fill the viewport with no bottom padding —
       restore the original .main-content:has(.crud-container) {padding-bottom: 0}
       intent that the broader .has-sidebar rule above otherwise overrides. */
    .app-container.has-sidebar .main-content:has(.crud-container),
    .app-container.has-sidebar .main-content:has(.ts-container),
    .app-container.has-sidebar .main-content:has(.review-container),
    .app-container.has-sidebar .main-content:has(.wiz-container),
    .app-container.has-sidebar .main-content:has(.crew-builder),
    .app-container.has-sidebar .main-content:has(.sr-viewport-contained) {
        padding-bottom: 0;
    }

    /* Dev banner shrinks the visible viewport — keep main-content matching it */
    body.dev-mode-active .app-container.has-sidebar .main-content {
        min-height: calc(100vh - 32px);
    }

    /* Action button bar sits flush at the bottom, right of the sidebar */
    .app-container.has-sidebar .fixed-bottom-buttons {
        left: var(--app-sidebar-width, 260px);
        right: 0;
        width: auto;
        bottom: 0;
        transform: none;
        transition: left 0.2s ease;
    }

    .sidebar-collapsed .app-container.has-sidebar .fixed-bottom-buttons {
        left: var(--app-sidebar-collapsed-width, 64px);
    }

    /* Sidebar replaces the global back button on desktop */
    body.logged-in .global-back-btn {
        display: none;
    }

    /* .ts-preview-header is position:sticky inside .main-content, which is
       already shifted by the sidebar — its default width: 100% fits naturally.
       No override needed (an extra margin-left here would double-shift it). */

    /* position:fixed bars escape the parent's constraints, so they need an
       explicit left offset to stop overlapping the sidebar. */
    .app-container.has-sidebar .ts-preview-actions,
    .app-container.has-sidebar .summary-bar,
    .app-container.has-sidebar .wiz-bottom {
        left: var(--app-sidebar-width, 260px);
        right: 0;
        transition: left 0.2s ease;
    }

    .sidebar-collapsed .app-container.has-sidebar .ts-preview-actions,
    .sidebar-collapsed .app-container.has-sidebar .summary-bar,
    .sidebar-collapsed .app-container.has-sidebar .wiz-bottom {
        left: var(--app-sidebar-collapsed-width, 64px);
    }

    /* Floating ts-view-back-btn (inside preview) collides with the sidebar — sidebar
       provides navigation, so suppress it on desktop. */
    .app-container.has-sidebar .ts-view-back-btn {
        display: none !important;
    }

    /* Wizard summary-sidebar (.sr-sidebar) uses position: sticky with top: 80px,
       which can introduce a visible top offset inside the now-constrained
       main-content. Force top-alignment to the grid row instead. */
    .app-container.has-sidebar .sr-sidebar {
        align-self: start;
        position: relative;
        top: 0;
    }
}

.sticky-header {
    position: sticky;
    top: 0;
    width: 100%;
    background: white;
    /* Exact height match with .app-sidebar-header so the bottom border
       lines up horizontally with the sidebar header border. */
    min-height: 71px;
    box-sizing: border-box;
    padding: 0 20px;
    flex-shrink: 0; /* Don't shrink in flex containers */
    margin: -1rem 0 0;  /* Offset parent padding */
    z-index: 100;
    border-bottom: 1px solid #f0f2f4;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Sticky header with stepper: title (if any) inline-left, stepper takes the
   rest of the row. Compact so the whole band stays ~64px tall, matching the
   sidebar header line. */
.sticky-header:has(.stepper-wrapper) {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
}

.sticky-header:has(.stepper-wrapper) .stepper-wrapper {
    flex: 1;
}

.sticky-header h2 {
    margin-bottom: 1rem;
    margin-left: 0.5rem;
}

.sticky-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    color: #1a1d21;
}

/* When the stepper is the only thing in the header (no title — unified),
   it spans full width. */
.sticky-header:not(:has(h3)) .stepper-wrapper {
    flex: 1;
}

.sticky-header .progress {
    height: 1rem;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

/* Add some shadow when scrolled */
.sticky-header.scrolled {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Cards */
.card {
    border: none;
    border-radius: 1rem;
    background-color: #f8fafc; 
    margin-bottom: 1rem;
    
}

.card-header {
    background: white;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 1rem 1rem 0 0 !important;
}

.fixed-bottom-buttons {
    position: fixed;
    bottom: var(--bottom-nav-height);
    left: 0;
    right: 0;
    padding: 0.5rem;
    z-index: 900;
    width: 100%;
    display: flex;
    justify-content: center;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.fixed-bottom-buttons:empty {
    display: none;
}

/* While the on-screen keyboard is open (touch devices), hide the fixed
   action bar. iOS otherwise re-anchors it above the keyboard, overlapping
   page content like the task/job search dropdowns. Toggled in scripts.js. */
body.keyboard-open .fixed-bottom-buttons {
    display: none;
}

.fixed-bottom-buttons .d-flex {
    width: 100%;
    max-width: 100%;
    padding: 0 1rem;
}

/* Hours input styling */
.hours-input {
    width: 100% !important;
    text-align: center;
    padding: 0.375rem 0.25rem;
}

.employee-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    height: 100%;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Responsive Design */
@media (min-width: 768px) {

    :root {
        --content-width: 768px;
    }

    .hours-input {
        width: 100% !important;
    }

    .fixed-bottom-buttons {
        left: 50%;
        transform: translateX(-50%);
    }

    .bottom-nav {
        width: 100%;
        left: 50%;
        transform: translateX(-50%);
    }

    .signature-container {
        max-width: 100%;  /* Ensure container doesn't exceed screen width */
        overflow: hidden;  /* Hide any overflow */
    }
    
    .signature-wrapper {
        width: 100%;  /* Fill container width */
        max-width: 100%;  /* Don't exceed container */
    }

    .signature-pad {
        width: 100%;  /* Fill wrapper width */
    }

    .table td, .table th {
        white-space: nowrap;
        padding: 0.5rem;
    }
    
    /* Allow description to wrap but with ellipsis */
    .table td.text-truncate {
        max-width: 150px !important;
    }
    
    /* Make filters stack nicely on mobile */
    .d-flex.gap-2 {
        width: 100%;
    }
}

/* Management Grid Layout */
@media (min-width: 992px) {
    .management-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }

    .management-grid .btn {
        height: 100%;
        display: flex;
        align-items: center;
        padding: 1.5rem;
    }
}

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
}



.branch-section {
    background-color: var(--secondary-color);
    border-radius: 1rem;
    padding: 1rem;
}

.branch-section h5 {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Button Icon Alignment */
.btn i {
    margin-right: 0.5rem;
}

/* Badge Counter */
.badge.bg-danger {
    position: relative;
    top: -1px;
}
.modal-footer {
    flex-wrap: nowrap !important;
    padding: 0.75rem !important;
}

.modal-footer .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    white-space: nowrap;
}
/* Print Formatting*/
@media print {
    body {
        padding: 0;
        background: white !important;
    }
    .card {
        border: none !important;
    }
    .no-print {
        display: none !important;
    }
    .print-border {
        border: 1px solid #dee2e6 !important;
    }
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 100px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.toggle-slider:before {
    position: absolute;
    content: "NO";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    width: 45px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 2px;
    color: #666;
}

.toggle-icon {
    transition: transform 0.2s ease-in-out;
    color: #8A2A2B;
}
.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

input:checked + .toggle-slider {
    background-color: #8A2A2B;
}

input:checked + .toggle-slider:before {
    transform: translateX(47px);
    content: "YES";
    color: #8A2A2B;
}

.form-separator {
    border: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 1.5rem 0;
}

.label-100px {
    display: inline-block; /* Ensures the width is respected */
    width: 110px;         /* Set the desired width */
}

/* Progress Bar Styles */



.stepper-wrapper {
    display: flex;
    justify-content: space-between;
    position: relative;
}

/* Connecting line behind all steps */
.stepper-wrapper::before {
    content: "";
    position: absolute;
    top: 14px;
    left: 10%;
    right: 10%;
    height: 3px;
    background-color: #e0e0e0;
    border-radius: 2px;
    z-index: 0;
}

/* Ensure counters appear above the line */
.stepper-counter {
    z-index: 1;
}


.stepper-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.stepper-counter {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e0e0e0;
    margin-bottom: 3px;
    color: #fff;
    font-weight: 500;
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}



.stepper-wrapper a {
    text-decoration: none;
    color: inherit;
}

/* Active state */
.stepper-item.active .stepper-counter {
    background-color: #8A2A2B;
}

/* Completed state */
.stepper-item.completed .stepper-counter {
    background-color: #F2A900;  
}

.stepper-item.completed .stepper-counter::after {
    content: "✓";  /* Checkmark */
    color: white;
}

.stepper-item.completed .stepper-counter span {
    display: none;  /* Hide the number when showing checkmark */
}

.stepper-title {
    color: #333;
    font-size: 0.85rem;
    margin-top: 0;
    line-height: 1.15;
}

/* Active title */
.stepper-item.active .stepper-title {
    color: #8A2A2B;
    font-weight: 500;
}

.signature-container {
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    background-color: #f8f9fa;
    margin-bottom: 1rem;
    position: relative; /* Keep this */
}

/* Signature box and wrapper */
.signature-wrapper {
    position: relative;  /* For absolute positioning of canvas */
    width: 100%;
    margin: 0;
    padding: 0;
}

.signature-pad {
    border: 1px solid #adb5bd;
    border-radius: 4px;
    touch-action: none;
    background-color: white;
    width: 100%;
    height: 120px;
    margin: 0;  /* Remove any margin */
    display: block;  /* Ensure block display */
}

/* Status banner styling */
.signature-status {
    position: absolute;
    top: 0.025rem;
    right: 1.25rem;
    margin: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    background-color: #ffc107;
    color: #000;
    z-index: 2;  /* Ensure it's above other elements */
    max-width: 50%;  /* Prevent too wide status messages */
    white-space: nowrap;  /* Keep text on one line */
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Ensure buttons don't affect layout */
.signature-buttons {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    position: relative;  /* Keep buttons in normal flow */
}

.signature-status.signature-complete {
    background-color: #198754;
    color: white;
}

/* Style the employee name header */
.signature-container h6 {
    color: #495057;
    margin-bottom: 0.5rem;  /* Reduced margin */
    font-size: 1rem;  /* Slightly smaller */
    padding-right: 90px;  /* Room for status */
}

/* Add spacing between signature containers */
.col:not(:last-child) .signature-container {
    margin-bottom: 0.75rem;
}

.info-label {
    color: var(--text-secondary, #475569);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.info-value {
    font-weight: 500;
}

.section-divider {
    height: 1px;
    background-color: #dee2e6;
    margin: 1.5rem 0;
}

.status-badge {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    border-radius: 50rem;
}

.progress {
    height: 1rem;
    border-radius: 0.25rem;
}

.progress-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    background-color: var(--primary-color);
    transition: width .6s ease;
}

.progress-bar.w-0 { width: 0; }
.progress-bar.w-10 { width: 10%; }
.progress-bar.w-20 { width: 20%; }
.progress-bar.w-30 { width: 30%; }
.progress-bar.w-40 { width: 40%; }
.progress-bar.w-50 { width: 50%; }
.progress-bar.w-60 { width: 60%; }
.progress-bar.w-70 { width: 70%; }
.progress-bar.w-80 { width: 80%; }
.progress-bar.w-90 { width: 90%; }
.progress-bar.w-100 { width: 100%; }

.offline #offline-indicator {
    display: block !important;
}

.offline .requires-online {
    opacity: 0.5;
    pointer-events: none;
}

.offline-badge {
    display: none;
}

.offline .offline-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background-color: #ffc107;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

/* Add smooth transitions for offline state changes */
.requires-online {
    transition: opacity 0.3s ease;
}

/* Style for elements that should be hidden when offline */
.offline .online-only {
    display: none !important;
}

/* Style for elements that should only show when offline */
.offline-only {
    display: none;
}

.offline .offline-only {
    display: block;
}

.theme-arrow {
    color: #8A2A2B; /* Set the arrow color to match your theme */
    transition: color 0.2s ease-in-out; /* Smooth color transition on hover */
}

.theme-arrow:hover {
    color: #F2A900; /* Optional hover color for better interactivity */
    text-decoration: none; /* Ensure no underline on hover */
}

.notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    text-align: center;
    padding: 1rem;
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
}

.notification.show {
    transform: translateY(0);
}

.notification.warning {
    background-color: #fff3cd;
    color: #856404;
}

.notification.info {
    background-color: #cce5ff;
    color: #004085;
}

.notification.success {
    background-color: #d4edda;
    color: #155724;
}

.notification.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* ==========================================================================
   Toast Notifications (Global)
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: calc(100% - 2rem);
    pointer-events: none;
}

@media (max-width: 576px) {
    .toast-container {
        top: 1rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #6B7280;
    min-width: 280px;
    max-width: 400px;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

@media (max-width: 576px) {
    .toast {
        min-width: auto;
        max-width: none;
        transform: translateY(-100%);
    }
    .toast.show {
        transform: translateY(0);
    }
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    border-left-color: #10B981;
}

.toast-success .toast-icon {
    color: #10B981;
}

.toast-error {
    border-left-color: #EF4444;
}

.toast-error .toast-icon {
    color: #EF4444;
}

.toast-warning {
    border-left-color: #F59E0B;
}

.toast-warning .toast-icon {
    color: #F59E0B;
}

.toast-info {
    border-left-color: #3B82F6;
}

.toast-info .toast-icon {
    color: #3B82F6;
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    color: #1F2937;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: #9CA3AF;
    transition: color 0.15s ease;
}

.toast-close:hover {
    color: #4B5563;
}

.toast-close i {
    width: 16px;
    height: 16px;
}

.cursor-pointer {
    cursor: pointer;
}
.hover\:bg-gray-100:hover {
    background-color: #f8f9fa;
}
.job-result {
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.job-result:hover,
.job-result:focus,
.job-result.highlighted {
    outline: none;
    background-color: #f0f0f0;
}
.job-result.highlighted {
    background-color: #e8e8e8;
}

/* Clear button for search inputs */
.btn-clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.btn-clear-search:hover {
    background-color: #e9ecef;
    color: #495057;
}
.btn-clear-search:focus {
    outline: none;
    background-color: #dee2e6;
}

.customer-name {
    color: #8A2A2B !important;  /* This appears to be your theme's maroon color */
}

.input-group .customer-autocomplete {
    width: auto !important;
    flex: 1 1 auto;
}

.suggestion-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background-color: #f8f9fa;
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
}

.suggestion-item:hover, .suggestion-item.active {
    background-color: #dddfe1;
}

.clear-customer {
    display: none;
}

.col-md-3 .input-group {
    width: 100%;
    max-width: 100%;
}

/* ============================================
   ONBOARDING WIZARD STEPPER
   ============================================ */

/* Wizard header */
.wizard-header {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.wizard-header .btn-link {
    font-size: 0.9rem;
}

.wizard-header .btn-link:hover {
    color: #8A2A2B !important;
}

.stepper-wizard {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 0;
    padding: 0.5rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Single continuous line behind all steps */
/* 8px padding + 15px (half of 30px circle) - 2px (half of 4px line) = 21px */
.stepper-wizard::before {
    content: "";
    position: absolute;
    top: 21px;
    left: 7%;
    right: 7%;
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
}

.stepper-wizard::-webkit-scrollbar {
    display: none;
}

/* Ensure stepper items don't shrink */
.stepper-wizard .stepper-item {
    flex: 1 0 auto;
    min-width: 80px;
}

/* Skipped step (gray with dash) */
.stepper-item.skipped .stepper-counter {
    background-color: #6c757d;
}

.stepper-item.skipped .stepper-counter::after {
    content: "-";
    color: white;
}

.stepper-item.skipped .stepper-counter span {
    display: none;
}

/* Optional step indicator - no special styling, keep consistent */

/* Disabled/locked step - still visible but not clickable */
.stepper-item.disabled {
    pointer-events: none;
    cursor: not-allowed;
}

/* Count badge on steps */
.stepper-item .badge-count {
    font-size: 0.65rem;
    margin-top: 2px;
    padding: 2px 6px;
}

/* Mobile adjustments - keep in single row but smaller */
@media (max-width: 768px) {
    .stepper-wizard .stepper-item {
        min-width: 60px;
    }

    .stepper-wizard .stepper-title {
        font-size: 0.65rem;
        white-space: nowrap;
    }

    .stepper-wizard .stepper-counter {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
    }

    /* Adjust line position for smaller counters (26px circles) */
    /* 8px padding + 13px (half of 26px) - 1.5px (half of 3px) = 19.5px */
    .stepper-wizard::before {
        top: 19.5px;
        height: 3px;
    }
}

/* Wizard content area */
.wizard-content {
    padding: 1rem;
    padding-bottom: calc(var(--bottom-nav-height) + 100px);
}

/* Step card styling */
.wizard-step-card {
    border: 1px solid #dee2e6;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.wizard-step-card .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem;
    border-radius: 12px 12px 0 0;
}

.wizard-step-card .card-body {
    padding: 1.5rem;
}

/* Tab styling for entry method selection */
.wizard-tabs {
    border-bottom: 1px solid #dee2e6;
}

.wizard-tabs .nav-link {
    color: #6c757d;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem 1.25rem;
    margin-bottom: -1px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.wizard-tabs .nav-link.active {
    color: #8A2A2B;
    border-bottom-color: #8A2A2B;
    background: transparent;
}

.wizard-tabs .nav-link:hover:not(.active) {
    color: #8A2A2B;
    border-bottom-color: #dee2e6;
}

/* Recent items list */
.recent-items-list {
    max-height: 200px;
    overflow-y: auto;
}

.recent-items-list .list-group-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

/* Import results styling */
.import-results {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    background-color: #f8f9fa;
}

/* Fixed bottom buttons for wizard - improved */
.wizard-bottom-buttons {
    position: fixed;
    bottom: var(--bottom-nav-height);
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    z-index: 900;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.wizard-bottom-buttons .d-flex {
    max-width: 100%;
}

.wizard-bottom-buttons .btn {
    padding: 0.75rem 1rem;
    font-weight: 500;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wizard-bottom-buttons .flex-fill {
    flex: 1 1 0;
    min-width: 0;
}

.wizard-bottom-buttons form.flex-fill {
    display: flex;
}

.wizard-bottom-buttons form.flex-fill .btn {
    flex: 1;
}

/* ============================================
   PERMISSIONS CHECKBOX GRID
   ============================================ */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.625rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
}

.permission-item {
    position: relative;
    padding: 0;
    background: white;
    border-radius: 0.5rem;
    border: 2px solid #e9ecef;
    transition: all 0.2s ease;
    margin: 0;
    overflow: hidden;
}

.permission-item:hover {
    border-color: #8A2A2B;
    box-shadow: 0 2px 8px rgba(138, 42, 43, 0.1);
}

.permission-item:has(.form-check-input:checked) {
    border-color: #8A2A2B;
    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
    box-shadow: 0 2px 8px rgba(138, 42, 43, 0.15);
}

.permission-item .form-check-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 2;
}

.permission-item .form-check-label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.8125rem;
    color: #495057;
    margin: 0;
    width: 100%;
}

.permission-item .form-check-label::before {
    content: '';
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #dee2e6;
    border-radius: 0.375rem;
    background: white;
    transition: all 0.2s ease;
}

.permission-item:has(.form-check-input:checked) .form-check-label::before {
    background: #8A2A2B;
    border-color: #8A2A2B;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}

.permission-item:has(.form-check-input:checked) .form-check-label {
    color: #8A2A2B;
    font-weight: 600;
}

.permission-item:hover .form-check-label::before {
    border-color: #8A2A2B;
}

/* Mobile: 2 columns */
@media (max-width: 576px) {
    .permissions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .permission-item .form-check-label {
        padding: 0.5rem 0.625rem;
        font-size: 0.75rem;
        gap: 0.5rem;
    }

    .permission-item .form-check-label::before {
        width: 18px;
        height: 18px;
    }
}

/* Tablet: 3 columns */
@media (min-width: 577px) and (max-width: 991px) {
    .permissions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Desktop: auto-fill with min 200px */
@media (min-width: 992px) {
    .permissions-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

/* Permissions badges in tables */
.permissions-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    max-width: 400px;
}

.permissions-badges .badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35em 0.65em;
    white-space: nowrap;
}

.permissions-cell {
    min-width: 200px;
    max-width: 450px;
}

@media (max-width: 768px) {
    .permissions-badges {
        max-width: 250px;
    }

    .permissions-badges .badge {
        font-size: 0.7rem;
    }

    .permissions-cell {
        min-width: 150px;
        max-width: 280px;
    }
}

/* ============================================
   GLOBAL BACK BUTTON (Desktop/Tablet only)
   ============================================ */
.global-back-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 950;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    transition: all 0.2s ease;
}

.global-back-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(138, 42, 43, 0.25);
}

.global-back-btn:active {
    transform: translateY(0) scale(0.95);
}

.global-back-btn i,
.global-back-btn svg {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
    stroke-width: 2.5;
    transition: color 0.2s ease;
}

.global-back-btn:hover i,
.global-back-btn:hover svg {
    color: white;
}

/* Show only on tablet and desktop (>= 768px) */
@media (min-width: 768px) {
    .global-back-btn {
        display: flex;
    }

    /* Center page header titles on desktop to work with back button */
    .crud-header,
    .crew-builder-header,
    .ts-header,
    .review-header,
    .card-header,
    .card-header > .d-flex,
    .page-header-top,
    .main-content > .d-flex:first-child {
        position: relative;
        min-height: 3rem;
    }

    .crud-header h2,
    .crew-builder-header h2,
    .ts-header h2,
    .review-header h2,
    .card-header > h2,
    .card-header > .d-flex > h2,
    .page-header-title,
    .main-content > .d-flex:first-child > h2 {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
        white-space: nowrap;
    }

    /* Hide subtitle text on sticky-header pages (behind back button) */
    .sticky-header > p,
    .page-header-subtitle {
        display: none;
    }

    /* Center h3 on sticky-header pages WITHOUT steppers */
    .sticky-header:not(:has(.stepper-wrapper)) {
        position: relative;
        min-height: 3.5rem;
        padding-left: 0;
    }

    .sticky-header:not(:has(.stepper-wrapper)) > h3 {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        margin: 0;
        top: 1rem;
        white-space: nowrap;
    }

    /* Keep header actions right-aligned when h2 is absolutely positioned */
    .crud-header-actions,
    .crew-builder-header-actions,
    .ts-header-actions,
    .review-header-actions,
    .page-header-actions,
    .card-header > .d-flex > .d-flex,
    .main-content > .d-flex:first-child > .d-flex {
        margin-left: auto;
    }

    /* Add left padding to stats strip to avoid back button */
    .stats-strip {
        padding-left: 70px;
    }

    /* Add left padding to sticky-header for back button clearance */
    .sticky-header {
        padding-left: 70px;
    }
}

/* ===== Percent Complete Slider Component ===== */
.percent-complete-wrapper {
    width: 100%;
}

.percent-slider-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.percent-input-box {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.percent-input-field {
    width: 60px;
    height: 38px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    padding: 0 6px;
    -moz-appearance: textfield;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.percent-input-field::-webkit-outer-spin-button,
.percent-input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.percent-input-field:focus {
    outline: none;
    border-color: #8b1538;
    box-shadow: 0 0 0 3px rgba(139, 21, 56, 0.1);
}

.percent-symbol-label {
    font-size: 1rem;
    font-weight: 700;
    color: #64748b;
    margin-left: 2px;
}

.percent-range-slider {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    min-width: 100px;
}

.percent-range-slider::-webkit-slider-runnable-track {
    height: 8px;
    background: linear-gradient(to right,
        #8b1538 0%,
        #8b1538 var(--slider-progress, 0%),
        #e2e8f0 var(--slider-progress, 0%),
        #e2e8f0 100%);
    border-radius: 4px;
}

.percent-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border: 3px solid #8b1538;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    margin-top: -6px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.percent-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.percent-range-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.15);
    background: #f8f9fa;
}

.percent-range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #ffffff;
    border: 3px solid #8b1538;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.percent-range-slider::-moz-range-track {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
}

.percent-range-slider::-moz-range-progress {
    height: 8px;
    background: #8b1538;
    border-radius: 4px;
}

.percent-tick-marks {
    display: none;
    justify-content: space-between;
    margin-top: 4px;
    padding: 0 10px 0 0;
}

.percent-tick-marks span {
    font-size: 0.65rem;
    font-weight: 500;
    color: #94a3b8;
}

/* Mobile: Show tick marks beneath slider */
@media (max-width: 576px) {
    .percent-tick-marks {
        display: flex;
    }

    .percent-slider-row {
        gap: 0.5rem;
    }

    .percent-input-field {
        width: 55px;
        height: 36px;
        font-size: 0.95rem;
    }

    .percent-range-slider {
        min-width: 80px;
    }
}

/* ============================================
   RESPONSIVE PAGE HEADER
   ============================================ */
.page-header {
    background: #ffffff;
    border-radius: 12px 12px 0 0;
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Top row: title + actions */
.page-header-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-header-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    letter-spacing: -0.02em;
    flex: 1;
    min-width: 0;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Action buttons styling */
.page-header-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 8px;
    white-space: nowrap;
    min-height: 40px;
    transition: all 0.15s ease;
}

.page-header-actions .btn i,
.page-header-actions .btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Filter bar container */
.page-header-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: stretch;
}

.page-header-filters .search-group {
    flex: 1;
    min-width: 200px;
}

.page-header-filters .filter-group {
    flex-shrink: 0;
}

/* Search input styling */
.page-header-filters .form-control {
    border-radius: 8px;
    border: 1.5px solid #e2e8f0;
    padding: 0.5rem 0.875rem;
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    min-height: 42px;
}

.page-header-filters .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(138, 42, 43, 0.1);
}

.page-header-filters .form-control::placeholder {
    color: #94a3b8;
}

/* Input group styling */
.page-header-filters .input-group {
    border-radius: 8px;
    overflow: hidden;
}

.page-header-filters .input-group .form-control {
    border-radius: 8px 0 0 8px;
}

.page-header-filters .input-group .btn {
    border-radius: 0 8px 8px 0;
    min-width: 44px;
    padding: 0 0.75rem;
}

.page-header-filters .input-group .input-group-text {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-right: none;
    padding: 0 0.75rem;
}

/* Date filter with icon */
.page-header-filters .date-filter-group {
    display: flex;
    align-items: center;
}

.page-header-filters .date-filter-group .input-group-text {
    border-radius: 8px 0 0 8px;
    min-height: 42px;
}

.page-header-filters .date-filter-group .form-control {
    border-radius: 0;
    border-left: none;
    min-width: 140px;
}

.page-header-filters .date-filter-group .btn {
    border-radius: 0 8px 8px 0;
    border-left: none;
}

/* Fix for JS date-input-wrapper inside input-groups */
.page-header-filters .date-filter-group .date-input-wrapper {
    position: relative;
    display: flex;
    flex: 1;
}

.page-header-filters .date-filter-group .date-input-wrapper::before {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    pointer-events: none;
}

.page-header-filters .date-filter-group .date-input-wrapper input[type="date"] {
    flex: 1;
    border-radius: 0;
    border-left: none;
}

/* Toggle filters styling */
.page-header-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
}

.page-header-toggles .form-check {
    margin: 0;
}

.page-header-toggles .form-check-label {
    font-size: 0.875rem;
    color: #64748b;
    cursor: pointer;
}

/* ===== Mobile Responsive (< 576px) ===== */
@media (max-width: 575.98px) {
    .page-header {
        padding: 0.875rem;
    }

    .page-header-top {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .page-header-title {
        text-align: center;
        font-size: 1.25rem;
    }

    .page-header-actions {
        justify-content: center;
        width: 100%;
    }

    /* Stack buttons on very small screens */
    .page-header-actions .btn {
        flex: 1;
        padding: 0.5rem 0.5rem;
        font-size: 0.8125rem;
    }

    /* Show abbreviated text on mobile */
    .page-header-actions .btn .btn-text-full {
        display: none;
    }

    .page-header-actions .btn .btn-text-short {
        display: inline;
    }

    /* Filters stack vertically */
    .page-header-filters {
        flex-direction: column;
    }

    .page-header-filters .search-group,
    .page-header-filters .filter-group {
        width: 100%;
        min-width: 0;
    }

    .page-header-filters .date-filter-group .form-control {
        min-width: 0;
        flex: 1;
    }

    .page-header-toggles {
        justify-content: center;
    }
}

/* ===== Tablet+ (>= 576px) ===== */
@media (min-width: 576px) {
    .page-header-actions .btn .btn-text-full {
        display: inline;
    }

    .page-header-actions .btn .btn-text-short {
        display: none;
    }
}

/* ===== Desktop adjustments (>= 768px) ===== */
@media (min-width: 768px) {
    .page-header {
        padding: 1.25rem 1.5rem;
    }

    .page-header-title {
        font-size: 1.5rem;
    }

    .page-header-actions .btn {
        padding: 0.5rem 1rem;
    }

    .page-header-filters .search-group {
        min-width: 300px;
    }
}

/* Utility: display contents (for form wrapper that shouldn't affect layout) */
.d-contents {
    display: contents;
}

/* Page header subtitle */
.page-header-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted, #64748B);
    margin: 0;
    margin-top: -0.25rem;
}

/* ===== Staging Environment Banner ===== */
.staging-banner {
    position: sticky;
    top: 0;
    z-index: 10001; /* above the dev-mode banner */
    display: flex;
    align-items: center;
    gap: 8px;
    background: repeating-linear-gradient(45deg, #b45309, #b45309 12px, #a04808 12px, #a04808 24px);
    color: #fff;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-align: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.staging-banner strong { font-weight: 800; letter-spacing: 0.08em; }
.staging-banner-text { opacity: 0.95; }
.staging-banner-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #fde68a; box-shadow: 0 0 0 2px rgba(253,230,138,0.35);
}
@media (max-width: 576px) {
    .staging-banner-text { display: none; }
}

/* ===== Dev Mode Banner ===== */
.dev-mode-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: #18181b;
    color: #fafafa;
    padding: 0 12px;
    height: 32px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
    letter-spacing: -0.01em;
    border-bottom: 1px solid #3f3f46;
}

.dev-mode-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 100%;
    flex-wrap: nowrap;
    overflow: hidden;
}

.dev-mode-banner-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    color: #a78bfa;
    white-space: nowrap;
    flex-shrink: 0;
}

.dev-mode-banner-label svg {
    flex-shrink: 0;
}

.dev-mode-banner-info {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.dev-mode-banner-item {
    display: flex;
    align-items: center;
    gap: 3px;
    background: #27272a;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    border: 1px solid #3f3f46;
    min-width: 0;
}

.dev-mode-banner-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.dev-mode-banner-item span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.dev-mode-banner-exit {
    background: transparent;
    border: 1px solid #52525b;
    color: #a1a1aa;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-family: inherit;
    margin-left: auto;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.dev-mode-banner-exit:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.dev-mode-banner-exit svg {
    flex-shrink: 0;
}

/* Adjust body padding when dev mode banner is shown */
body.dev-mode-active {
    padding-top: 32px;
}

/* Adjust fixed detail panels when dev mode banner is shown */
body.dev-mode-active .ts-detail.active,
body.dev-mode-active .crud-detail.active {
    top: 32px;
}

/* Mobile: ultra-compact single line */
@media (max-width: 480px) {
    .dev-mode-banner {
        padding: 0 8px;
        height: 28px;
        font-size: 11px;
    }

    .dev-mode-banner-content {
        gap: 4px;
    }

    .dev-mode-banner-label {
        gap: 3px;
    }

    /* Hide "Dev Mode" text, show only icon */
    .dev-mode-banner-label span {
        display: none;
    }

    .dev-mode-banner-info {
        gap: 3px;
    }

    .dev-mode-banner-item {
        padding: 2px 6px;
        font-size: 10px;
        gap: 2px;
    }

    .dev-mode-banner-item svg {
        width: 10px !important;
        height: 10px !important;
    }

    .dev-mode-banner-exit {
        padding: 2px 6px;
        font-size: 10px;
        gap: 2px;
    }

    .dev-mode-banner-exit span {
        display: none;
    }

    body.dev-mode-active {
        padding-top: 28px;
    }

    /* Adjust fixed detail panels for smaller banner on mobile */
    body.dev-mode-active .ts-detail.active,
    body.dev-mode-active .crud-detail.active {
        top: 28px;
    }
}

/* Dev Mode section in profile */
.dev-mode-section {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border: 1px solid #c4b5fd;
    border-radius: 8px;
    padding: 1rem;
}

.dev-mode-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.75rem;
    color: #7c3aed;
    font-weight: 600;
}

.dev-mode-section-header svg {
    width: 18px;
    height: 18px;
}

.dev-mode-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.dev-mode-control {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dev-mode-control label {
    font-size: 0.8125rem;
    color: #6b7280;
    font-weight: 500;
}

.dev-mode-control select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #c4b5fd;
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
}

.dev-mode-control select:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* Required-field validation highlight (e.g. new-task description on entry steps) */
.field-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}