/* ============================================================
   Smart Credit — Design System & Application Styles
   Marca (medida del logo): azul #2E4E8B, turquesa #1B9BC0, cian #4FD8E8, naranja #F57E17, azul marino #122341.
   Tipografía: Montserrat, alojada en este mismo servidor (sin pedirle nada a terceros).
   ============================================================ */

@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/montserrat-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/montserrat-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/montserrat-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/montserrat-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 800; font-display: swap; src: url('../fonts/montserrat-latin-800-normal.woff2') format('woff2'); }

/* ─── CSS Custom Properties ─────────────────────────────── */
:root {
  --blue-deep:     #122341;
  --blue-mid:      #2E4E8B;
  --blue-light:    #1B9BC0;
  --blue-pale:     #E8EDF6;
  --green:         #2e7d32;
  --green-light:   #43A047;
  --green-pale:    #E8F5E9;
  --amber:         #F57E17;
  --amber-pale:    #FFF8E1;
  --red:           #C62828;
  --red-pale:      #FFEBEE;
  --bg:            #F4F6FB;
  --surface:       #ffffff;
  --surface-2:     #f9fafb;
  --border:        #DCE2EE;
  --text-primary:  #0f172a;
  --text-secondary:#475569;
  --text-muted:    #94a3b8;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 16px rgba(18,35,65,.12), 0 2px 6px rgba(18,35,65,.08);
  --shadow-lg:     0 20px 48px rgba(18,35,65,.18), 0 8px 20px rgba(18,35,65,.10);
  --radius:        16px;
  --radius-sm:     10px;
  --radius-pill:   999px;
  --nav-h:         64px;
  --header-h:      64px;
  --transition:    all .25s cubic-bezier(.4,0,.2,1);
}

/* Enlaces de texto: azul de la marca (los botones y el menú fijan su propio color con clases) */
a { color: var(--blue-mid); }
a:hover { color: var(--blue-deep); }

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ─── Header ─────────────────────────────────────────────── */
.logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  backdrop-filter: blur(8px);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-text strong {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -.3px;
  line-height: 1;
}

.logo-text span {
  font-size: 10px;
  color: rgba(255,255,255,.7);
  font-weight: 400;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.header-badge {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
}

/* ─── Section Titles ─────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── KPI Cards ──────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, var(--blue-deep));
}

.kpi-card:active { transform: scale(.98); }

.kpi-card.accent-blue  { --accent: var(--blue-deep); }
.kpi-card.accent-green { --accent: var(--green); }
.kpi-card.accent-amber { --accent: var(--amber); }
.kpi-card.accent-red   { --accent: var(--red); }

.kpi-icon {
  font-size: 20px;
  margin-bottom: 8px;
  display: block;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -.5px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.kpi-card.wide {
  grid-column: 1 / -1;
}

/* ─── Semáforo ───────────────────────────────────────────── */
.semaforo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 20px;
  border: 1.5px solid;
  transition: var(--transition);
  animation: semaforo-pulse 2.5s ease-in-out infinite;
}

.semaforo.green {
  background: var(--green-pale);
  border-color: var(--green-light);
  color: var(--green);
}

.semaforo.amber {
  background: var(--amber-pale);
  border-color: var(--amber);
  color: var(--amber);
}

.semaforo.red {
  background: var(--red-pale);
  border-color: var(--red);
  color: var(--red);
  animation: semaforo-alert 1s ease-in-out infinite;
}

@keyframes semaforo-pulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50%       { box-shadow: 0 0 0 6px rgba(46,125,50,.15); }
}

@keyframes semaforo-alert {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50%       { box-shadow: 0 0 0 8px rgba(198,40,40,.2); }
}

/* ─── Chart Card ─────────────────────────────────────────── */
.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-legend {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-wrapper {
  position: relative;
  height: 220px;
}

/* ─── Config Form Card ───────────────────────────────────── */
.config-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.config-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Montserrat', sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--surface-2);
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--blue-light);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(30,136,229,.12);
}

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

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  -webkit-appearance: none;
  user-select: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue-mid) 0%, var(--blue-deep) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(21,101,192,.35);
}

.btn-primary:active { transform: scale(.97); box-shadow: none; }

