/**
 * Estilos canónicos del Diagnóstico de Estados Financieros DuPont y Altman Z
 * Fijate Tools • Financial Analysis
 */

:root {
  --bg-body: #0a0e17;
  --bg-card: #121826;
  --bg-card-subtle: #182234;
  --bg-card-hover: #1f2c42;
  --border-color: #26334d;
  --border-focus: #3b82f6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #ff8507;
  --accent-glow: rgba(255, 133, 7, 0.18);
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #f43f5e;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-mono: 'JetBrains Mono', monospace;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --border-focus: #2563eb;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #ea580c;
  --accent-glow: rgba(234, 88, 12, 0.12);
  --green: #059669;
  --yellow: #d97706;
  --red: #e11d48;
}

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

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

.main-wrapper.tool-layout {
  max-width: 1360px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1;
}

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

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

/* Presets Bar */
.card-presets {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.presets-header {
  margin-bottom: 0.65rem;
}

.presets-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

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

.btn-preset:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.btn-preset.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Formulario Financiero */
.card-financial-inputs {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.section-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.badge-balance-check {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
  border: 1px solid var(--green);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

.financial-inputs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .financial-inputs-grid {
    grid-template-columns: 1fr;
  }
}

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

.column-subtitle {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.inputs-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.form-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  color: var(--text-main);
  font-size: 0.9rem;
  min-height: 38px;
  outline: none;
}

.form-input:focus {
  border-color: var(--border-focus);
}

/* PIRÁMIDE DUPONT EN 5 FACTORES */
.card-dupont-pyramid {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.roe-badge-hero {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
}

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

.roe-badge-hero strong {
  font-size: 1.35rem;
  color: var(--accent);
}

.dupont-factors-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.85rem;
}

@media (max-width: 1024px) {
  .dupont-factors-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 650px) {
  .dupont-factors-grid {
    grid-template-columns: 1fr;
  }
}

.dupont-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: transform 0.2s ease;
}

.dupont-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.factor-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.factor-val {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.factor-formula {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.factor-expl {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* ALTMAN Z-SCORE */
.card-altman-z {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.z-badge-hero {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
}

.z-badge-safe {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
  border-color: var(--green);
}

.z-badge-gray {
  background: rgba(245, 158, 11, 0.15);
  color: var(--yellow);
  border-color: var(--yellow);
}

.z-badge-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--red);
  border-color: var(--red);
}

.z-score-visual-gauge {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.z-score-val-box {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.z-score-label {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.z-score-val-box strong {
  font-size: 2.2rem;
  color: var(--text-main);
  line-height: 1;
}

.z-zones-bar {
  position: relative;
  height: 38px;
  display: flex;
  border-radius: var(--radius-sm);
  overflow: visible;
}

.zone-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
  padding: 0 0.5rem;
  text-align: center;
}

.zone-danger { flex: 1.23; background: #ef4444; border-radius: 6px 0 0 6px; }
.zone-gray { flex: 1.67; background: #f59e0b; }
.zone-safe { flex: 2.5; background: #10b981; border-radius: 0 6px 6px 0; }

.z-marker-pin {
  position: absolute;
  top: -24px;
  transform: translateX(-50%);
  background: var(--text-main);
  color: var(--bg-body);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: left 0.3s ease;
}

.z-variables-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.dupont-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.dupont-table th, .dupont-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-color);
}

.dupont-table th {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-weight: 600;
}

/* RATIOS PANEL */
.card-ratios-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ratios-categories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .ratios-categories-grid {
    grid-template-columns: 1fr;
  }
}

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

.ratios-category-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.ratios-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ratio-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
}

.ratio-name {
  color: var(--text-muted);
}

/* INFORME EJECUTIVO */
.card-executive-summary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.executive-content {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.executive-content strong {
  color: var(--text-main);
}

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

.font-bold {
  font-weight: 700;
}

/* Modales */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-dialog-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 40px;
}
