/* --- VARIABLES Y ESTILOS GLOBALES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --background: #121212;
    --bg-secondary: #1E1E1E;
    --text-primary: #FFFFFF;
    --text-muted: #818085;
    --card-color: #242424;
    --border-color: #333333;
    --selected-bg: #007BFF;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
}

/* --- ESTILOS DEL HEADER (sin cambios) --- */
.main-header { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 70px; padding: 0 20px; border-bottom: 1px solid var(--border-color); }
.header-group { display: flex; align-items: center; gap: 15px; }
.icon-button { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background-color: var(--bg-secondary); border-radius: 50%; border: none; cursor: pointer; padding: 10px; }
.icon-button svg { width: 100%; height: auto; }
.location-display { font-family: 'JetBrains Mono', Arial, sans-serif; font-size: 15px; display: flex; align-items: center; gap: 8px; font-weight: 500; }
.location-display svg { width: 30px; height: 30px; }
.search-form { display: flex; align-items: center; gap: 15px; }
.search-wrapper { position: relative; }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 0 15px; height: 45px; width: 250px; border-radius: 30px; background-color: var(--bg-secondary); }
.search-bar svg { width: 20px; height: 20px; flex-shrink: 0; }
.search-bar input { background: transparent; border: none; outline: none; color: white; width: 100%; font-size: 16px; font-family: 'Instrument Sans', Arial, sans-serif; }
#suggestions-container { display: none; position: absolute; top: 50px; left: 0; width: 100%; background-color: var(--card-color); border: 1px solid var(--border-color); border-radius: 15px; z-index: 1000; max-height: 200px; overflow-y: auto; }
.suggestion-item { padding: 12px 15px; cursor: pointer; font-size: 15px; border-bottom: 1px solid var(--border-color); }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background-color: var(--bg-secondary); }
#date { font-family: 'Instrument Sans', Arial, sans-serif; font-size: 16px; background-color: var(--bg-secondary); color: var(--text-primary); height: 45px; padding: 0 15px; border-radius: 20px; border: none; outline: none; text-align: center; color-scheme: dark; }


/* --- LAYOUT DEL DASHBOARD (NUEVA ESTRUCTURA) --- */
.dashboard-grid {
    display: grid;
    padding: 20px;
    gap: 20px;
    height: calc(100vh - 70px);
    
    /* CAMBIO: 4 Columnas: Principal, 2 mini-cards, Nueva Gráfica */
    grid-template-columns: 350px 1fr 1fr 2fr;
    
    /* CAMBIO: Se ajusta el grid para que la nueva gráfica y el mapa tengan tamaños iguales */
    grid-template-rows: auto 1fr;
    
    grid-template-areas:
        "nav      nav     nav     nav"
        "today    mini1   mini2   new-chart"
        "map      map     summary summary";
}

/* --- ASIGNACIÓN DE ÁREAS --- */
.time-nav             { grid-area: nav; }
.current-weather-card { grid-area: today; }
.new-chart-card       { grid-area: new-chart; }
.map-overview-card    { grid-area: map; height: 500px;}
.day-summary-card     { grid-area: summary; }

/* Asignación a las 2 mini-cards */
.mini-card:nth-of-type(1) { grid-area: mini1; }
.mini-card:nth-of-type(2) { grid-area: mini2; }

/* --- ESTILOS DE LA NAVEGACIÓN DE TIEMPO (sin cambios) --- */
.time-nav { display: flex; gap: 20px; margin-bottom: 10px; }
.time-nav button { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 5px 0; font-weight: 500; border-bottom: 2px solid transparent; transition: all 0.2s ease-in-out; }
.time-nav button.active, .time-nav button:hover { color: var(--text-primary); border-bottom-color: var(--text-primary); }

/* --- ESTILO BASE PARA TODAS LAS TARJETAS (sin cambios) --- */
.card { background-color: var(--card-color); border-radius: 20px; padding: 25px; display: flex; flex-direction: column; }
.card h3 { font-weight: 500; margin-bottom: 15px; }

/* --- ESTILOS TARJETA PRINCIPAL (sin cambios) --- */
.current-weather-card .card-header { display: flex; justify-content: space-between; align-items: center; }
.current-weather-card h2 { font-size: 24px; font-weight: 600; }
.current-weather-card .time { font-size: 16px; color: var(--text-muted); }
.current-weather-card .weather-body { display: flex; align-items: center; justify-content: space-around; margin: 20px 0; flex-grow: 1; }
.current-weather-card .temperature { font-size: 72px; font-weight: 700; }
.current-weather-card .weather-icon { width: 250px; }
.current-weather-card .weather-details { border-top: 1px solid var(--border-color); padding-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; color: var(--text-muted); margin-bottom: 50px; }
.weather-details > p { display: flex; align-items: center; gap: 10px; }

/* --- ESTILOS DE MINI CARDS (sin cambios) --- */
.mini-card { height: 100%; min-height: 150px; display: flex; flex-direction: column; text-align: center; align-items: center; justify-content: space-between; padding: 20px 15px; cursor: pointer; transition: all 0.2s ease-in-out; }
.mini-card:hover { transform: translateY(-5px); }
.mini-card.selected { background-color: var(--selected-bg); }
.mini-card header { width: 100%; padding-bottom: 15px; border-bottom: 1px solid var(--border-color); }
.mini-card h2 { font-size: 24px; font-weight: 600; margin: 0; }
.mini-card img { width: 150px; height: 150px; object-fit: contain; margin: auto; align-items: center;}
.mini-card footer { font-size: 34px; font-weight: 800; }
.mini-card footer h3 { margin-bottom: 30px; font-size: 50px; font-weight:700 ; }
.details > p { font-size: 15px; font-weight: normal; margin-bottom: 10px; color : var(--text-muted); text-align: center;}
.details {padding:10px, 15px; margin-top: auto;}


