/**
 * ================================================================================
 *                        NÚCLEO INTEGRADO DE PREVISÃO
 * ================================================================================
 * Projeto: NIMBUS - Nó Integrador de Monitoramento de Bacias de Uso no Sul
 * Sub-projeto: geo-NIMBUS
 * Direção: Gabriel Paz
 * Autoria: Gabriel Paz auxiliado por IA
 * SENIP – Setor de Engenharia e Inovação do Núcleo Integrado de Previsão
 * Data: Dezembro/2025
 * Versão: 5.4
 * 
 * Descrição: Estilos CSS principais - Material Design minimalista
 *            Paleta: Azul escuro (#1a237e) e Laranja (#ff6f00)
 *            Inclui suporte a modo noturno e responsividade mobile
 * 
 * Melhorias 5.4:
 *   - Legenda mobile mais compacta
 *   - Menu de navegação mobile integrado no sidebar
 *   - Contraste melhorado
 * ================================================================================
 */

/* ============================================================================
   CSS RESET E VARIÁVEIS
   ============================================================================ */
:root {
    /* Cores principais - Modo Claro */
    --primary-dark: #1a237e;
    --primary: #283593;
    --primary-light: #3949ab;
    --secondary: #ff6f00;
    --secondary-light: #ff8f00;
    --secondary-dark: #e65100;
    
    /* Cores neutras - Modo Claro */
    --background: #f5f5f5;
    --surface: #ffffff;
    --text: #212121;
    --text-secondary: #757575;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    
    /* Cores de estado */
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --info: #2196f3;
    
    /* Sombras (Material Design) */
    --shadow-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    --shadow-3: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
    --shadow-4: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
    
    /* Transições */
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.3s ease-out;
    --transition-slow: 0.5s ease-out;
    
    /* Tamanhos */
    --header-height: 64px;
    --sidebar-width: 320px;
    --timeline-height: 90px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    
    /* Fontes */
    --font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

/* ============================================================================
   MODO NOTURNO (5.4)
   Ativado pela classe .dark-mode no body
   ============================================================================ */
body.dark-mode {
    --primary-dark: #90caf9;
    --primary: #64b5f6;
    --primary-light: #42a5f5;
    --secondary: #ffb74d;
    --secondary-light: #ffcc80;
    --secondary-dark: #ffa726;
    
    --background: #121212;
    --surface: #1e1e1e;
    --text: #e0e0e0;
    --text-secondary: #a0a0a0;
    --gray-50: #2d2d2d;
    --gray-100: #1e1e1e;
    --gray-200: #333333;
    --gray-300: #424242;
    --gray-400: #616161;
    --gray-500: #757575;
    --gray-600: #9e9e9e;
    --gray-700: #bdbdbd;
    --gray-800: #e0e0e0;
    --gray-900: #f5f5f5;
    
    --shadow-1: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.5);
    --shadow-2: 0 3px 6px rgba(0,0,0,0.4), 0 3px 6px rgba(0,0,0,0.5);
    --shadow-3: 0 10px 20px rgba(0,0,0,0.4), 0 6px 6px rgba(0,0,0,0.5);
}

/* Reset básico */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

/* 5.4: Body com suporte a safe-area para Android/iOS */
body {
    margin: 0;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--background);
    overflow: hidden;
    height: 100vh;
    height: calc(100vh - env(safe-area-inset-bottom));
    position: relative;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================================
   TELA DE CARREGAMENTO (5.4 - Atualizada com selo e textos)
   ============================================================================ */
/* 5.4: Tela de carregamento com fundo em tons de laranja */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ff6f00 0%, #ff8f00 50%, #ffa726 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

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

.loading-logos {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
}

.loading-logo {
    max-width: 120px;
    height: auto;
    animation: pulse 2s infinite ease-in-out;
}

.loading-selo {
    max-width: 100px;
    height: auto;
    animation: pulse 2s infinite ease-in-out;
    animation-delay: 0.5s;
}

.loading-text-container {
    text-align: center;
    color: #ffffff;
    margin-bottom: 24px;
}

.loading-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.loading-subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-status {
    color: #ffffff;
    font-size: 0.875rem;
    margin-top: 16px;
    opacity: 0.8;
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.03); opacity: 0.9; }
}

/* ============================================================================
   MODAL DE BOAS-VINDAS (5.4)
   ============================================================================ */
