/* Custom navbar optimizations */
.navbar .nav-link {
    padding: 0.5rem 0.75rem;
}

/* Filter Breadcrumbs Styling */
#filterBreadcrumbs {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

#filterBreadcrumbs .breadcrumb {
    background-color: transparent;
    padding: 0;
    margin: 0;
}

#filterBreadcrumbs .breadcrumb-item {
    font-size: 0.9rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#filterBreadcrumbs .breadcrumb-item a,
#filterBreadcrumbs .breadcrumb-item button {
    color: var(--bs-link-color, #6366f1);
    text-decoration: none;
    font-weight: 500;
}

#filterBreadcrumbs .breadcrumb-item a:hover,
#filterBreadcrumbs .breadcrumb-item button:hover {
    text-decoration: underline;
}

#filterBreadcrumbs .breadcrumb-item.active a,
#filterBreadcrumbs .breadcrumb-item.active button {
    color: var(--bs-body-color, #333);
    font-weight: 600;
    pointer-events: none;
    text-decoration: none;
}

#filterBreadcrumbs .breadcrumb-item + .breadcrumb-item::before {
    content: "\203A";
    font-size: 1.2rem;
    color: var(--bs-secondary-color, #999);
    padding: 0 0.5rem;
}

/* Quick Filters Dropdown in Navbar */
#quickFiltersMenu {
    max-height: 60vh;
    overflow-y: auto;
    min-width: 200px;
}

#quickFiltersMenu .dropdown-header {
    font-weight: 600;
    color: #6366f1;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* Ensure icons are visible on all screen sizes */
.navbar .nav-link i.bi {
    display: inline-block;
    vertical-align: middle;
}

/* Smooth transitions for navbar */
.navbar {
    transition: all 0.3s ease;
}

/* Optimize dropdown menu on mobile */
@media (max-width: 991px) {
    .navbar .dropdown-menu {
        position: absolute;
        width: 100%;
        background: var(--surface-color);
        border: 1px solid var(--border-color);
        margin-top: 0;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
    }

    /* Ensure icons have proper spacing on mobile */
    .navbar .nav-link > i {
        width: 24px;
        text-align: center;
    }
}

/* Larger touch targets on mobile */
@media (max-width: 576px) {
    .navbar .nav-item {
        margin: 0;
    }

    .navbar .nav-link {
        padding: 0.75rem;
    }

    /* Show icons only on xs screens */
    .navbar .nav-link i.bi {
        font-size: 1.25rem;
    }
}

/* Mobile: sticky first column on wide tables so users don't lose row context */
@media (max-width: 767.98px) {
    .table-responsive .table thead th:first-child,
    .table-responsive .table tbody td:first-child {
        position: sticky;
        left: 0;
        z-index: 10;
        box-shadow: 2px 0 6px rgba(0,0,0,0.1);
    }
    .table-responsive .table thead th:first-child {
        background: var(--bs-body-bg);
    }
    .table-responsive .table tbody td:first-child {
        background: var(--bs-body-bg);
    }
    /* Dark mode */
    [data-bs-theme="dark"] .table-responsive .table thead th:first-child,
    [data-bs-theme="dark"] .table-responsive .table tbody td:first-child {
        background: var(--bs-body-bg, #212529);
    }
}

/* Global Search Modal */
#globalSearchModal .modal-dialog {
    margin-top: 10vh;
    max-width: 580px;
}
#globalSearchModal .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
#globalSearchModal .modal-header {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
}
#globalSearchInput {
    font-size: 17px;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}
#globalSearchInput:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
#globalSearchFilters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
#globalSearchFilters .form-select {
    font-size: 13px;
    padding: 6px 28px 6px 10px;
    border-radius: 6px;
}
#globalSearchFilters .form-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.search-kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: monospace;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #6b7280;
}

