/* ==========================================================
   TRILCE SIM - UI/UX MODERNIZATION (RESPONSIVE)
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Paleta Corporativa Modernizada */
  --ucv-blue: #0F2A55; /* Un tono navy más profundo y elegante */
  --ucv-blue-hover: #193B73;
  --ucv-light-blue: #F4F7FB;
  --ucv-yellow: #FFF7D6;
  --ucv-yellow-hover: #FFEEA8;
  --ucv-accent: #3B82F6; /* Azul vibrante para botones de acción */
  
  /* Texto y Fondos */
  --text-main: #1E293B;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --bg-main: #F8FAFC;
  --white: #FFFFFF;
  
  /* Estados */
  --success: #10B981;
  --success-bg: #D1FAE5;
  --danger: #EF4444;
  --danger-bg: #FEE2E2;
  
  /* Sombras Modernas (Soft Shadows) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.3);
  
  --radius: 12px; /* Bordes más redondeados y amigables */
  --radius-sm: 8px;
}

* { 
  box-sizing: border-box; 
  font-family: 'Inter', system-ui, -apple-system, sans-serif; 
}

body { 
  margin: 0; 
  color: var(--text-main); 
  background-color: var(--bg-main); 
  -webkit-font-smoothing: antialiased; 
  line-height: 1.5;
}

.hidden { display: none !important; }

/* --- UTILIDADES TEXTO --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-blue { color: var(--ucv-blue); }
.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'ui-monospace', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace; font-variant-numeric: tabular-nums; }

/* --- LOGIN VISTA (Estética Premium) --- */
.bg-login { 
  /* Fondo oscuro con un sutil grid de fondo estilo "blueprint" */
  background-color: #0B1121; 
  background-image: 
    radial-gradient(at 100% 0%, rgba(26, 54, 93, 0.4) 0px, transparent 50%), 
    radial-gradient(at 0% 100%, rgba(37, 99, 235, 0.2) 0px, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 24px 24px, 24px 24px;
}

.auth-container { 
  display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; 
}

.auth-card { 
  background: rgba(255, 255, 255, 0.98); 
  backdrop-filter: blur(20px);
  padding: 48px 40px; 
  border-radius: 24px; 
  /* Sombras multicapa para dar profundidad real, no genérica */
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1); 
  width: 100%; 
  max-width: 420px; 
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1); 
}

.brand-header { text-align: center; margin-bottom: 32px; }
.brand-header h1 { 
  color: #0F172A; 
  margin: 0 0 6px 0; 
  font-size: 28px; 
  font-weight: 800; 
  letter-spacing: -0.5px; 
}
.brand-header p { 
  color: #64748B; 
  margin: 0; 
  font-size: 12px; 
  text-transform: uppercase; 
  letter-spacing: 2px; 
  font-weight: 700; 
}

