/* ==========================================================================
   Calculadora de camperización: Balance 12V/24V y Báscula ITV - Estilos canónicos
   Fijate Tools - Responsive, Dark/Light Mode, Touch Friendly
   ========================================================================== */

:root {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #0284c7;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-primary: #0b1329;
  --bg-card: #131f37;
  --bg-card-hover: #1c2b4d;
  --bg-input: #0f1a30;
  --border-color: #1e2e4f;
  --border-focus: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-primary: #38bdf8;
  --accent-primary-hover: #0284c7;
  --accent-success: #34d399;
  --accent-warning: #fbbf24;
  --accent-danger: #f87171;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  width: 100%;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Layout */
.main-wrapper {
  flex: 1 0 auto;
  width: 100%;
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
}

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

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Header de la herramienta */
.intro-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.intro-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(2, 132, 199, 0.12);
  color: var(--accent-primary);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(2, 132, 199, 0.25);
}

.intro-title {
  font-size: 1.6rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.intro-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 800px;
}

/* Pestañas de navegación superiores */
.camper-tabs-nav {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.camper-tab-btn {
  flex: 1;
  min-width: 180px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.camper-tab-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.camper-tab-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.camper-tab-content {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}

.camper-tab-content.active {
  display: flex;
}

/* Tarjetas de sección */
.card-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.section-title {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Formularios y cuadrículas */
.grid-form-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.grid-form-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

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

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-select, .form-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 40px;
  appearance: none;
  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 14px center;
  cursor: pointer;
}

.form-select:focus, .form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.form-select option, .form-select optgroup {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

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

.input-with-unit input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.input-with-unit input:focus {
  outline: none;
}

.input-with-unit .unit-tag {
  padding: 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card-hover);
  height: 100%;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border-color);
  white-space: nowrap;
}

/* HUD Tiles */
.hud-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
}

.hud-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

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

.hud-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.hud-val-box {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.hud-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hud-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Lista de aparatos eléctricos */
.appliances-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.appliance-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
}

.appliance-row.is-disabled {
  opacity: 0.55;
  background: transparent;
}

.appliance-check-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
}

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

.app-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.appliance-inputs-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.appliance-inputs-group .input-with-unit {
  width: 105px;
  height: 38px;
}

.app-daily-subtotal {
  min-width: 90px;
  text-align: right;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.25rem;
}

.subtotal-val {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
}

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

.btn-remove-app {
  background: transparent;
  border: none;
  color: var(--accent-danger);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 0.35rem;
  line-height: 1;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 42px;
  padding: 0 1.25rem;
  background: transparent;
  color: var(--accent-primary);
  border: 1px dashed var(--accent-primary);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.btn-secondary:hover {
  background: rgba(2, 132, 199, 0.08);
}

/* Resultados cálculo cable */
.cable-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.cable-result-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  text-align: center;
}

.cable-result-card.featured {
  border-color: var(--accent-primary);
  background: rgba(2, 132, 199, 0.06);
}

.cable-res-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.cable-res-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.cable-res-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

/* Semáforo de ITV */
.itv-status-box {
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.itv-status-box.status-good {
  background: rgba(16, 185, 129, 0.08);
  border-color: var(--accent-success);
}

.itv-status-box.status-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: var(--accent-warning);
}

.itv-status-box.status-illegal {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--accent-danger);
}

.itv-status-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.itv-status-desc {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* FAQ */
.faq-item {
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.faq-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Responsive */
@media (max-width: 860px) {
  .appliance-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .appliance-inputs-group {
    width: 100%;
    justify-content: space-between;
  }

  .appliance-inputs-group .input-with-unit {
    width: 90px;
  }

  .camper-tabs-nav {
    flex-direction: column;
  }

  .camper-tab-btn {
    width: 100%;
    min-width: 0;
  }
}

/* Impresión */
@media print {
  header, footer, .camper-tabs-nav, .tool-ad-sidebar, .tools-ad-banner-section, .btn-secondary, .btn-remove-app {
    display: none !important;
  }

  .camper-tab-content {
    display: flex !important;
  }

  .card-section {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }
}
