/* ==========================================
   Main Styles - Philippines ISP Dashboard
   ========================================== */

/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* SVG Icon Styles */
.icon-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.icon-svg svg {
    display: block;
    width: 100%;
    height: 100%;
}

:root {
    /* Brand Colors */
    --converge-primary: #6366F1;
    --converge-secondary: #8B5CF6;
    --converge-accent: #A78BFA;
    --globe-primary: #10B981;
    --globe-secondary: #14B8A6;
    --globe-accent: #34D399;
    
    /* Classification Colors */
    --class-connection: #EF4444;
    --class-speed: #F97316;
    --class-outage: #8B5CF6;
    --class-billing: #EAB308;
    --class-support: #3B82F6;
    --class-installation: #10B981;
    --class-other: #6B7280;
    
    /* Neutral Colors (force dark theme) */
    --bg-primary: #1F2937;   /* slate-800 */
    --bg-secondary: #111827; /* gray-900 */
    --bg-tertiary: #0F172A;  /* slate-900 */
    --text-primary: #F9FAFB; /* gray-50 */
    --text-secondary: #D1D5DB;/* gray-300 */
    --text-tertiary: #9CA3AF;/* gray-400 */
    --border-color: #374151; /* gray-700 */
    
    /* UI Variables */
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1), 0 6px 10px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15), 0 10px 15px rgba(0, 0, 0, 0.08);
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
}

/* Light theme overrides (when explicitly selected) */
.dashboard[data-theme="light"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F9FAFB;
    --bg-tertiary: #F3F4F6;
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-tertiary: #6B7280;
    --border-color: #E5E7EB;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1F2937;
        --bg-secondary: #111827;
        --bg-tertiary: #0F172A;
        --text-primary: #F9FAFB;
        --text-secondary: #D1D5DB;
        --text-tertiary: #9CA3AF;
        --border-color: #374151;
    }
}

/* Base Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Dashboard Container */
.dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header */
.header {
    position: relative;
    z-index: 1000;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg);
    max-width: 1920px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Search Container Styles */
.search-container {
    position: relative;
    flex: 0 1 400px;
    margin: 0 0.5rem;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 2.25rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.3s ease;
    outline: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-input:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-input::placeholder {
    color: var(--text-tertiary);
    opacity: 0.7;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    opacity: 0.8;
}

.search-clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.search-clear-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.search-results-info {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.search-results-info .results-count {
    color: var(--primary-color);
    font-weight: 600;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    animation: pulse 2s infinite;
}

.logo-icon svg,
.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--converge-primary), var(--globe-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Provider Toggle */
.provider-toggle {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-xs);
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-base);
    position: relative;
    z-index: 2;
}

.toggle-btn.active {
    color: white;
}

.provider-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.provider-icon svg {
    width: 100%;
    height: 100%;
}

.toggle-slider {
    position: absolute;
    top: var(--spacing-xs);
    left: var(--spacing-xs);
    width: calc(50% - var(--spacing-xs));
    height: calc(100% - var(--spacing-sm));
    background: var(--converge-primary);
    border-radius: var(--border-radius-sm);
    transition: var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.toggle-slider.globe {
    transform: translateX(100%);
    background: var(--globe-primary);
}

/* View Mode Toggle */
.view-mode-toggle {
    display: flex;
    gap: var(--spacing-xs);
    background: var(--bg-secondary);
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
}

/* Choropleth Level Toggle */
.choropleth-level-toggle {
    display: flex;
    gap: var(--spacing-xs);
    background: var(--bg-secondary);
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
    margin-left: var(--spacing-sm);
}

.level-btn {
    padding: var(--spacing-sm);
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-btn:hover {
    background: var(--bg-tertiary);
}

.level-btn.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.level-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.view-btn {
    padding: var(--spacing-sm);
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-btn:hover {
    background: var(--bg-tertiary);
}

.view-btn.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.view-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Main Content Wrapper for Map and Table */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Map Section */
.map-section {
    flex: 0 0 70vh; /* Fixed height, won't grow or shrink */
    height: 70vh; /* Consistent height that won't be overridden */
    min-height: 420px;
    max-height: 70vh; /* Prevent expansion beyond intended size */
    position: relative;
    background: var(--bg-tertiary);
    transition: none; /* Disable any height transitions */
}

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

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

/* Map Controls */
.map-controls {
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 500;
}

.map-control-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.map-control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.map-control-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-primary);
    stroke-width: 2;
}

/* Legend */
.legend-container {
    position: absolute;
    bottom: var(--spacing-lg);
    left: var(--spacing-lg);
    min-width: 250px;
    max-width: 350px;
    z-index: 500;
    padding: var(--spacing-md);
}

.legend-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

/* Gradient scale for choropleth */
.legend-scale {
    margin: var(--spacing-md) 0;
}

.legend-gradient {
    height: 20px;
    width: 100%;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 0 2px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.legend-item:hover {
    color: var(--text-primary);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Control Panel */
.control-panel {
    width: 400px;
    background: var(--bg-secondary);
    overflow-y: auto;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Panel Sections */
.panel-section {
    padding: var(--spacing-lg);
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.section-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.section-icon svg {
    width: 100%;
    height: 100%;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--spacing-md);
    z-index: 9999;
}

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

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: white;
    font-size: 0.875rem;
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 9999;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .control-panel {
        width: 350px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .main-content {
        flex-direction: column;
    }
    
    .control-panel {
        width: 100%;
        order: -1;
        max-height: 40vh;
    }
    
    .map-section {
        min-height: 60vh;
    }
}

/* Map Tooltip Styles */
.map-tooltip {
    background-color: rgba(0, 0, 0, 0.8);
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    padding: 6px 10px;
    font-size: 14px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Remove Leaflet's default blue outline on clicked paths */
.leaflet-interactive:focus {
    outline: none !important;
}

.leaflet-clickable:focus {
    outline: none !important;
}

path.leaflet-interactive:focus {
    outline: none !important;
}

@media (max-width: 480px) {
    .logo-text {
        font-size: 1rem;
    }
    
    .provider-toggle {
        width: 100%;
        justify-content: space-around;
    }
}