/* Tabs minimalistas tipo aplicación nativa */
.auth-tabs { 
  display: flex; 
  background: transparent; 
  border-bottom: 2px solid #E2E8F0; 
  border-radius: 0; 
  padding: 0; 
  margin-bottom: 28px; 
  gap: 24px;
}
.auth-tab { 
  flex: none;
  border: none; 
  background: transparent; 
  padding: 10px 4px; 
  border-radius: 0; 
  font-weight: 600; 
  color: #94A3B8; 
  cursor: pointer; 
  transition: all 0.2s ease; 
  font-size: 14px; 
  margin-bottom: -2px; /* Para superponerse al borde inferior */
  border-bottom: 2px solid transparent;
}
.auth-tab:hover { color: #475569; }
.auth-tab.active { 
  background: transparent; 
  color: var(--ucv-blue); 
  box-shadow: none;
  border-bottom: 2px solid var(--ucv-accent);
}

/* Inputs de fondo gris sutil (Modern Soft UI) */
.auth-form { display: flex; flex-direction: column; gap: 20px; }
.auth-form label { 
  font-size: 13px; font-weight: 600; color: #334155; 
  display: flex; flex-direction: column; gap: 8px; 
}
.auth-form input { 
  padding: 14px 16px; 
  border: 1px solid transparent; 
  background-color: #F1F5F9; /* Fondo gris claro en lugar de borde marcado */
  border-radius: 10px; 
  font-size: 14px; 
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
  color: #0F172A;
  font-weight: 500;
}
.auth-form input:focus { 
  outline: none; 
  background-color: #FFFFFF;
  border-color: var(--ucv-accent); 
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); 
}
.auth-form input::placeholder { color: #94A3B8; font-weight: 400; }
.auth-error { color: var(--danger); font-size: 13px; margin: -8px 0 0; min-height: 18px; font-weight: 500; }

/* --- BOTONES (UX Mejorado) --- */
.btn { 
  border: none; 
  padding: 10px 18px; 
  border-radius: var(--radius-sm); 
  font-weight: 600; 
  cursor: pointer; 
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
  font-size: 14px; 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-primary { background: var(--ucv-accent); color: var(--white); box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2); }
.btn-primary:hover:not(:disabled) { background: #2563EB; transform: translateY(-2px); box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.3); }
.btn-outline-blue { background: transparent; color: var(--ucv-blue); border: 1px solid var(--ucv-blue); }
.btn-outline-blue:hover:not(:disabled) { background: var(--ucv-light-blue); }
.btn-danger { background: var(--danger); color: white; box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2); }
.btn-danger:hover:not(:disabled) { background: #DC2626; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(239, 68, 68, 0.3); }
.btn-link { background: none; border: none; color: var(--text-muted); text-decoration: none; cursor: pointer; font-weight: 500; transition: color 0.2s; padding: 0; }
.btn-link:hover { color: var(--ucv-accent); }
.btn-back { display: inline-flex; align-items: center; text-decoration: none; color: var(--text-muted); font-weight: 600; transition: color 0.2s; font-size: 14px; }
.btn-back:hover { color: var(--ucv-blue); }

/* --- LAYOUT APP & GLASSMORPHISM --- */
.app-header { 
  background: rgba(255, 255, 255, 0.85); 
  backdrop-filter: blur(12px); 
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8); 
  padding: 16px 30px; 
  margin-bottom: 30px; 
  position: sticky; 
  top: 0; 
  z-index: 50; 
}
.header-content { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: 0 auto; }
.header-content h2 { margin: 0; color: var(--ucv-blue); font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.user-menu { display: flex; align-items: center; gap: 20px; font-size: 14px; font-weight: 500; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px 60px; animation: fadeIn 0.4s ease-out; }
.page-title { font-size: 18px; color: var(--ucv-blue); font-weight: 800; }

/* --- COMPONENTES DEL SIMULADOR --- */
.simulator-toolbar { 
  display: flex; justify-content: space-between; align-items: center; 
  background: var(--white); padding: 16px 20px; 
  border-radius: var(--radius); box-shadow: var(--shadow-sm); 
  border: 1px solid var(--border-color); margin-bottom: 20px; 
}
.toolbar-group { display: flex; align-items: center; gap: 15px; }
.simulator-add-box { 
  background: var(--white); padding: 20px; 
  border-radius: var(--radius); box-shadow: var(--shadow-md); 
  border: 1px solid var(--border-color); margin-bottom: 30px; 
  position: relative; overflow: hidden;
}
.simulator-add-box::before {
  content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 4px; background-color: var(--ucv-accent);
}

.form-inline { display: flex; gap: 15px; align-items: center; flex-wrap: wrap; }
.form-input { 
  padding: 10px 14px; border: 1px solid var(--border-color); 
  border-radius: var(--radius-sm); font-size: 14px; flex: 1; 
  min-width: 180px; transition: all 0.2s; background: var(--bg-main);
  color: var(--text-main); font-weight: 500;
}
.form-input:focus:not(:read-only) { outline: none; border-color: var(--ucv-accent); box-shadow: var(--shadow-focus); background: var(--white); }
.form-input:disabled { opacity: 0.6; cursor: not-allowed; }

/* --- TABLAS MODERNAS --- */
.table-card { 
  background: var(--white); border: 1px solid var(--border-color); 
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-md); 
}
.table-header-title { 
  background: var(--white); color: var(--ucv-blue); font-weight: 800; 
  padding: 18px 20px; border-bottom: 1px solid var(--border-color); 
  font-size: 16px; display: flex; justify-content: space-between; align-items: center;
}
.table-responsive { 
  overflow-x: auto; 
  -webkit-overflow-scrolling: touch; 
}
/* Scrollbar custom para Webkit */
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-track { background: var(--bg-main); }
.table-responsive::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

.ucv-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; white-space: nowrap; }
.ucv-table th { 
  background: var(--ucv-light-blue); color: var(--text-muted); 
  font-weight: 700; padding: 14px 20px; text-align: left; 
  border-bottom: 1px solid var(--border-color); text-transform: uppercase; 
  font-size: 12px; letter-spacing: 0.5px;
}
.ucv-table td { padding: 16px 20px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.ucv-table tbody tr { transition: background 0.2s; }
.row-highlight { background-color: var(--white); }
.row-highlight:hover { background-color: var(--bg-main); }

.table-footer { 
  background: var(--ucv-light-blue); padding: 18px 20px; 
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 800; color: var(--ucv-blue); border-top: 1px solid var(--border-color); 
  font-size: 15px;
}

/* --- DETALLE PARCIALES --- */
.parcial-section { 
  margin-bottom: 30px; background: var(--white); border-radius: var(--radius); 
  box-shadow: var(--shadow-md); overflow: hidden; border: 1px solid var(--border-color); 
  transition: transform 0.2s ease;
}
.parcial-section:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.parcial-title { 
  color: var(--ucv-blue); font-size: 15px; margin: 0; padding: 16px 20px; 
  background: var(--white); font-weight: 800; display: flex; align-items: center; gap: 8px;
}

.formula-box { 
  display: grid; grid-template-columns: 1fr auto; 
  background: var(--white); border-top: 1px solid var(--border-color); 
}
.formula-label { 
  background: var(--ucv-light-blue); color: var(--ucv-blue); 
  font-weight: 800; padding: 14px 20px; font-size: 12px; letter-spacing: 0.5px; 
}
.formula-text, .formula-result { 
  padding: 16px 20px; font-size: 14px; color: var(--text-main); 
}
.formula-text { font-family: 'ui-monospace', 'SFMono-Regular', monospace; }
.formula-result { font-weight: 800; border-left: 1px solid var(--border-color); background: var(--white); font-size: 16px; }

/* --- BADGE DE REDONDEO --- */
.badge-redondeo {
  background-color: var(--ucv-accent);
  color: white;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  margin-left: 8px;
  vertical-align: text-bottom;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* ==========================================================
   DISEÑO RESPONSIVO (MOBILE FIRST & VERTICAL SCREENS)
   ========================================================== */
@media (max-width: 768px) {
  .app-header { padding: 12px 20px; }
  .header-content h2 { font-size: 18px; }
  .user-menu { flex-direction: column; align-items: flex-end; gap: 4px; }
  .user-email { display: none; /* Ocultar email largo en mobile para salvar espacio */ }
  
  .container { padding: 0 15px 40px; }
  
  /* Toolbars apilables para pulgares */
  .simulator-toolbar { flex-direction: column; align-items: stretch; gap: 15px; padding: 15px; }
  .toolbar-group { flex-direction: column; align-items: stretch; width: 100%; gap: 10px; }
  .toolbar-group label { margin-bottom: -5px; }
  .toolbar-group select, .toolbar-group button, .simulator-toolbar > button { width: 100%; min-height: 44px; }
  
  /* Formularios apilables */
  .form-inline { flex-direction: column; align-items: stretch; gap: 12px; width: 100%; }
  .form-inline .form-input, .form-inline .btn { width: 100%; max-width: none !important; min-height: 44px; }
  
  /* Ajustes de Parciales en Mobile */
  .parcial-section > div:first-child { flex-direction: column; align-items: flex-start !important; gap: 10px; padding: 15px !important; }
  .parcial-section > div:first-child button { width: 100%; }
  
  /* Fórmula Box apilable en móvil */
  .formula-box { grid-template-columns: 1fr; }
  .formula-label.text-right { border-left: none; border-top: 1px solid var(--border-color); text-align: left; }
  .formula-result { border-left: none; border-bottom: 1px solid var(--border-color); text-align: left; }
}

/* Animaciones */
@keyframes slideUp { 
  from { opacity: 0; transform: translateY(30px); } 
  to { opacity: 1; transform: translateY(0); } 
}
@keyframes fadeIn { 
  from { opacity: 0; } 
  to { opacity: 1; } 
}


/* ==========================================================
   GLOBAL LOADER (PANTALLA DE CARGA)
   ========================================================== */
.loader-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--ucv-light-blue);
  border-top: 4px solid var(--ucv-accent);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
  margin-bottom: 16px;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.loader-text {
  color: var(--ucv-blue);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  animation: pulseText 1.5s ease-in-out infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulseText {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}