/* ==========================================================================
   Global Styles
   ========================================================================== */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

/* ==========================================================================
   Layout
   ========================================================================== */

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1rem;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #2c3e50;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 999;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #3498db;
}

.help-text {
    margin-bottom: 0.8rem;
    padding: 0.5rem;
    background: #e8f4fd;
    border: 1px solid #bee5eb;
    border-radius: 4px;
}

.help-text small {
    color: #0c5460;
    font-style: italic;
}

/* ==========================================================================
   Dataset List
   ========================================================================== */

.dataset-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dataset-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.dataset-item:hover {
    background: #e3f2fd;
    border-color: #2196f3;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.2);
}

.dataset-item.active {
    background: #2196f3;
    color: white;
    border-color: #1976d2;
}

.dataset-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.dataset-info {
    font-size: 0.85rem;
    opacity: 0.8;
}

.dataset-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4caf50;
    border: 2px solid white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dataset-toggle.inactive {
    background: #ccc;
}

/* ==========================================================================
   Controls
   ========================================================================== */

.control-select {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.control-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #e67e22;
}

/* ==========================================================================
   Filter Controls
   ========================================================================== */

.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-group {
    background: #f8f9fa;
    padding: 1.2rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    position: relative;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

.filter-title {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.filter-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.8rem;
}

.filter-row label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #6c757d;
    margin-bottom: 0.2rem;
}

.filter-input {
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.filter-input:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.remove-filter {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: background-color 0.15s ease-in-out;
}

.remove-filter:hover {
    background: #c82333;
}

.apply-filter {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    transition: background-color 0.15s ease-in-out;
}

.apply-filter:hover {
    background: #218838;
}

.filtered-indicator {
    background: #17a2b8;
    color: white;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.7rem;
    margin-left: 0.5rem;
}

/* ==========================================================================
   Map Container
   ========================================================================== */

.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.map-view {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.map-btn {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.8rem;
    margin: 2px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-btn:hover {
    background: #3498db;
    color: white;
    transform: scale(1.05);
}

.map-btn.active {
    background: #2196f3;
    color: white;
}

/* ==========================================================================
   Feature Info Panel
   ========================================================================== */

.feature-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 0;
    max-width: 400px;
    max-height: 300px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.feature-info-header {
    background: #3498db;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.feature-info-header h4 {
    margin: 0;
    font-size: 1.1rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.feature-content {
    padding: 1rem;
    overflow-y: auto;
    max-height: 200px;
}

.feature-property {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.feature-property:last-child {
    border-bottom: none;
}

.property-key {
    font-weight: 600;
    color: #2c3e50;
}

.property-value {
    color: #7f8c8d;
    text-align: right;
    max-width: 200px;
    word-wrap: break-word;
}

/* ==========================================================================
   Statistics Panel
   ========================================================================== */

.stats-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 0;
    width: 350px;
    height: 250px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.stats-header {
    background: #27ae60;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.stats-content {
    padding: 1rem;
    height: calc(100% - 60px);
}

/* ==========================================================================
   Loading and Toast
   ========================================================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #2c3e50;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success {
    background: #27ae60;
}

.toast.error {
    background: #e74c3c;
}

.toast.warning {
    background: #f39c12;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        z-index: 1001;
        width: 280px;
    }
    
    .main-layout {
        position: relative;
    }
    
    .header h1 {
        font-size: 1.4rem;
    }
    
    .feature-info {
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .stats-panel {
        top: 10px;
        left: 10px;
        right: 10px;
        width: auto;
    }
}
