/* ===== Modern Map Page Design ===== */
.map-page {
    padding: 0;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    min-height: calc(100vh - 70px);
}

.map-hero-section {
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%);
    padding: 3rem 0 2rem;
    position: relative;
    overflow: hidden;
}

.map-hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.map-hero-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
    text-align: center;
}

.map-hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: white;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.map-hero-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    max-width: 700px;
    margin: 0 auto;
}

.map-container-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.map-controls-panel {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.controls-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: -1.25rem -1.25rem 1rem -1.25rem;
    padding: 0.75rem 1.25rem;
    padding-bottom: 0.75rem;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 12px 12px 0 0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.controls-header i {
    font-size: 1.2rem;
    color: #ffffff;
}

.controls-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.filter-row {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 0 0 auto;
    min-width: 150px;
    max-width: 180px;
}

.filter-group label {
    font-weight: 600;
    color: #475569;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.filter-group select {
    padding: 0.45rem 0.65rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #1e293b;
    background: white;
    transition: all 0.2s;
    cursor: pointer;
    width: 100%;
}

.filter-group select:hover {
    border-color: #3b82f6;
}

.filter-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-button-group {
    display: flex;
    align-items: end;
    flex-shrink: 0;
}

.search-btn {
    padding: 0.45rem 1.5rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.search-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.search-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.25);
}

.search-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.territory-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.territory-toggle:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
}

.territory-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3b82f6;
    flex-shrink: 0;
}

.territory-toggle label {
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    margin: 0;
    font-size: 0.85rem;
    white-space: nowrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #f1f5f9;
}

.stat-card {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    padding: 1.25rem;
    border-radius: 12px;
    text-align: center;
    border: 2px solid #e2e8f0;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
}

.stat-card-label {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.main-map-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
}

.main-map-layout.hidden {
    display: none;
}

.main-map-layout.full-width {
    grid-template-columns: 1fr;
}

.main-map-layout.full-width .map-sidebar {
    display: none !important;
}

.map-sidebar {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 300px);
}

.sidebar-header {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    padding: 1.5rem;
    color: white;
}

.sidebar-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.sidebar-count {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-content::-webkit-scrollbar {
    width: 8px;
}

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

.sidebar-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.units-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.governorate-section {
    margin-bottom: 1.5rem;
}

.governorate-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid #e2e8f0;
}

.governorate-header span:first-child {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.95rem;
}

.governorate-badge {
    background: linear-gradient(135deg, #475569 0%, #64748b 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.unit-item {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: #f8fafc;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.unit-item:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
    transform: translateX(-4px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.unit-item.active {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.unit-name {
    font-weight: 700;
    color: #1e293b;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.unit-details {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.6;
}

.unit-details i {
    margin-left: 0.25rem;
    color: #3b82f6;
}

.map-wrapper {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    position: relative;
    height: calc(100vh - 300px);
    min-height: 600px;
}

.map-container {
    width: 100%;
    height: 100%;
    position: relative;
}

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

.map-type-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 1000;
    background: white;
    padding: 0.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 0.5rem;
}

.map-type-btn {
    padding: 0.6rem 1rem;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: #475569;
    transition: all 0.2s;
    white-space: nowrap;
}

.map-type-btn:hover {
    background: #f8fafc;
    border-color: #3b82f6;
    color: #3b82f6;
}

.map-type-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: #3b82f6;
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f1f5f9;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 1rem;
    color: #64748b;
    font-weight: 600;
    font-size: 1rem;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: none;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.empty-state.active {
    display: block;
}

.empty-state-icon {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 0.75rem;
}

.empty-state h3 {
    color: #64748b;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.empty-state p {
    color: #94a3b8;
    font-size: 0.9rem;
    margin: 0;
}

/* Popup Styles */
.territory-popup {
    padding: 0;
    min-width: 280px;
}

.territory-popup-header {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px 8px 0 0;
    margin: -10px -10px 10px -10px;
}

.territory-popup-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.territory-popup-content {
    padding: 0.5rem 0;
}

.territory-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.territory-info-row:last-child {
    border-bottom: none;
}

.territory-info-label {
    font-weight: 600;
    color: #475569;
    font-size: 0.9rem;
}

.territory-info-value {
    color: #1e293b;
    font-size: 0.9rem;
    text-align: left;
    flex: 1;
    margin-right: 10px;
}

.unit-popup {
    padding: 0;
    min-width: 300px;
}

.unit-popup-header {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px 8px 0 0;
    margin: -10px -10px 12px -10px;
}

.unit-popup-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.unit-popup-content {
    padding: 0.5rem 0;
}

.unit-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.unit-info-row:last-child {
    border-bottom: none;
}

.unit-info-label {
    font-weight: 600;
    color: #475569;
    font-size: 0.9rem;
}

.unit-info-value {
    color: #1e293b;
    font-size: 0.9rem;
    text-align: left;
    flex: 1;
    margin-right: 10px;
}

.unit-info-value a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.unit-info-value a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-map-layout {
        grid-template-columns: 1fr;
    }

    .map-sidebar {
        max-height: 400px;
    }

    .map-wrapper {
        height: 600px;
    }
}

@media (max-width: 768px) {
    .map-hero-title {
        font-size: 1.8rem;
    }

    .map-hero-subtitle {
        font-size: 1rem;
    }

    .map-container-wrapper {
        padding: 1rem;
    }

    .filter-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .map-wrapper {
        height: 500px;
        min-height: 500px;
    }

    .map-type-controls {
        flex-direction: column;
        top: 10px;
        right: 10px;
    }
}
