/* Calculadora App Styles */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header nav h1 {
    color: white;
    font-size: 1.8rem;
    font-weight: 600;
}

main {
    flex: 1;
    display: block;
    padding: 2rem 1.25rem;
}

.calculadora-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.calculadora-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 1.25rem 0;
    padding: 0 0.25rem;
}

/* Form Styles */
#calculadora-form {
    width: 100%;
}

.form-category {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #f0f0f0;
}

.form-category:last-of-type {
    border-bottom: none;
}

.category-title {
    color: #667eea;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #667eea;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    color: #555;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background-color: #fafafa;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input::placeholder {
    color: #aaa;
}

/* ===== Inputs modificados por el usuario ===== */

.form-input.is-modified {
    background-color: #fff4d6;          /* amarillo suave */
    border-color: #f0b429;              /* borde destacado */
    box-shadow: 0 0 0 2px rgba(240, 180, 41, 0.25);
}

/* Opcional: transición suave */
.form-input {
    transition: background-color 0.2s ease,
                border-color 0.2s ease,
                box-shadow 0.2s ease;
}

/* ===== Tarjeta con variables modificadas (modo PRO) ===== */

.card-group.is-dirty .card-head {
    background: linear-gradient(
        90deg,
        rgba(240, 180, 41, 0.18),
        rgba(240, 180, 41, 0)
    );
}

.card-group.is-dirty .card-title::after {
    content: " • Modificado";
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(130, 93, 0, 0.9);
    margin-left: 0.4rem;
}

.card-group.is-dirty .card-chevron {
    background: rgba(240, 180, 41, 0.2);
    color: rgba(130, 93, 0, 1);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
    padding-right: 3rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: center;
}

.btn-submit,
.btn-reset {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex: 1;
    max-width: 200px;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-reset {
    background: #f0f0f0;
    color: #666;
    flex: 0.7;
    max-width: 150px;
}

.btn-reset:hover {
    background: #e0e0e0;
    color: #333;
}

/* Results Styles */
.results-container {
    width: 100%;
    animation: fadeIn 0.5s ease-in;
}

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

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #667eea;
}

.results-header h3 {
    color: #667eea;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.btn-back {
    padding: 0.625rem 1.5rem;
    background: #f0f0f0;
    color: #555;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-back:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateX(-3px);
}

.btn-back:active {
    transform: translateX(-1px);
}

.results-content {
    margin-top: 1.5rem;
}

.results-list {
    display: grid;
    gap: 1rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border-left: 4px solid #667eea;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.result-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.result-title {
    font-weight: 600;
    color: #555;
    font-size: 1rem;
}

.result-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #667eea;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    min-width: 80px;
    text-align: center;
}

.no-results {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem;
}

footer {
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: auto;
}

footer p {
    font-size: 0.9rem;
}

/* ==== Gráficos horarios (Highcharts) ==== */

.charts-container {
    margin-top: 2rem;
    border-top: 2px solid #f0f0f0;
    padding-top: 1.5rem;
}

.chart-title {
    margin: 1.5rem 0 0.5rem;
    color: #333;
    font-weight: 600;
    font-size: 1rem;
}

.chart {
    width: 100%;
    height: 400px;
    margin-bottom: 2rem;
}

/* ==== Mapa del heliocampo ==== */

.heliomap-container {
    margin-top: 2rem;
    border-top: 2px solid #f0f0f0;
    padding-top: 1.5rem;
}

.heliomap {
    width: 100%;
    height: 600px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
    margin-bottom: 1rem;
}

.btn-download-heliomap {
    padding: 0.75rem 1.75rem;
    border-radius: 8px;
    border: none;
    background: #667eea;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.btn-download-heliomap:hover {
    background: #4c5fd6;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.btn-download-heliomap:active {
    transform: translateY(0);
}

/* ===== Dashboard / Tarjetas expandibles ===== */

.form-grid {
    display: block;
}

.card-group {
    grid-column: span 6; /* 2 columnas en desktop */
    background: rgba(255, 255, 255, 0.92);
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.55);
}

.card-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.95rem 1.05rem;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.card-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1f2a44;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    font-size: 0.8rem;
    color: rgba(31, 42, 68, 0.65);
}

.card-chevron {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(102, 126, 234, 0.12);
    color: #4c5fd6;
    transition: transform 0.18s ease;
    user-select: none;
}

.card-group.is-expanded .card-chevron { transform: rotate(180deg); }

.card-body {
    padding: 1rem 1.05rem 1.1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Compactar inputs dentro de las tarjetas */
.card-body .form-group { margin-bottom: 0.85rem; }
.card-body .form-group label { font-size: 0.9rem; }

/* Ubicación: mapa + panel selección */
.location-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    align-items: start;
}

.location-panel {
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    padding: 0.9rem;
}

.location-panel h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
    color: #1f2a44;
}

