/**
 * Estilos específicos para Simulador de Certificado de Eficiencia Energética (CEE)
 * Fijate Tools
 */

:root {
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --color-primary: #0284c7;
    --color-primary-hover: #0369a1;

    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-heading: #1e293b;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-page: #0b0f17;
    --bg-card: #131b2b;
    --bg-input: #1a2438;
    --border-color: #243048;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-heading: #ffffff;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-main);
    background-color: var(--bg-page);
    color: var(--text-main);
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, .brand-title, .calc-title, .section-title {
    font-family: var(--font-heading);
    color: var(--text-heading);
    letter-spacing: -0.02em;
}

.text-mono { font-family: var(--font-mono); }

.tool-layout {
    max-width: 1200px;
    margin: 1.5rem auto 3rem;
    padding: 0 1rem;
    box-sizing: border-box;
    flex: 1 0 auto;
    width: 100%;
}

.tool-with-sidebar {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    width: 100%;
}

.tool-main-content {
    flex: 1 1 0%;
    min-width: 0;
    width: 100%;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.75rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}

@media (max-width: 640px) {
    .tool-card { padding: 1.25rem; }
}

.tool-header-block {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.25rem;
}

.calc-title { font-size: 1.6rem; margin: 0 0 0.5rem 0; font-weight: 700; }
.calc-subtitle { margin: 0; color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; }

.presets-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.btn-preset {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}

.btn-preset:hover, .btn-preset.active {
    background: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.field-label { font-size: 0.875rem; font-weight: 600; color: var(--text-heading); }
.field-hint { font-size: 0.775rem; color: var(--text-muted); }

.input-with-unit {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.input-with-unit input[type="number"] {
    flex: 1 1 0%;
    width: 0;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 0.65rem 0.85rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--text-main);
    min-height: 40px;
}

.input-unit {
    padding: 0 0.85rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.03);
    height: 100%;
    display: flex;
    align-items: center;
}

select.custom-select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
    padding: 0.65rem 2.5rem 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-input);
    color: var(--text-main);
    border-radius: 0.5rem;
    font-family: var(--font-main);
    font-size: 0.9rem;
    min-height: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' 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 0.85rem center;
    background-size: 16px;
    cursor: pointer;
}

/* Escalera energética oficial (A a G) */
.ladder-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.ladder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ladder-badges-comparison {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.letter-badge-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.badge-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.energy-badge-large {
    width: 60px;
    height: 60px;
    border-radius: 0.75rem;
    color: #ffffff;
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.ladder-arrow-transition {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.energy-ladder-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ladder-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ladder-bar {
    height: 34px;
    color: #ffffff;
    font-weight: 800;
    font-family: var(--font-heading);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-radius: 0 17px 17px 0;
    font-size: 1.1rem;
    transition: width 0.3s ease;
}

.bar-a { width: 35%; }
.bar-b { width: 44%; }
.bar-c { width: 53%; }
.bar-d { width: 62%; }
.bar-e { width: 71%; }
.bar-f { width: 80%; }
.bar-g { width: 90%; }

.bar-limit {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    font-weight: 500;
    opacity: 0.9;
}

.ladder-marker {
    padding: 0.35rem 0.75rem;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    animation: fadeIn 0.3s ease;
}

.marker-current {
    background: var(--bg-card);
    border: 2px solid var(--text-heading);
    color: var(--text-heading);
}

.marker-upgraded {
    background: #10b981;
    color: #ffffff;
}

.marker-both {
    background: #0284c7;
    color: #ffffff;
}

/* KPIs de consumo y CO2 */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.2rem;
    text-align: center;
}

.kpi-label {
    font-size: 0.775rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
    display: block;
}

.kpi-value {
    font-size: 1.55rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-heading);
    margin: 0;
}

/* Aviso de deducción IRPF */
.irpf-notice {
    border-radius: 0.75rem;
    padding: 1.2rem 1.5rem;
    margin-bottom: 2rem;
    line-height: 1.55;
    font-size: 0.925rem;
}

.irpf-eligible {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid #10b981;
    color: var(--text-heading);
}

.irpf-pending {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid #f59e0b;
    color: var(--text-heading);
}

/* Lista de mejoras recomendadas */
.upgrades-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.upgrade-item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.upgrade-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.upgrade-title { font-size: 0.925rem; color: var(--text-heading); }
.upgrade-cost { font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-mono); }

.impact-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.35rem 0.65rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.action-bar { display: flex; justify-content: flex-end; margin-bottom: 2rem; }
.btn-primary {
    background: var(--color-primary); color: #ffffff; border: none; padding: 0.75rem 1.5rem;
    border-radius: 0.5rem; font-family: var(--font-main); font-weight: 600; font-size: 0.95rem;
    cursor: pointer; display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px;
}
.btn-primary:hover { background: var(--color-primary-hover); }

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 9999; padding: 1rem;
}
.modal-card {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 1rem;
    width: 100%; max-width: 650px; max-height: 90vh; overflow-y: auto; padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1rem;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-title { margin: 0; font-size: 1.25rem; }
.btn-icon-close {
    background: transparent; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer;
    min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center;
}
.modal-textarea {
    width: 100%; height: 240px; font-family: var(--font-mono); font-size: 0.85rem;
    background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border-color);
    border-radius: 0.5rem; padding: 0.75rem; resize: vertical; box-sizing: border-box;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; }

/* SEO Guía */
.seo-guide-section {
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 1rem;
    padding: 2rem; margin-bottom: 2.5rem;
}
.seo-guide-title { font-size: 1.5rem; margin: 0 0 1rem 0; }
.seo-guide-content p { line-height: 1.7; color: var(--text-main); margin-bottom: 1rem; }
.faq-list { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.faq-item { border: 1px solid var(--border-color); border-radius: 0.5rem; background: var(--bg-input); overflow: hidden; }
.faq-question { padding: 1rem; font-weight: 600; cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; color: var(--text-heading); }
.faq-answer { padding: 0 1rem 1rem; color: var(--text-muted); line-height: 1.6; font-size: 0.925rem; }
