/* Custom styles for OpticSearch */

:root {
    --sidebar-width: 280px;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ecf0f1;
    --sidebar-hover: #34495e;
    --sidebar-active: #3498db;
}

/* Wrapper */
.wrapper {
    min-height: 100vh;
}

/* Accessibility skip-link: off-screen until keyboard-focused, per standard pattern */
.skip-link {
    position: absolute;
    top: -60px;
    left: 8px;
    z-index: 2000;
    transition: top 0.15s ease-in-out;
}

.skip-link:focus {
    top: 8px;
}

/* Скрываем плавающую кнопку меню, пока открыт offcanvas — иначе она
   перекрывает заголовок офканваса (z-index кнопки был выше офканваса). */
[data-bs-toggle="offcanvas"][aria-expanded="true"] {
    display: none;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar-header {
    background-color: rgba(0, 0, 0, 0.2);
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    padding: 0.75rem 1rem;
    border-radius: 0;
    transition: all 0.3s ease;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background-color: var(--sidebar-active);
    color: #fff;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    background-color: rgba(0, 0, 0, 0.2);
    margin-top: auto;
}

.sidebar-search .form-control {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--sidebar-text);
}

.sidebar-search .form-control:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.sidebar-search .input-group-text {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--sidebar-text);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background-color: #f8f9fa;
}

/* Map legend: offset past the fixed sidebar on desktop so it doesn't render
   on top of the sidebar's own bottom-left links (same left:0/z-index). */
.map-legend {
    left: calc(var(--sidebar-width) + 1rem);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }

    /* Clear the fixed mobile menu button (top-left, base.html), which
       otherwise sits on top of page titles/flash messages. The map page
       (full-bleed #map, own floating controls) is excluded on purpose. */
    .main-content:not(:has(#map)) {
        padding-top: 4rem;
    }

    /* Clear the fixed mobile menu button on top of the map's own
       offline/online status pill. */
    .map-offline-indicator {
        top: 64px !important;
    }

    /* Sidebar is off-canvas here, so the legend no longer needs to dodge it. */
    .map-legend {
        left: 1rem;
    }

    /* On narrow screens the floating info stack (nearest-closure/route cards,
       right:76px + max-width:280px, set inline in map.js) is wide enough to
       overlap the bottom-left legend at the same bottom offset. Push it above
       the legend instead of letting the two collide. !important is required
       to beat the inline styles set from JS. */
    #map-info-stack {
        right: 12px !important;
        bottom: 132px !important;
        max-width: calc(100vw - 24px) !important;
    }
}

/* Dark theme support */
[data-bs-theme="dark"] .main-content {
    background-color: #1a1a1a;
}

/* Map overlays must keep readable contrast in both themes (they use bg-body). */
.map-legend,
#map-info-stack > * {
    color: var(--bs-body-color);
}

/* Map container */
#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Custom marker styles */
.custom-marker {
    background: transparent;
    border: none;
}

.current-location-marker {
    background: transparent;
    border: none;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
}

/* Marker cluster styles */
.marker-cluster-small {
    background-color: rgba(40, 167, 69, 0.6);
}

.marker-cluster-medium {
    background-color: rgba(255, 193, 7, 0.6);
}

.marker-cluster-large {
    background-color: rgba(220, 53, 69, 0.6);
}

/* Floating buttons */
.position-fixed .btn {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

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

/* Status badges (reuse Bootstrap's own semantic color variables) */
.badge-status-active {
    background-color: var(--bs-success);
}

.badge-status-inactive {
    background-color: var(--bs-danger);
}

.badge-status-maintenance {
    background-color: var(--bs-warning);
    color: #000;
}

/* Closures registry (list toolbar: table/card view switch, density, inspector) */
#closureRegistry .registry-table-view,
#closureRegistry .registry-card-view {
    display: none;
}

#closureRegistry[data-view="table"] .registry-table-view {
    display: block;
}

#closureRegistry[data-view="card"] .registry-card-view {
    display: flex;
}

#closureRegistry[data-density="compact"] .registry-table-view td,
#closureRegistry[data-density="compact"] .registry-table-view th {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}

#closureRegistry[data-density="compact"] .registry-card-view .card-body {
    padding: 0.75rem;
}

#closureRegistry[data-density="compact"] .registry-card-view .card-title {
    font-size: 1rem;
}

.closure-inspector-map {
    width: 100%;
    height: 220px;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

/* Flash toasts: top-right on mobile and desktop */
.app-toast-container {
    position: fixed;
    z-index: 1090;
    right: 1rem;
    top: 1rem;
    bottom: auto;
    max-width: min(22rem, calc(100vw - 2rem));
    pointer-events: none;
}

.app-toast-container .toast {
    pointer-events: auto;
    width: 100%;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-left: 4px solid var(--bs-primary) !important;
    overflow: hidden;
}

.app-toast-success { border-left-color: var(--bs-success) !important; }
.app-toast-danger,
.app-toast-error { border-left-color: var(--bs-danger) !important; }
.app-toast-warning { border-left-color: var(--bs-warning) !important; }
.app-toast-info,
.app-toast-debug { border-left-color: var(--bs-info) !important; }

@media (prefers-reduced-motion: reduce) {
    .app-toast-container .toast {
        transition: none !important;
    }
}

