/* General Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

/* Tunisie Telecom Blue */
:root {
    --tt-blue: #00426b;
    --tt-light-blue: #0066a1;
    --sidebar-bg: #f8f9fa;
}

/* Disclaimer Banner */
.disclaimer-banner {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    border-bottom: 1px solid #ffeaa7;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
}

/* Container */
.container-fluid {
    padding-top: 45px;
    height: 100vh;
}

.row {
    height: 100%;
    margin: 0;
}

/* Sidebar */
.sidebar {
    background-color: var(--sidebar-bg);
    padding: 20px;
    height: 100%;
    overflow-y: auto;
    border-right: 2px solid var(--tt-blue);
}

.sidebar-content {
    max-width: 100%;
}

/* Card Styling */
.card {
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-header {
    background-color: var(--tt-blue);
    color: white;
    padding: 10px 15px;
}

.card-header h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.card-body {
    padding: 15px;
}

/* Buttons */
.btn {
    border-radius: 5px;
    font-weight: 500;
}

.btn-success {
    background-color: #28a745;
    border-color: #28a745;
}

.btn-success:hover {
    background-color: #218838;
    border-color: #1e7e34;
}

.btn-warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #000;
}

.btn-warning:hover {
    background-color: #e0a800;
    border-color: #d39e00;
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
}

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

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

.btn-primary:hover {
    background-color: var(--tt-light-blue);
    border-color: var(--tt-light-blue);
}

/* Map Container */
.map-container {
    height: 100%;
    position: relative;
}

#map {
    height: 100%;
    width: 100%;
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 30px;
    right: 10px;
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 200px;
    /* position:relative needed so the close button positions inside the legend */
}

.map-legend h6 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--tt-blue);
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
    opacity: 0.7;
    border: 1px solid #ccc;
}

/* Progress Bar */
.progress {
    background-color: #e9ecef;
}

.progress-bar {
    background-color: var(--tt-blue);
    font-size: 14px;
    font-weight: 600;
    transition: width 0.3s ease;
}

/* Form Inputs */
.form-control-sm {
    font-size: 13px;
}

.form-label {
    font-weight: 500;
    margin-bottom: 5px;
}

/* Alert */
.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

/* Table */
.table td {
    padding: 5px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -100%;
        width: 100%;
        height: calc(100% - 45px);
        top: 45px;
        z-index: 1500;
        transition: left 0.3s ease;
        border-right: none;
        box-shadow: 2px 0 8px rgba(0,0,0,0.2);
    }

    .sidebar.show {
        left: 0;
    }

    .map-container {
        width: 100%;
    }

    .map-legend {
        bottom: 10px;
        right: 10px;
        font-size: 12px;
        padding: 10px;
        min-width: 150px;
    }

    .map-legend h6 {
        font-size: 12px;
        margin-bottom: 5px;
    }

    .legend-color {
        width: 15px;
        height: 15px;
        margin-right: 8px;
    }

    .legend-item {
        margin-bottom: 5px;
    }
}

/* Mobile Toggle Button */
.mobile-toggle {
    display: none;
    position: absolute;
    top: 55px;
    left: 10px;
    z-index: 1600;
    background-color: white;
    border: 2px solid var(--tt-blue);
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: block;
    }
}

/* Leaflet Popup Customization */
.leaflet-popup-content {
    margin: 10px;
    font-size: 13px;
}

.leaflet-popup-content h6 {
    margin-bottom: 8px;
    color: var(--tt-blue);
    font-size: 14px;
}

.leaflet-popup-content p {
    margin: 5px 0;
}

.leaflet-popup-content strong {
    color: var(--tt-blue);
}

/* Scrollbar Styling for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--tt-blue);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--tt-light-blue);
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: #fff;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.loading-content p {
    font-size: 16px;
    margin: 0;
    font-weight: 500;
}

/* Sidebar Backdrop (mobile) */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1400;
    background: rgba(0, 0, 0, 0.35);
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Per-request status */
#currentRequestStatus {
    font-size: 12px;
    color: var(--tt-blue);
    min-height: 1.2em;
    margin-top: 4px;
    word-break: break-all;
}

/* Legend close button */
.legend-close-btn {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0 4px;
}

.legend-close-btn:hover {
    color: #333;
}

/* Legend toggle button (shown when legend hidden) */
.legend-toggle-btn {
    position: absolute;
    bottom: 30px;
    right: 10px;
    z-index: 1000;
    background: white;
    border: 2px solid var(--tt-blue);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.2s ease;
}

.legend-toggle-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

.legend-toggle-btn:hover {
    background-color: #f0f0f0;
}

.map-legend.hidden {
    display: none;
}

/* Custom Leaflet Draw Styles */
.leaflet-draw-toolbar a {
    background-color: white;
}

/* Disable text selection during scan */
.no-select {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
