/* ==========================================================================
   KEV PROCESS SpA - Sistema de Presupuestos y Costeo
   styles.css - Estilos corporativos y de alta densidad para ingeniería
   ========================================================================== */

:root {
  --primary: #0f2744;
  --primary-light: #1e3a5f;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-dark: #94a3b8;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --excel-header-bg: #1e3a5f;
  --excel-header-text: #ffffff;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header Corporativo */
.header-bar {
  background: linear-gradient(135deg, #0b1d33 0%, #173356 100%);
  color: white;
  padding: 0.85rem 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-box {
  background: #2563eb;
  color: white;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 1.1rem;
}

/* Modos Selector (Cuestionario vs Desarrollo) */
.mode-toggle-container {
  display: flex;
  background: rgba(255, 255, 255, 0.12);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.mode-btn {
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #cbd5e1;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-btn.active {
  background: white;
  color: #0f2744;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Acciones principales */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #059669; color: white; }
.btn-success:hover { background: #047857; }
.btn-secondary { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-dark { background: #0f172a; color: white; }
.btn-dark:hover { background: #1e293b; }

/* Contenedor Principal */
.app-container {
  max-width: 1550px;
  margin: 1.25rem auto;
  padding: 0 1rem;
}

/* Tarjeta Resumen Flotante / Lateral */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f2744;
}

/* Stepper en Modo Cuestionario */
.stepper-nav {
  display: flex;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.step-item {
  flex: 1;
  min-width: 140px;
  padding: 0.85rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.step-item.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: #f8faff;
}

.step-item.completed {
  color: #059669;
}

.step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.step-item.active .step-number {
  background: #2563eb;
  color: white;
}

.step-item.completed .step-number {
  background: #059669;
  color: white;
}

/* Formularios de Paso */
.step-pane {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

/* Modo Desarrollo (Pestañas Multitab de Excel) */
.excel-tabs {
  display: flex;
  background: #e2e8f0;
  padding: 4px 6px 0 6px;
  border-radius: 8px 8px 0 0;
  overflow-x: auto;
  gap: 2px;
  border-bottom: 2px solid #0f2744;
}

.excel-tab {
  padding: 0.5rem 1rem;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  background: #cbd5e1;
  color: #334155;
  border-radius: 6px 6px 0 0;
  white-space: nowrap;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.excel-tab:hover {
  background: #e2e8f0;
}

.excel-tab.active {
  background: #0f2744;
  color: white;
}

/* Tablas Matriciales Tipo Excel */
.excel-table-container {
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  overflow-x: auto;
  padding: 1rem;
  min-height: 480px;
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.excel-table th {
  background-color: var(--excel-header-bg);
  color: var(--excel-header-text);
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 700;
  border: 1px solid #334e68;
  font-size: 0.8rem;
  letter-spacing: 0.3px;
}

.excel-table td {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  color: #1e293b;
}

.excel-table tr:hover td {
  background-color: #f1f5f9;
}

.excel-table input[type="text"],
.excel-table input[type="number"],
.excel-table select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.85rem;
  background: #fdfdfd;
}

.excel-table input:focus,
.excel-table select:focus {
  outline: none;
  border-color: #2563eb;
  background: white;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.total-row td {
  font-weight: 800;
  background-color: #f8fafc;
  border-top: 2px solid #0f2744;
  border-bottom: 2px solid #0f2744;
}

/* Modales */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 950px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
}

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

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: #f8fafc;
  border-radius: 0 0 12px 12px;
}

/* ==========================================================================
   MEJORAS NIVEL 1 & 2: GANTT, DROPZONE, TOASTS, CONFIGURACIÓN
   ========================================================================== */

/* Mini Carta Gantt */
.gantt-container {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
}

.gantt-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.775rem;
}

.gantt-bar-track {
  background: #f1f5f9;
  height: 22px;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.gantt-bar {
  position: absolute;
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  color: white;
  font-weight: 700;
  font-size: 0.7rem;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
}

.gantt-bar-oficina { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.gantt-bar-fat { background: linear-gradient(90deg, #8b5cf6, #a855f7); }
.gantt-bar-terreno { background: linear-gradient(90deg, #d97706, #f59e0b); }
.gantt-bar-cierre { background: linear-gradient(90deg, #059669, #10b981); }

/* Dropzone de Importación */
.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 10px;
  padding: 2rem 1.5rem;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #0f2744;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transform: translateY(20px);
  opacity: 0;
  animation: toastIn 0.25s forwards, toastOut 0.25s forwards 3.5s;
}

.toast.toast-success { border-left: 4px solid #10b981; }
.toast.toast-warning { border-left: 4px solid #f59e0b; }
.toast.toast-info { border-left: 4px solid #3b82f6; }

@keyframes toastIn {
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  to { transform: translateY(20px); opacity: 0; }
}

/* Badge de Auto-Guardado */
.autosave-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.725rem;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
}

.autosave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* ==========================================================================
   BARRA LATERAL (SIDEBAR DRAWER) CON AUTOHIDE & PIN
   ========================================================================== */
.sidebar-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  background: #081424;
  color: #f1f5f9;
  z-index: 160;
  box-shadow: 6px 0 30px rgba(0, 0, 0, 0.55);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-drawer.open {
  transform: translateX(0);
}

body.sidebar-pinned {
  padding-left: 320px;
  transition: padding-left 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

body.sidebar-pinned .sidebar-overlay {
  display: none !important;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 155;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  padding: 1.1rem 1.25rem;
  background: #07101c;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  background: #07101c;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.sidebar-menu-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-size: 0.825rem;
  font-weight: 500;
  color: #cbd5e1;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.sidebar-menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-menu-btn.active {
  background: #2563eb;
  color: white;
  font-weight: 600;
}

/* Header Minimalista con KPIs */
.header-project-badge {
  display: flex;
  flex-direction: column;
  max-width: 320px;
}

.header-kpi-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Acordeón de Textos de Oferta */
.text-section-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.text-section-header {
  padding: 0.7rem 1rem;
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1e293b;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.text-section-header:hover {
  background: #f1f5f9;
}

.text-section-body {
  padding: 0.85rem 1rem;
}

.text-section-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.775rem;
  font-family: inherit;
  color: #334155;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.text-section-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

