/* ==========================================================================
   lineasat.cl - Capacidad Térmica de Cortocircuito (IEC 60865-1 / IEC 60909-0)
   © 2026 Desarrollado por repositorIA
   ========================================================================== */
:root {
  --bg-primary: #0b1320;
  --bg-secondary: #111e33;
  --bg-card: #162642;
  --bg-input: #0e1a2e;
  --border-color: #243b61;
  --border-focus: #38bdf8;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-cyan: #38bdf8;
  --accent-blue: #2563eb;
  --accent-green: #22c55e;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans); background: var(--bg-primary); color: var(--text-main);
  line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column;
}

/* Encabezado */
.app-header {
  background: rgba(17, 30, 51, 0.95); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-color);
  padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  flex-wrap: wrap; position: sticky; top: 0; z-index: 50;
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
}
.brand-title { font-weight: 700; font-size: 1.05rem; }
.brand-title span { color: var(--accent-cyan); }
.brand-desc { font-size: 0.8rem; color: var(--text-muted); }
.header-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.norm-badge {
  font-size: 0.72rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-color);
  color: var(--text-muted); background: var(--bg-secondary);
}
.nav-link-back { color: var(--accent-cyan); text-decoration: none; font-size: 0.85rem; margin-right: 6px; }
.nav-link-back:hover { text-decoration: underline; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius-sm); font-family: inherit;
  font-size: 0.82rem; font-weight: 600; padding: 7px 12px; cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s ease; white-space: nowrap;
}
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: var(--bg-secondary); color: var(--text-main); border-color: var(--border-color); }
.btn-secondary:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border-color); padding: 5px 9px; }
.btn-ghost:hover { color: var(--accent-red); border-color: var(--accent-red); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Diseño principal */
.app-container {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; padding: 20px 24px;
  max-width: 1600px; width: 100%; margin: 0 auto; flex: 1;
}
.sidebar, .content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 18px;
}
.card-title {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; color: var(--text-main);
}
.card-title .icon { margin-right: 6px; }
.card-sub { font-size: 0.78rem; color: var(--text-muted); margin: -8px 0 12px; }

/* Formularios */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 11px; }
.form-group label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input-wrap { display: flex; align-items: stretch; }
.input-wrap .unit {
  display: grid; place-items: center; padding: 0 9px; font-size: 0.75rem; color: var(--text-dim);
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; white-space: nowrap;
}
.input-wrap input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
input, select {
  width: 100%; background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 7px 9px; font-family: inherit; font-size: 0.85rem; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--border-focus); }
input[readonly] { color: var(--accent-cyan); background: var(--bg-secondary); font-family: var(--font-mono); }
.hint { font-size: 0.72rem; color: var(--text-dim); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; cursor: pointer; }
.check input { width: auto; margin-top: 3px; }
.derived {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 0.82rem; padding: 10px 12px;
  border-radius: var(--radius-md); background: var(--bg-secondary); border: 1px solid var(--border-color);
}
.derived span:nth-child(even) { font-family: var(--font-mono); color: var(--accent-cyan); text-align: right; }
.derived .strong { color: var(--text-main); font-weight: 700; }

/* Tabla de conductores */
.table-scroll { overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th {
  background: var(--bg-secondary); color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.03em; padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
td { padding: 7px 8px; border-bottom: 1px solid rgba(36, 59, 97, 0.6); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.cond-table input, .cond-table select { padding: 5px 7px; font-size: 0.8rem; }
.cond-table .w-xs { width: 62px; }
.cond-table .w-sm { width: 82px; }
.cond-table .w-md { width: 120px; }
.cond-table .w-lg { min-width: 230px; }
.cond-table select[data-f="materialKey"] { min-width: 215px; }
.cond-meta { font-size: 0.7rem; color: var(--text-dim); margin-top: 3px; }
.cond-meta a { color: var(--accent-cyan); text-decoration: none; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* Resultados */
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.res-card { border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 14px; background: var(--bg-secondary); }
.res-card h4 { font-size: 0.88rem; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.res-card dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 0.8rem; }
.res-card dt { color: var(--text-muted); }
.res-card dd { font-family: var(--font-mono); text-align: right; }
.pill { font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: rgba(34, 197, 94, 0.15); color: var(--accent-green); border: 1px solid rgba(34, 197, 94, 0.4); }
.pill-bad { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.4); }
.ok { color: var(--accent-green); font-weight: 700; }
.bad { color: var(--accent-red); font-weight: 700; }
.chart-box { position: relative; height: 360px; }
.note { font-size: 0.78rem; color: var(--text-muted); line-height: 1.6; }
.note p + p { margin-top: 6px; }
.note code { font-family: var(--font-mono); color: var(--accent-cyan); }
.empty { padding: 26px; text-align: center; color: var(--text-dim); font-size: 0.85rem; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bg-card); color: var(--text-main);
  border: 1px solid var(--accent-cyan); padding: 9px 16px; border-radius: var(--radius-md); font-size: 0.82rem;
  box-shadow: var(--shadow-md); z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

footer { text-align: center; padding: 18px; color: var(--text-dim); font-size: 0.78rem; border-top: 1px solid var(--border-color); }
footer a { color: var(--accent-cyan); text-decoration: none; }

@media (max-width: 980px) {
  .app-container { grid-template-columns: 1fr; padding: 16px; }
  .app-header { padding: 10px 16px; }
}

/* Informe impreso */
#print-report { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; color: #000; }
  .app-header, .app-container, footer, .toast, #feedback-widget, [id*="feedback"] { display: none !important; }
  #print-report { display: block; font-family: Arial, sans-serif; font-size: 10pt; color: #000; }
  #print-report h1 { font-size: 15pt; margin-bottom: 2mm; }
  #print-report h2 { font-size: 11.5pt; margin: 5mm 0 2mm; border-bottom: 1px solid #1f3a5f; color: #1f3a5f; }
  #print-report table { width: 100%; border-collapse: collapse; margin-bottom: 3mm; font-size: 9pt; }
  #print-report th, #print-report td { border: 1px solid #999; padding: 1.2mm 2mm; color: #000; background: none; text-transform: none; letter-spacing: 0; }
  #print-report th { background: #1f3a5f !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-report td.num { text-align: right; }
  #print-report img { width: 100%; max-height: 90mm; object-fit: contain; }
  #print-report .meta { color: #444; font-size: 9pt; }
}

/* Efectos mecánicos */
.mech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
#mechTable td:first-child { white-space: nowrap; }
#mechTable tr.key td { font-weight: 700; color: var(--text-main); }