.location-kv {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    margin-top: 0.65rem;
}

.location-kv .kv-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.9rem;
    color: rgba(31, 42, 68, 0.8);
}

.location-kv .kv-val {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #1f2a44;
    padding: 0.4rem 0.6rem;
    border-radius: 10px;
    background: rgba(102, 126, 234, 0.08);
}

/* Acciones al ancho completo */
.form-actions {
    grid-column: span 12;
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
    justify-content: flex-end;
}

/* Ajustes responsive */
@media (max-width: 980px) {
    .card-group { grid-column: span 12; }
    .location-grid { grid-template-columns: 1fr; }
    .form-actions { justify-content: center; }
}

/* Resultados: envolver en tarjeta cuando se muestran */
.results-container {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.55);
}

/* Espacio vertical bajo el mapa */
.card-group[data-card="ubicacion"] {
    margin-bottom: 2.5rem;
}

/* Mapa 50% más alto */
.card-group[data-card="ubicacion"] #map {
    height: 600px !important;
}

/* ===== Columnas fijas (2 columnas independientes) ===== */
.columns {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start; /* evita estirar alturas */
}

.col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Las tarjetas ya no dependen de grid-column */
.card-group {
    width: 100%;
    align-self: flex-start;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

@media (max-width: 980px) {
    .columns {
        flex-direction: column;
    }
    .form-actions {
        justify-content: center;
    }
}

/* ===== Resultados: estilo panel (dashboard oscuro) ===== */

.results-dashboard {
    width: 100%;
    padding: 1.25rem;
    border-radius: 18px;
    background: rgba(10, 16, 35, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.92);
}

.results-dashboard * {
    color: inherit;
}

.results-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.results-title-lg {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 750;
    letter-spacing: 0.2px;
}

.results-subtitle {
    margin-top: 0.25rem;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.65);
}

.results-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-back--ghost {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
}

.btn-back--ghost:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.20);
    transform: none;
}

.btn-primary {
    padding: 0.625rem 1.1rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(112, 94, 255, 0.9);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-primary:hover {
    background: rgba(112, 94, 255, 1);
    box-shadow: 0 10px 24px rgba(112, 94, 255, 0.30);
    transform: translateY(-1px);
}

.results-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.25rem;
    align-items: start;
}

.results-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-card {
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    padding: 1rem;
}

.sidebar-card--compact {
    padding: 0.9rem;
}

.sidebar-card-title {
    font-weight: 750;
    margin-bottom: 0.65rem;
}

.sidebar-card-body {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
}

.status-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(114, 255, 199, 0.95);
    box-shadow: 0 0 0 4px rgba(114, 255, 199, 0.12);
}

.status-muted {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.9rem;
}

.sidebar-pill {
    height: 30px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.results-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.results-section {
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    padding: 1rem;
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.section-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 750;
}

.section-meta {
    margin-top: 0.2rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
}

.kpi-card {
    border-radius: 14px;
    background: rgba(8, 13, 30, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.10);
    padding: 0.9rem;
}

.kpi-card.numero-de-heliostatos-calculados {
    background-image: url('{% static "logos/numero_de_heliostatos_calculados.svg" %}');
    background-size: 30px;
    background-repeat: no-repeat;
    padding-left: 40px;
}



.kpi-title {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: rgba(255, 255, 255, 0.92);
}

.charts-container--dashboard {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.chart-card {
    border-radius: 14px;
    background: rgba(159, 120, 3, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.10);
    padding: 0.9rem;
    margin-bottom: 0.9rem;
}

.heliomap-container--dashboard {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.btn-download-heliomap--dashboard {
    background: rgba(112, 94, 255, 0.9);
}

.btn-download-heliomap--dashboard:hover {
    background: rgba(112, 94, 255, 1);
}

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .results-layout {
        grid-template-columns: 1fr;
    }
    .results-sidebar {
        order: 2;
    }
}


/* Estilo para el logo de cargando */
.loading-spinner {
    text-align: center;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);  /* Color de fondo ligeramente más oscuro */
    padding: 20px;
    border-radius: 10px;
    z-index: 9999;  /* Asegura que el spinner se muestre sobre otros elementos */
    display: none;  /* Se oculta inicialmente */
}

.loading-spinner img {
    width: 200px;  /* Ajusta el tamaño del logo de carga */
    height: 200px;
}

.loading-spinner p {
    color: white;
    margin-top: 10px;
    font-size: 1rem;
}

/* Estilo para el botón de reseteo de zoom */
.btn-reset-zoom {
    background: #f0f0f0;
    color: #333;
    border: 2px solid #e0e0e0;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 5px;
    margin-top: 1rem;
}

.btn-reset-zoom:hover {
    background: #e0e0e0;
    color: #000;
}

.chart {
    width: 100%;
    height: 400px;
    margin-bottom: 2rem;
}