/* Mobile Floating Action Button */
#mobileFab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1040;
}
@media (max-width: 767.98px) {
    #mobileFab {
        display: block;
    }
}
#mobileFabBtn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
#mobileFabBtn:hover, #mobileFabBtn:focus {
    box-shadow: 0 6px 20px rgba(99,102,241,0.5);
    transform: scale(1.05);
    color: #fff;
}
#mobileFab.open #mobileFabBtn {
    transform: rotate(45deg);
}
#mobileFabMenu {
    position: absolute;
    bottom: 62px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#mobileFab.open #mobileFabMenu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.fab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    /* Was a hardcoded #1f2937, which stayed near-black against the dark surface. */
    color: var(--text-primary);
    white-space: nowrap;
}
.fab-item:hover {
    text-decoration: none;
    color: #6366f1;
}
.fab-label {
    background: var(--bs-body-bg);
    padding: 6px 14px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    font-weight: 500;
}
.fab-icon {
    /* Was 42px — below the 44px minimum touch target. */
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    border-radius: 50%;
    background: var(--bs-body-bg);
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #6366f1;
    flex-shrink: 0;
}
.fab-item:hover .fab-icon {
    background: #6366f1;
    color: #fff;
}
#mobileFabOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.2);
    z-index: 1039;
}
#mobileFabOverlay.show {
    display: block;
}

/* Quick Tip Modal */
@media (min-width: 992px) {
    #quickTipModal .modal-dialog {
        position: fixed;
        bottom: 20px;
        right: 20px;
        max-width: 400px;
        margin: 0;
    }
    #quickTipModal .modal-content {
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    }
}
#quickTipModal .quick-tip-icon {
    font-size: 2rem;
    color: var(--primary-color, #0d6efd);
}

/* ============================================
   Skip Link
   Visually hidden until focused, then pinned to the top-left. This is the first
   focusable element in the document so keyboard users can jump the ~40-link navbar.
   ============================================ */
.skip-link {
    position: absolute;
    top: var(--space-skip-link-offset);
    left: var(--space-skip-link-offset);
    z-index: 2000;                      /* above the sticky navbar (1000) and status bars (1060) */
    padding: 12px 20px;
    background: var(--primary-color);
    color: #fff;                        /* literal: must stay readable on the indigo chip in both themes */
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);       /* parked off-screen; not display:none, so it stays focusable */
    transition: transform 0.15s ease;
}
.skip-link:focus {
    transform: translateY(0);
    color: #fff;
}

/* The <main> target takes tabindex="-1" so the skip link actually moves focus.
   Suppress the focus ring it would otherwise draw around the whole page. */
#mainContent:focus {
    outline: none;
}

/* ============================================
   Theme Toggle Icon
   Both icons ship in the markup; CSS reveals one based on [data-theme] set in <head>.
   ============================================ */
.theme-icon--dark {
    display: none;
}
[data-theme="dark"] .theme-icon--light {
    display: none;
}
[data-theme="dark"] .theme-icon--dark {
    display: inline-block;
}

/* ============================================
   Cookie Consent Banner
   ============================================ */
.cookie-consent {
    display: none;                      /* cookie-sync.js flips this to block */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    background: var(--text-primary);    /* dark slate in light theme, light in dark theme */
    color: var(--surface-color);
    padding: 16px 24px;
    /* Clear the iOS home indicator when installed as a PWA. */
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgb(0 0 0 / 0.3);
    font-size: 0.875rem;
    line-height: 1.5;
}
.cookie-consent__link {
    color: var(--primary-light);
    text-decoration: underline;
}
.cookie-consent__accept {
    background: var(--primary-dark);
    color: #fff;                        /* literal: fixed-contrast text on the indigo button */
    border: none;
    padding: 8px 20px;
    min-height: var(--touch-target-min);
    border-radius: var(--radius-xs);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

/* ============================================
   Keyboard Shortcuts Help Button
   ============================================ */
.keyboard-help-btn {
    position: fixed;
    bottom: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 20px;
    z-index: 9990;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    /* Was 42px — below the 44px minimum touch target. */
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--primary-color);
}

/* Keyboard shortcuts are meaningless without a physical keyboard, and on a phone this
   button overlaps the thumb zone the FAB already owns. Hide it on touch-primary devices. */
@media (hover: none) and (pointer: coarse) {
    .keyboard-help-btn {
        display: none;
    }
}

/* ============================================
   Safe-Area handling for the mobile FAB
   ============================================ */
#mobileFab {
    /* Lift the FAB clear of the iOS home indicator in standalone mode. */
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