.btn-success {
  background: linear-gradient(135deg, var(--green-light) 0%, var(--green) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(46,125,50,.35);
}

.btn-danger {
  background: var(--red-pale);
  color: var(--red);
  border: 1px solid var(--red);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-full { width: 100%; }

/* ─── FAB ────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: max(16px, calc(50vw - 240px + 16px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-mid), var(--blue-deep));
  color: #fff;
  font-size: 24px;
  line-height: 1;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 90;
}

.fab:active { transform: scale(.92); }

.budget-meter {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.budget-meter-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
}

.budget-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.budget-fill {
  height: 100%;
  background: var(--blue-deep);
  transition: width 0.3s ease;
}

.budget-fill.warning { background: var(--amber); }
.budget-fill.danger { background: var(--red); }

/* ─── Product Selection (Step 2) ─────────────────────────── */
.portfolio-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}

.portfolio-info { flex: 1; }
.portfolio-name { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.portfolio-cost { font-size: 12px; color: var(--text-secondary); }

.portfolio-qty {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 700;
  cursor: pointer;
}

.qty-val {
  font-weight: 700;
  font-size: 15px;
  min-width: 20px;
  text-align: center;
}

/* ─── Product List (Catalog Modal) ───────────────────────── */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 80px;
}

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.product-card:active { transform: scale(.99); }

.product-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.product-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.product-id {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.roi-badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.roi-badge.high   { background: var(--green-pale); color: var(--green); }
.roi-badge.medium { background: var(--amber-pale);  color: var(--amber); }
.roi-badge.low    { background: var(--red-pale);    color: var(--red); }

/* Perspectivas del Balanced Scorecard — identidad de categoría, no estado
   (por eso son 4 tonos propios, no un reuso de verde/ámbar/rojo). */
.persp-badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.persp-badge.persp-financiera  { background: rgba(46,78,139,.12);  color: #2E4E8B; }
.persp-badge.persp-cliente     { background: rgba(0,137,123,.12);   color: #00897B; }
.persp-badge.persp-procesos    { background: rgba(108,62,181,.12);  color: #6C3EB5; }
.persp-badge.persp-aprendizaje { background: rgba(173,20,87,.12);   color: #AD1457; }

/* Matriz BSC (panel/objetivos.php): perspectiva × departamento */
.matriz-bsc th:first-child, .matriz-bsc td:first-child { white-space: nowrap; }
.matriz-celda { min-width: 160px; vertical-align: top; }
.matriz-vacia { color: var(--text-muted); }
.matriz-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: 4px 0;
}
.matriz-chip + .matriz-chip { border-top: 1px dashed var(--border); }

.product-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.metric-item { display: flex; flex-direction: column; gap: 2px; }

.metric-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .3px;
}

.metric-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-value.positive { color: var(--green); }
.metric-value.warning  { color: var(--amber); }
.metric-value.danger   { color: var(--red); }

.product-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.product-actions .btn {
  flex: 1;
  padding: 9px 14px;
  font-size: 13px;
}

/* ─── Search Bar ─────────────────────────────────────────── */
.search-bar {
  position: relative;
  margin-bottom: 16px;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(30,136,229,.12);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  pointer-events: none;
}

/* ─── Modal / Drawer ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 220;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  backdrop-filter: blur(3px);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 0 0 40px;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto;
}

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

.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.modal-body { padding: 20px; }

/* ─── Calculated Preview ─────────────────────────────────── */
.calc-preview {
  background: linear-gradient(135deg, var(--blue-pale) 0%, #f0f7ff 100%);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
  border: 1px solid rgba(30,136,229,.2);
}

.calc-preview h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--blue-mid);
  margin-bottom: 12px;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.calc-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calc-item .label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.calc-item .value { font-size: 15px; font-weight: 700; color: var(--blue-deep); }
.calc-item .value.green { color: var(--green); }
.calc-item .value.amber { color: var(--amber); }
.calc-item .value.red   { color: var(--red); }

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; font-weight: 500; }
.empty-state small { font-size: 13px; opacity: .7; }

/* ─── Toast Notification ─────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 80px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  transition: all .3s ease;
  pointer-events: none;
}

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

/* ─── Projection Table ───────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.projection-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.projection-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.projection-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.projection-table tr:last-child td { border-bottom: none; }

.projection-table .achieved {
  color: var(--green);
  font-weight: 700;
}

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

.month-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--blue-pale);
  color: var(--blue-deep);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fade-in-up .4s ease both;
}

.animate-in:nth-child(1) { animation-delay: .05s; }
.animate-in:nth-child(2) { animation-delay: .10s; }
.animate-in:nth-child(3) { animation-delay: .15s; }
.animate-in:nth-child(4) { animation-delay: .20s; }
.animate-in:nth-child(5) { animation-delay: .25s; }
.animate-in:nth-child(6) { animation-delay: .30s; }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