.welcome-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.welcome-modal.visible {
    opacity: 1;
    visibility: visible;
}

.welcome-content {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-4);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.welcome-header {
    background: linear-gradient(135deg, var(--secondary-light) 0%, var(--primary) 100%);
    padding: 24px;
    color: #ffffff;
    text-align: center;
}

body.dark-mode .welcome-header {
    background: linear-gradient(135deg, #1e1e1e 0%, #333333 100%);
}

.welcome-header img {
    max-width: 80px;
    margin-bottom: 12px;
}

.welcome-header h2 {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.welcome-header p {
    font-size: 0.875rem;
    opacity: 0.9;
}

.welcome-body {
    padding: 24px;
}

.welcome-body h3 {
    font-size: 1rem;
    color: var(--primary-dark);
    margin-bottom: 12px;
}

body.dark-mode .welcome-body h3 {
    color: var(--primary);
}

.welcome-body ul {
    list-style: none;
    margin-bottom: 16px;
}

.welcome-body li {
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.welcome-body li::before {
    content: "•";
    position: absolute;
    left: 8px;
    color: var(--secondary);
}

.welcome-alert {
    background: #fff3e0;
    border-left: 4px solid var(--secondary);
    padding: 12px;
    border-radius: 4px;
    margin-top: 16px;
    font-size: 0.875rem;
    color: #e65100;
}

body.dark-mode .welcome-alert {
    background: #3d2c1a;
    color: #ffb74d;
}

.welcome-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.welcome-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.welcome-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.welcome-btn {
    padding: 10px 24px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.welcome-btn:hover {
    background: var(--primary-dark);
}

.station-modal-btn {
    width: 100%;
    padding: 10px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.875rem;
}

/* ============================================================================
   HEADER (5.4 - Com menu de navegação)
   ============================================================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    box-shadow: var(--shadow-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    transition: background-color var(--transition-normal);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
    color: var(--text);
}

.menu-toggle:hover {
    background-color: var(--gray-100);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo {
    height: 40px;
    width: auto;
}

.logo-text-container {
    display: flex;
    flex-direction: column;
}

.logo-text {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
    text-decoration: none;
}

body.dark-mode .logo-text {
    color: var(--primary);
}

.logo-subtitle {
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

/* Menu de navegação no header (5.4) */
.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 24px;
}

.header-nav-link {
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.header-nav-link:hover {
    background: var(--gray-100);
    color: var(--text);
    text-decoration: none;
}

.header-nav-link.active {
    background: var(--primary);
    color: #ffffff;
}

body.dark-mode .header-nav-link.active {
    background: var(--primary-dark);
    color: #121212;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 16px;
}

.variable-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-100);
    padding: 8px 16px;
    border-radius: 24px;
    max-width: 300px;
    width: 100%;
}

.variable-selector label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.variable-selector select {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-dark);
    cursor: pointer;
    padding: 4px 8px;
}

body.dark-mode .variable-selector select {
    color: var(--primary);
}

.variable-selector select:focus {
    outline: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.partner-logos {
    display: flex;
    align-items: center;
    gap: 8px;
}

.partner-logo-link {
    display: flex;
    align-items: center;
}

.partner-logo {
    height: 32px;
    width: auto;
    max-width: 80px;
    object-fit: contain;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.partner-logo:hover {
    opacity: 1;
}

.datetime-display {
    text-align: right;
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.datetime-display .date {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--primary-dark);
}

body.dark-mode .datetime-display .date {
    color: var(--primary);
}

.datetime-display .time {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary);
}

/* ============================================================================
   SIDEBAR / MENU LATERAL (5.4 - Rodapé melhorado)
   ============================================================================ */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--surface);
    box-shadow: var(--shadow-3);
    transform: translateX(-100%);
    transition: transform var(--transition-normal), background-color var(--transition-normal);
    z-index: 900;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
    z-index: 899;
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

body.dark-mode .sidebar-title {
    color: var(--primary);
}

.sidebar-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.sidebar-section {
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-section-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.sidebar-section-header:hover {
    background-color: var(--gray-50);
}

.sidebar-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-section-icon {
    width: 20px;
    height: 20px;
    fill: var(--gray-500);
    transition: transform var(--transition-fast);
}

.sidebar-section.collapsed .sidebar-section-icon {
    transform: rotate(-90deg);
}

.sidebar-section-content {
    padding: 0 16px 16px;
    display: block;
}

.sidebar-section.collapsed .sidebar-section-content {
    display: none;
}

/* Controles do sidebar */
.control-group {
    margin-bottom: 14px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.control-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.control-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(40, 53, 147, 0.1);
}

.control-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
}

.control-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.control-checkbox span {
    font-size: 0.875rem;
    color: var(--text);
}

.shape-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shape-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.shape-actions button {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.shape-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.shape-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px 0;
}

.shape-category-header {
    font-weight: 700;
    color: var(--text);
    font-size: 0.95rem;
}

.shape-category-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shape-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    background: var(--surface);
}

