/* ==========================================================
   FinTech Suite - Estilos CSS Profesionales
   ========================================================== */

:root {
  /* Color Tokens */
  --bg-primary: #1c273a;
  --bg-surface: #111827;
  --bg-surface-elevated: #1a2234;
  --bg-surface-hover: #222d42;
  --bg-input: #0d131f;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --border-hover: rgba(255, 255, 255, 0.16);

  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  /* Accent Colors */
  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-emerald-subtle: rgba(16, 185, 129, 0.15);
  --accent-amber: #f59e0b;
  --accent-amber-subtle: rgba(245, 158, 11, 0.15);
  --accent-rose: #f43f5e;
  --accent-rose-subtle: rgba(244, 63, 94, 0.15);

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
  --shadow-glow-blue: 0 0 25px -5px rgba(59, 130, 246, 0.3);
  --shadow-glow-green: 0 0 25px -5px rgba(16, 185, 129, 0.3);

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* Reset & Base Setup */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Background Lights */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.glow-top-left {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #2563eb, transparent 70%);
  top: -150px;
  left: -150px;
}

.glow-bottom-right {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #059669, transparent 70%);
  bottom: -200px;
  right: -200px;
}

/* Container */
.app-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  position: relative;
  z-index: 1;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.header-brand-group {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.logo-wrapper:hover {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.15);
  transform: translateY(-1px);
}

.app-logo {
  height: 52px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #3b82f6;
  border-radius: 50%;
  box-shadow: 0 0 8px #3b82f6;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.3);
    opacity: 1;
    box-shadow: 0 0 12px #60a5fa;
  }

  100% {
    transform: scale(0.95);
    opacity: 0.8;
  }
}

.main-title {
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.35rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.98rem;
  max-width: 580px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.scenario-buttons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.scenario-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 0.25rem;
  margin-left: 0.25rem;
}

/* Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  border: 1px solid transparent;
  outline: none;
  user-select: none;
}

.btn-chip {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  border-radius: var(--radius-sm);
}

.btn-chip:hover {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-outline:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: #ffffff;
  box-shadow: var(--shadow-glow-blue);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 2rem;
  align-items: start;
}

/* Layers Column */
.layers-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Layer Card Design */
.layer-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.layer-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-primary);
  opacity: 0.8;
}

#cardLayer1::before {
  background: #3b82f6;
}

#cardLayer2::before {
  background: #06b6d4;
}

#cardLayer3::before {
  background: #f59e0b;
}

#cardLayer4::before {
  background: #10b981;
}

.layer-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
}

.layer-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.layer-tag {
  background: var(--bg-surface-elevated);
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.final-tag {
  background: var(--accent-emerald-subtle);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}

.layer-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text-primary);
}

.layer-badge {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-surface-elevated);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.layer-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