/* ---ESTILOS DEL RESUMEN DE DÍA (sin cambios) --- */
.new-chart-card{
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    width: 800px;
    position: relative; /* para contener el overlay */
    overflow: hidden;   /* evitar desbordes del overlay/spinner */
}
.new-chart-card h3{
    font-size: 24px;
    text-align: center;
    font-weight: 600;
}

.new-chart-card form {
display: flex;
flex-direction: column;
gap: 18px;
}
  
  .new-chart-card label {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 6px;
  }
  
  .new-chart-card input[type="number"],
  .new-chart-card input[type="date"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border 0.2s;
    background-color: var(--bg-secondary);
    color: var(--text-muted);
  }
  
  .new-chart-card input[type="number"]:focus,
  .new-chart-card input[type="date"]:focus {
    border: 1.5px solid #8cb2ff;
    outline: none;
  }
  
  .new-chart-card button[type="submit"] {
    background: #2b6cb0;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 0;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: background 0.2s;
  }
  
  .new-chart-card button[type="submit"]:hover {
    background: #1a4366;
  }
  
    /* Overlay y spinners para estado de carga */
    .loading-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.35);
        display: grid;
        place-items: center;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
        border-radius: inherit;
    }

    .spinner,
    .btn-spinner {
        width: 20px;
        height: 20px;
        border: 2.5px solid rgba(255,255,255,0.25);
        border-top-color: #8cb2ff;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

    .btn-save {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .btn-spinner { display: none; }

    .new-chart-card.is-loading .loading-overlay { opacity: 1; pointer-events: auto; }
    .new-chart-card.is-loading .btn-save { opacity: .95; cursor: not-allowed; }
    .new-chart-card.is-loading .btn-spinner { display: inline-block; }
    .new-chart-card.is-loading .btn-label { opacity: .9; }
    .new-chart-card.is-loading input,
    .new-chart-card.is-loading button,
    .new-chart-card.is-loading select { pointer-events: none; }

    @keyframes spin { to { transform: rotate(360deg); } }

    /* Accesibilidad: solo lectores de pantalla */
    .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;
    }

    .form-message { margin-top: 8px; font-size: .95rem; color: #ff8b8b; }
/* --- ESTILOS DE MAPA Y RESUMEN (CORREGIDO) --- */
.map-overview-card, .day-summary-card, .new-chart-card {
    display: flex;
    flex-direction: column;
}
.map-overview-card {
    grid-column: 1 / 4; /* El mapa ocupa las primeras dos columnas de su fila */
}
.day-summary-card {
    grid-column: 4 / 5; /* La gráfica ocupa las últimas dos columnas */
}
.map-overview-card #mi_mapa { flex-grow: 1; background-color: var(--bg-secondary); border-radius: 15px; min-height: 250px; }
.day-summary-card .summary-graph, .new-chart-card .summary-graph { flex-grow: 1; display: flex; align-items: flex-end; min-height: 150px; background-color: var(--bg-secondary); border-radius: 15px; }


/* Media query (sin cambios) */
@media (max-width: 1200px) { /* ... */ }

/* --- TEMA CLARO --- */
body[data-theme="light"] {
    --background: #F5F5F5;
    --bg-secondary: #FFFFFF;
    --text-primary: #1E1E1E;
    --text-muted: #6B6B6B;
    --card-color: #FFFFFF;
    --border-color: #E0E0E0;
    --selected-bg: #007BFF;
}

/* Ajustes específicos para el tema claro */
body[data-theme="light"] .icon-button svg {
    fill: #1E1E1E !important;
}

/* Icono de usuario usa stroke en lugar de fill */
body[data-theme="light"] .user-login svg circle,
body[data-theme="light"] .user-login svg path {
    stroke: #1E1E1E;
}

body[data-theme="light"] .location-display svg path {
    fill: #1E1E1E;
}

body[data-theme="light"] .search-bar svg path {
    fill: #1E1E1E;
}

body[data-theme="light"] .search-bar input {
    color: #1E1E1E;
}

body[data-theme="light"] .search-bar input::placeholder {
    color: #6B6B6B;
}

body[data-theme="light"] #date {
    color-scheme: light;
}

body[data-theme="light"] .main-header {
    border-bottom: 1px solid #E0E0E0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

body[data-theme="light"] .card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body[data-theme="light"] .mini-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* --- LOGIN / MODAL STYLES --- */
.user-name { color: var(--text-primary); }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-backdrop.active { display: flex; }
.login-modal {
    width: 360px;
    background: var(--card-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    color: var(--text-primary);
}
.login-modal h3 { margin-bottom: 12px; }
.login-modal label { display:block; margin-top:8px; font-size:14px; color:var(--text-muted); }
.login-modal input { width:100%; padding:10px 12px; margin-top:6px; border-radius:8px; border:1px solid var(--border-color); background:var(--bg-secondary); color:var(--text-primary); }
.login-actions { display:flex; gap:10px; margin-top:14px; }
.btn { padding:10px 12px; border-radius:8px; border:none; cursor:pointer; font-weight:600; }
.btn-primary { background:#2b6cb0; color:#fff; }
.btn-ghost { background:transparent; border:1px solid var(--border-color); color:var(--text-primary); }
.login-error { color:#ff6b6b; margin-top:8px; font-size:14px; display:none; }
.login-success { color:#7be495; margin-top:8px; font-size:14px; display:none; }