.shape-focus-btn {
    padding: 6px 10px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.shape-focus-btn:hover {
    background: var(--primary);
    color: #fff;
}

.empty-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 8px 0;
}

/* Switch toggle para modo noturno (5.4) */
.switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.switch-label {
    font-size: 0.875rem;
    color: var(--text);
}

.switch {
    position: relative;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-400);
    border-radius: 24px;
    transition: background-color var(--transition-fast);
}

.switch-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.switch input:checked + .switch-slider {
    background-color: var(--primary);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(24px);
}

/* Chips para filtros de fonte */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 16px;
    font-size: 0.8125rem;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-chip:hover {
    background: var(--gray-200);
}

.filter-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.filter-chip img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: contain;
}

/* Controle de acumulado (5.4) */
.accumulation-control {
    margin-top: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.accumulation-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.accumulation-slider {
    width: 100%;
    margin-bottom: 8px;
}

.accumulation-value {
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-dark);
}

body.dark-mode .accumulation-value {
    color: var(--primary);
}

/* 5.4: Menu de navegação no sidebar (sempre visível no mobile) */
.sidebar-section-menu {
    display: none;
}

.sidebar-nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.sidebar-nav-menu-link svg {
    fill: currentColor;
    flex-shrink: 0;
}

.sidebar-nav-menu-link:hover {
    background: var(--gray-200);
    text-decoration: none;
}

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

body.dark-mode .sidebar-nav-menu-link.active {
    background: var(--primary-dark);
    color: #121212;
}

/* 5.4: Seção "Sobre" reorganizada */
.sidebar-sobre-content {
    text-align: center;
}

.sobre-logo {
    margin-bottom: 16px;
}

.sobre-logo img {
    max-width: 120px;
    height: auto;
}

