/**
 * Estilos específicos para Dimensionador de Generador Eléctrico y SAI
 * 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;
    --color-inverter: #10b981;
    --color-avr: #f59e0b;
    --color-ups: #8b5cf6;

    --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);
}

/* Grid de aparatos seleccionables */
.appliances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.appliance-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: all 0.2s ease;
}

.appliance-card.selected {
    border-color: var(--color-primary);
    background: rgba(2, 132, 199, 0.05);
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.appliance-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.925rem;
    color: var(--text-heading);
}

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

.badge-sensitive {
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-ups);
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 0.2rem 0.5rem;
    border-radius: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.appliance-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.counter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--border-color);
}

.counter-label { font-size: 0.8rem; color: var(--text-muted); }

.counter-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-count {
    width: 28px;
    height: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.count-val {
    font-family: var(--font-mono);
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

/* Añadir carga personalizada */
.custom-add-card {
    background: var(--bg-input);
    border: 1px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.custom-add-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
}

.custom-form-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.custom-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1 1 180px;
}

.custom-field label { font-size: 0.775rem; font-weight: 600; color: var(--text-muted); }
.custom-field input[type="text"], .custom-field input[type="number"] {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.4rem;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-main);
    color: var(--text-main);
    min-height: 38px;
}

.custom-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.custom-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 0.5rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.85rem;
}

.btn-remove-custom {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Tarjeta recomendación de tecnología */
.tech-banner {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.badge-tech {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 0.4rem;
    font-weight: 800;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.badge-inverter {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-avr {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.tech-desc { margin: 0; font-size: 0.925rem; line-height: 1.55; }

/* KPIs */
.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.6rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-heading);
    margin: 0;
}

/* Tarjeta SAI / UPS */
.ups-card {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.ups-title {
    font-size: 1.1rem;
    margin: 0 0 0.5rem 0;
    color: var(--color-ups);
    font-weight: 700;
}

.ups-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.ups-metric-label { font-size: 0.8rem; color: var(--text-muted); display: block; }
.ups-metric-val { font-size: 1.3rem; font-weight: 800; font-family: var(--font-mono); color: var(--text-heading); }

.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; }