/* Forms & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

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

.form-group.full-width {
  grid-column: span 2;
}

label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.tooltip {
  cursor: help;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: 0.35rem;
}

.input-currency-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-symbol {
  position: absolute;
  left: 1rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 1.05rem;
  pointer-events: none;
  user-select: none;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  padding: 0.75rem 1rem;
  transition: var(--transition-fast);
  outline: none;
}

.currency-input {
  padding-left: 2.2rem;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  background: #0f172a;
}

.select-wrapper {
  position: relative;
}

.select-control {
  appearance: none;
  cursor: pointer;
  padding-right: 2.5rem;
  font-weight: 500;
}

.select-arrow {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.75rem;
  pointer-events: none;
}

/* Calculated Results Row */
.calculated-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  background: var(--bg-surface-elevated);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.calculated-row.highlight-net {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(5, 150, 105, 0.02));
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.calc-metric {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.calc-metric.full-width {
  grid-column: span 2;
}

.metric-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.metric-value.highlight {
  color: #60a5fa;
}

.metric-value.text-warning {
  color: var(--accent-amber);
}

.metric-value.net-value {
  font-size: 1.45rem;
  color: #34d399;
}

.metric-value.net-margin {
  font-size: 1.45rem;
  color: #34d399;
}

.metric-value.is-loss {
  color: var(--accent-rose) !important;
}

/* Progress bar inside layer cards */
.progress-container {
  height: 4px;
  background: var(--bg-input);
  border-radius: 999px;
  margin-top: 0.75rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  transition: width 0.4s ease;
  border-radius: 999px;
}

.progress-gross {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.progress-operating {
  background: linear-gradient(90deg, #06b6d4, #22d3ee);
}

.progress-net {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.tax-note {
  font-size: 0.78rem;
  color: var(--accent-amber);
  margin-top: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--accent-amber-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Summary / Dashboard Column */
.summary-section {
  position: sticky;
  top: 1.5rem;
}

.summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}

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

.summary-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.status-indicator {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.status-healthy {
  background: var(--accent-emerald-subtle);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.status-warning {
  background: var(--accent-amber-subtle);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.status-danger {
  background: var(--accent-rose-subtle);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.3);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.kpi-box {
  background: var(--bg-surface-elevated);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform var(--transition-fast);
}

.kpi-box:hover {
  transform: translateY(-2px);
}

.kpi-box.highlight-kpi {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.04));
  border-color: rgba(16, 185, 129, 0.3);
}

.kpi-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.22rem;
  font-weight: 700;
  color: #ffffff;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Breakdown Waterfall Bar */
.breakdown-section {
  background: var(--bg-surface-elevated);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
}

.breakdown-header {
  margin-bottom: 0.75rem;
}

.breakdown-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.cascade-bar {
  height: 14px;
  background: var(--bg-input);
  border-radius: 999px;
  display: flex;
  overflow: hidden;
  margin-bottom: 0.9rem;
  border: 1px solid var(--border-subtle);
}

.segment {
  height: 100%;
  transition: width 0.35s ease;
}

.segment-cost {
  background: #f43f5e;
}

.segment-expenses {
  background: #f97316;
}

.segment-tax {
  background: #f59e0b;
}

.segment-net {
  background: #10b981;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

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

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-cost {
  background: #f43f5e;
}

.dot-expenses {
  background: #f97316;
}

.dot-tax {
  background: #f59e0b;
}

.dot-net {
  background: #10b981;
}

/* Financial Statement Table */
.statement-table-wrapper {
  margin-bottom: 1.5rem;
}

.statement-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.statement-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.statement-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.statement-table td {
  padding: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.row-highlight {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
}

.row-subtotal {
  background: rgba(59, 130, 246, 0.06);
  border-top: 1px solid rgba(59, 130, 246, 0.2);
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.row-total {
  background: rgba(16, 185, 129, 0.1);
  border-top: 2px solid rgba(16, 185, 129, 0.4);
  font-weight: 700;
  color: #34d399;
}

.text-right {
  text-align: right;
}

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

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

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

/* Summary Action Buttons */
.summary-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

/* Footer */
.app-footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Toast Message */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1f2937;
  color: #f9fafb;
  padding: 0.85rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-emerald);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .summary-section {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
  }

  .header-brand-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .app-logo {
    height: 44px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-group.full-width {
    grid-column: span 1;
  }

  .calculated-row {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .summary-actions {
    grid-template-columns: 1fr;
  }
}

/* Print Optimization */
@media print {
  body {
    background: #ffffff;
    color: #000000;
  }

  .glow-orb,
  .header-actions,
  .summary-actions,
  .scenario-buttons,
  #btnReset,
  .toast {
    display: none !important;
  }

  .app-container {
    max-width: 100%;
    padding: 0;
  }

  .dashboard-grid {
    display: block;
  }

  .layer-card,
  .summary-card {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    margin-bottom: 1.5rem;
    page-break-inside: avoid;
  }

  .metric-value,
  .main-title,
  .layer-title,
  .summary-title {
    color: #000000 !important;
    -webkit-text-fill-color: initial !important;
  }

  .form-control {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #aaaaaa !important;
  }

  .statement-table th,
  .statement-table td {
    color: #000000 !important;
    border-color: #dddddd !important;
  }
}