.sobre-instituicao {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.sobre-apoio {
    margin-bottom: 20px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.sobre-apoio-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sobre-parceiros {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sobre-parceiros a {
    display: inline-block;
}

.sobre-parceiros img {
    height: 28px;
    width: auto;
    max-width: 60px;
    object-fit: contain;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.sobre-parceiros img:hover {
    opacity: 1;
}

.sobre-descricao {
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 16px;
}

.sobre-creditos {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.sobre-autor {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.sobre-autor a {
    color: var(--primary);
    text-decoration: none;
}

.sobre-autor a:hover {
    text-decoration: underline;
}

.sobre-versao {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

/* ============================================================================
   ÁREA DO MAPA
   ============================================================================ */
.map-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: var(--timeline-height);
    z-index: 1;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--gray-200);
}

/* Estilos do Leaflet para modo noturno */
body.dark-mode .leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--text) !important;
}

body.dark-mode .leaflet-control-zoom a:hover {
    background: var(--gray-200) !important;
}

body.dark-mode .leaflet-control-layers {
    background: var(--surface) !important;
    color: var(--text) !important;
}

/* ============================================================================
   MARCADORES DO MAPA
   ============================================================================ */
.station-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: var(--shadow-2);
    font-weight: 700;
    font-size: 11px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.station-marker:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-3);
    z-index: 1000 !important;
}

/* Cluster markers */
.marker-cluster div {
    width: 36px;
    height: 36px;
    margin-left: 4px;
    margin-top: 4px;
    text-align: center;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster-small {
    background-color: rgba(40, 53, 147, 0.6);
}

.marker-cluster-small div {
    background-color: var(--primary);
}

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

.marker-cluster-medium div {
    background-color: var(--secondary);
}

.marker-cluster-large {
    background-color: rgba(230, 81, 0, 0.6);
}

.marker-cluster-large div {
    background-color: var(--secondary-dark);
}

/* ============================================================================
   MODAL DE DETALHES DA ESTAÇÃO (5.4 - Horizontal)
   ============================================================================ */
.station-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.station-modal.visible {
    opacity: 1;
    visibility: visible;
}

.station-modal-content {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    max-width: 800px;
    width: 95%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-4);
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

.station-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #ffffff;
}

body.dark-mode .station-modal-header {
    background: linear-gradient(135deg, #2d2d2d 0%, #424242 100%);
}

.station-modal-title {
    flex: 1;
}

.station-modal-title h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.station-modal-title .codigo {
    font-size: 0.8125rem;
    opacity: 0.9;
    font-family: var(--font-mono);
}

.station-modal-fonte {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.station-modal-fonte img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: #ffffff;
    object-fit: contain;
    padding: 2px;
}

.station-modal-fonte span {
    font-size: 0.8125rem;
    opacity: 0.9;
}

.station-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
    flex-shrink: 0;
}

.station-modal-close:hover {
    background: rgba(255,255,255,0.3);
}

.station-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Layout horizontal do modal (5.4) */
.station-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.station-modal-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.station-value-card {
    text-align: center;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.station-value-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1;
}

body.dark-mode .station-value-number {
    color: var(--primary);
}

.station-value-unit {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.station-value-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.station-info-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.station-info-item {
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.station-info-label {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.station-info-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.station-modal-chart {
    display: flex;
    flex-direction: column;
}

/* 5.4: Container com altura fixa e overflow hidden para evitar crescimento do gráfico */
.station-chart-container {
    flex: 1;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    min-height: 280px;
    max-height: 280px;
    height: 280px;
    position: relative;
    overflow: hidden;
}

.station-chart-container canvas {
    max-width: 100% !important;
    max-height: 250px !important;
}

.station-chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.station-other-data {
    margin-top: 16px;
}

.station-other-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.station-data-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.station-data-chip {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 6px 12px;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    font-size: 0.8125rem;
}

.station-data-chip-value {
    font-weight: 600;
    color: var(--primary-dark);
}

body.dark-mode .station-data-chip-value {
    color: var(--primary);
}

.station-data-chip-unit {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.station-modal-footer {
    padding: 16px 24px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.station-modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: var(--secondary);
    color: #ffffff;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition-fast);
}


.station-modal-btn:hover {
    background: var(--secondary-dark);
    text-decoration: none;
}

.station-modal-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ============================================================================
   TIMELINE (5.4 - Invertida, presente à direita)
   ============================================================================ */
/* 5.4: Timeline com suporte a safe-area para Android */
.timeline-container {
    position: fixed;
    bottom: 0;
    bottom: env(safe-area-inset-bottom);
    left: 0;
    right: 0;
    height: var(--timeline-height);
    background: var(--surface);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 800;
    display: flex;
    align-items: center;
    padding: 0 20px;
    transition: background-color var(--transition-normal);
}

.timeline-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.timeline-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
    color: var(--text);
}

.timeline-btn:hover {
    background: var(--gray-200);
}

.timeline-btn:active {
    transform: scale(0.95);
}

.timeline-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.timeline-btn.active {
    background: var(--primary);
    color: #ffffff;
}

.timeline-slider-container {
    flex: 1;
    margin: 0 16px;
    position: relative;
}

/* 5.4: Timeline invertida - esquerda é passado, direita é presente */
.timeline-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    background: var(--gray-300);
}

/* Barra preenchida à esquerda do thumb */
.timeline-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--primary) 0%, var(--primary) var(--timeline-progress, 100%), var(--gray-300) var(--timeline-progress, 100%));
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--surface);
    border: 3px solid var(--primary);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-1);
    margin-top: -6px;
}

.timeline-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
}

.timeline-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--surface);
    border: 3px solid var(--primary);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-1);
}

.timeline-slider::-moz-range-progress {
    background: var(--primary);
    height: 6px;
    border-radius: 3px;
}

.timeline-ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    padding: 0 9px;
}

.timeline-tick {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-align: center;
}

.timeline-current {
    text-align: center;
    flex-shrink: 0;
    min-width: 100px;
}

.timeline-current-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.timeline-current-time {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-dark);
}

body.dark-mode .timeline-current-time {
    color: var(--primary);
}

/* ============================================================================
   LEGENDA DE CORES
   ============================================================================ */
