/* ==========================================================================
   Estimador de costas procesales y aranceles - Fijate Tools
   Estándares canónicos: Inter, Outfit, JetBrains Mono, Midnight Slate,
   responsive mobile-first, controles táctiles >=40px, escenarios de riesgo.
   ========================================================================== */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta Midnight Slate */
  --bg-page: #0b0f17;
  --bg-card: #131b26;
  --bg-card-subtle: #192433;
  --bg-card-hover: #1f2c3e;
  --border-card: #223247;
  --border-focus: #3b82f6;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #38bdf8;

  --legal-green: #10b981;
  --legal-green-bg: rgba(16, 185, 129, 0.15);
  --legal-green-border: rgba(16, 185, 129, 0.35);

  --legal-red: #ef4444;
  --legal-red-bg: rgba(239, 68, 68, 0.12);
  --legal-red-border: rgba(239, 68, 68, 0.3);

  --legal-gold: #f59e0b;
  --legal-gold-bg: rgba(245, 158, 11, 0.18);
  --legal-gold-border: rgba(245, 158, 11, 0.45);

  --legal-blue: #0ea5e9;
  --legal-blue-bg: rgba(14, 165, 233, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-card: #cbd5e1;
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --accent: #0284c7;

  --legal-green-bg: rgba(16, 185, 129, 0.12);
  --legal-red-bg: rgba(239, 68, 68, 0.1);
  --legal-gold-bg: rgba(245, 158, 11, 0.12);
  --legal-blue-bg: rgba(14, 165, 233, 0.12);
}

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

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

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.hero-title,
.card-title {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.mono, code, .price-val {
  font-family: var(--font-mono);
}

/* Suite Nav Bar */
.suite-nav-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-card);
  padding: 0.6rem 1rem;
  margin-bottom: 1.5rem;
}

.suite-nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.suite-badge-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  white-space: nowrap;
  padding-right: 0.5rem;
  border-right: 1px solid var(--border-card);
}

.suite-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all 0.15s ease;
  min-height: 36px;
}

.suite-link:hover {
  color: var(--text-primary);
  background: var(--bg-card-subtle);
}

.suite-link.is-active {
  color: #ffffff;
  background: var(--primary);
  font-weight: 600;
}

/* Layout */
.tool-layout {
  max-width: 1200px;
  margin: 0 auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

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

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

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .main-grid {
    grid-template-columns: 380px 1fr;
  }
}

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

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

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-control,
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 0.85rem;
  font-family: var(--font-main);
  font-size: 0.95rem;
  color: var(--text-primary);
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.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='%2394a3b8' 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 12px center;
  background-size: 16px;
  cursor: pointer;
}

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

.form-control:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.85rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.toggle-label {
  display: flex;
  flex-direction: column;
}

.toggle-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.toggle-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.switch-control {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-switch {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-card);
  transition: 0.2s ease;
  border-radius: 24px;
}

.slider-switch:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s ease;
  border-radius: 50%;
}

.switch-control input:checked + .slider-switch {
  background-color: var(--primary);
}

.switch-control input:checked + .slider-switch:before {
  transform: translateX(20px);
}

/* Preset chips */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.preset-chip {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* Cuadro de resumen por conceptos */
.costs-breakdown-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.costs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-card);
  font-size: 0.9rem;
}

.costs-row:last-child {
  border-bottom: none;
}

.costs-row.row-total {
  font-size: 1.15rem;
  font-weight: 700;
  padding-top: 0.85rem;
  border-top: 2px solid var(--border-card);
  margin-top: 0.5rem;
}

.row-label {
  display: flex;
  flex-direction: column;
}

.row-sublabel {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.row-value {
  font-family: var(--font-mono);
  font-weight: 600;
}

.cap-warning-badge {
  background: var(--legal-gold-bg);
  border: 1px solid var(--legal-gold-border);
  color: var(--legal-gold);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  margin-top: 0.75rem;
  line-height: 1.4;
}

/* Tarjetas de Escenarios comparativos de riesgo */
.scenarios-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 650px) {
  .scenarios-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.scenario-card.card-win {
  border-color: var(--legal-green-border);
  background: linear-gradient(180deg, var(--legal-green-bg), var(--bg-card));
}

.scenario-card.card-defeat {
  border-color: var(--legal-red-border);
  background: linear-gradient(180deg, var(--legal-red-bg), var(--bg-card));
}

.scenario-card.card-nocosts {
  border-color: var(--border-card);
  background: var(--bg-card-subtle);
}

.scenario-header {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card-win .scenario-header { color: var(--legal-green); }
.card-defeat .scenario-header { color: var(--legal-red); }
.card-nocosts .scenario-header { color: var(--accent); }

.scenario-figure {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-mono);
  margin-bottom: 0.35rem;
}

.scenario-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Gráfico de barras porcentuales */
.distribution-graph-box {
  margin-top: 1.5rem;
  padding: 1.15rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
}

.dist-bar-track {
  height: 18px;
  background: var(--border-card);
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  margin-bottom: 0.75rem;
}

.dist-bar-segment {
  height: 100%;
  transition: width 0.3s ease;
}

.dist-segment-lawyer { background: var(--primary); }
.dist-segment-procurator { background: var(--accent); }
.dist-segment-taxes { background: var(--legal-gold); }

.dist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.dist-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dist-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* Botones de acción */
.action-buttons-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-legal-action {
  flex: 1 1 auto;
  min-height: 42px;
  padding: 0 1.2rem;
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-primary-action {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary-action:hover {
  background: var(--primary-hover);
}

.btn-secondary-action {
  background: var(--bg-card-subtle);
  border-color: var(--border-card);
  color: var(--text-primary);
}

.btn-secondary-action:hover {
  background: var(--bg-card-hover);
}

/* Modales canónicos */
.canonical-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.canonical-modal.is-open {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 2;
  animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.5rem;
}

.modal-body {
  padding: 1.25rem;
  font-size: 0.9rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-card);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: var(--bg-card-subtle);
}

/* Print */
@media print {
  .app-header,
  .suite-nav-bar,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .fijate-footer,
  .action-buttons-group,
  .chips-row {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card-main,
  .costs-breakdown-card,
  .scenario-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #000000 !important;
  }
}