.color-legend {
    position: fixed;
    bottom: calc(var(--timeline-height) + 12px);
    right: 12px;
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-2);
    padding: 5px;
    padding-bottom: 20px;
    z-index: 900;
    min-width: 100px;
    transition: background-color var(--transition-normal);
}

.color-legend-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    text-align: center;
}

.color-legend-gradient {
    height: 100px;
    width: 16px;
    border-radius: 4px;
    margin: 0 auto;
}

.color-legend-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100px;
    margin-left: 8px;
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.color-legend-content {
    display: flex;
    justify-content: center;
}

/* ============================================================================
   RESPONSIVIDADE MOBILE (5.4 - Melhorada)
   ============================================================================ */
@media (max-width: 900px) {
    /* Modal em layout vertical no tablet */
    .station-modal-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 56px;
        --sidebar-width: 100%;
        --timeline-height: 80px;
    }
    
    .header {
        padding: 0 8px;
    }
    
    .logo-text {
        font-size: 1.125rem;
    }
    
    .logo-subtitle {
        display: none;
    }
    
    .header-nav {
        display: none;
    }
    
    .header-center {
        display: none;
    }
    
    .partner-logos {
        display: none;
    }
    
    .datetime-display {
        padding: 6px 8px;
    }
    
    .datetime-display .date {
        font-size: 0.6875rem;
    }
    
    .datetime-display .time {
        font-size: 0.875rem;
    }
    
    .sidebar {
        width: 100%;
        max-width: 100%;
    }
    
    /* 5.4: Mostrar seção de menu no sidebar mobile */
    .sidebar-section-menu {
        display: block !important;
    }
    
    /* 5.4: Esconder logos de parceiros do header no mobile */
    .partner-logos {
        display: none !important;
    }
    
    /* 5.4: Seção sobre ocupa mais espaço no mobile */
    .sobre-apoio {
        display: block !important;
    }
    
    /* Timeline mobile */
    .timeline-container {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 12px;
        gap: 8px;
    }
    
    .timeline-controls {
        order: 1;
        flex: 0 0 auto;
    }
    
    .timeline-slider-container {
        order: 3;
        flex: 0 0 100%;
        margin: 0;
    }
    
    .timeline-current {
        order: 2;
        flex: 1;
        text-align: right;
    }
    
    .timeline-current-time {
        font-size: 1rem;
    }
    
    .timeline-btn {
        width: 32px;
        height: 32px;
    }
    
    .timeline-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .map-container {
        bottom: 80px;
    }
    
    /* 5.4: Legenda mobile mais compacta e melhor posicionada acima da timeline */
    .color-legend {
        bottom: calc(105px + env(safe-area-inset-bottom));
        right: 8px;
        padding: 6px 8px;
        min-width: 70px;
    }
    
    .color-legend-title {
        font-size: 0.5625rem;
        margin-bottom: 4px;
    }
    
    .color-legend-gradient {
        height: 60px;
        width: 12px;
    }
    
    .color-legend-labels {
        height: 60px;
        font-size: 0.5625rem;
        margin-left: 4px;
    }
    
    /* Modal mobile */
    .station-modal-content {
        max-height: 95vh;
        width: 100%;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        margin-top: auto;
    }
    
    .station-modal-header {
        padding: 16px;
    }
    
    .station-modal-body {
        padding: 16px;
    }
    
    .station-modal-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .station-value-number {
        font-size: 2.5rem;
    }
    
    .station-info-list {
        grid-template-columns: 1fr;
    }
    
    /* Welcome modal mobile */
    .welcome-content {
        max-height: 95vh;
        margin: auto 8px 0;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    }
}

@media (max-width: 480px) {
    .logo {
        height: 32px;
    }
    
    .logo-text {
        font-size: 1rem;
    }
    
    .menu-toggle {
        width: 40px;
        height: 40px;
    }
    
    .station-value-number {
        font-size: 2rem;
    }
}

/* ============================================================================
   UTILITÁRIOS E ACESSIBILIDADE
   ============================================================================ */
.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;
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

/* Preferências de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Fallback para imagens */
.img-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
    color: var(--text-secondary);
    font-size: 0.6875rem;
    text-align: center;
    padding: 4px;
    border-radius: 4px;
}

/* Sessão e intranet 5.5 */
.user-session {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    justify-content: flex-end;
}

.user-pill {
    background: #e8eaf6;
    color: #1a237e;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.logout-link {
    color: #1a237e;
    font-weight: 700;
    text-decoration: none;
}
