/* css/styles.css */

/* Importar tipografía moderna de Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg-app: #090d16;
  --bg-sidebar: rgba(13, 20, 35, 0.75);
  --bg-card: rgba(21, 30, 52, 0.55);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  
  --accent: #3b82f6;
  --accent-light: rgba(59, 130, 246, 0.12);
  
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.12);
  
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);
  
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.12);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   1. PANTALLA DE LOGIN
   ========================================================================== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 10% 20%, rgb(18, 28, 54) 0%, rgb(9, 13, 22) 90%);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: var(--transition-smooth);
}

.login-container.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.05);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fadeIn 0.6s ease-out;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 2rem;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.login-card h2 {
  font-family: var(--font-title);
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.input-wrapper {
  position: relative;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.form-control {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: rgba(10, 15, 30, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-focus);
  background: rgba(10, 15, 30, 0.9);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  gap: 8px;
  width: 100%;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  width: auto;
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-top: 1rem;
  display: none;
  text-align: left;
  animation: shake 0.3s ease-in-out;
}

.login-demo-help {
  margin-top: 2rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-color);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.login-demo-help code {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
}

/* ==========================================================================
   2. ESTRUCTURA DE LA APLICACIÓN (SIDEBAR & CONTENIDO)
   ========================================================================== */
.sidebar {
  width: 270px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: var(--transition-smooth);
}

.sidebar-brand {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.sidebar-brand i {
  color: var(--primary);
  font-size: 1.5rem;
  background: var(--primary-light);
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.sidebar-menu {
  list-style: none;
  padding: 0 1rem;
  flex-grow: 1;
}

.sidebar-menu li {
  margin-bottom: 0.35rem;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
  cursor: pointer;
}

.sidebar-menu a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.sidebar-menu li.active a {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar-menu li.active a i {
  color: #ffffff;
}

.sidebar-menu a i {
  font-size: 1.15rem;
  transition: var(--transition-smooth);
}

.sidebar-user {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.1rem;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-info {
  flex-grow: 1;
  overflow: hidden;
}

.user-info .user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-info .user-role {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
}

.btn-logout {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}

.btn-logout:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* CONTENEDOR PRINCIPAL */
.main-content {
  margin-left: 270px;
  flex-grow: 1;
  padding: 2.5rem;
  min-height: 100vh;
  transition: var(--transition-smooth);
  width: calc(100% - 270px);
}

/* ==========================================================================
   3. ESTRUCTURA DE LAS VISTAS (APP SPA CONTAINER)
   ========================================================================== */
.app-view {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.app-view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.view-header h1 {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.view-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ==========================================================================
   4. DASHBOARD E INDICADORES (KPI CARDS)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: var(--transition-smooth);
}

.kpi-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-lg);
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.kpi-icon.primary {
  background: var(--primary-light);
  color: var(--primary);
}

.kpi-icon.accent {
  background: var(--accent-light);
  color: var(--accent);
}

.kpi-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.kpi-icon.warning {
  background: var(--warning-light);
  color: var(--warning);
}

.kpi-icon.danger {
  background: var(--danger-light);
  color: var(--danger);
}

.kpi-details .kpi-value {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-details .kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Gráficos y Tablas */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.panel-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* ==========================================================================
   5. TABLAS E HISTORIAL (KARDEX / LISTADOS)
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.custom-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-title);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.custom-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.custom-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 30px;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-accent { background: var(--accent-light); color: var(--accent); }

/* ==========================================================================
   6. SECCIÓN INVENTARIO (FICHAS Y FILTROS)
   ========================================================================== */
.filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input-group {
  flex-grow: 1;
  position: relative;
  min-width: 250px;
}

.search-input-group i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input-group .form-control {
  padding-left: 40px;
}

.select-control {
  padding: 12px 16px;
  background: rgba(10, 15, 30, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  min-width: 160px;
}

.select-control:focus {
  border-color: var(--primary);
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.material-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: var(--transition-smooth);
}

.material-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-lg);
}

.material-type-tag {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}

.material-sku {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.material-name {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.75rem;
  height: 44px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.material-category {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 1rem;
}

.material-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

.material-stock {
  font-size: 0.85rem;
}

.material-stock .stock-number {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-title);
}

.material-location {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 0.5rem;
}

/* ==========================================================================
   7. PROCESO DE REQUISICIÓN (FORMULARIO Y CARRITO)
   ========================================================================== */
.requisition-container {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.5rem;
}

.cart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: fit-content;
  position: sticky;
  top: 20px;
}

.cart-items-list {
  margin-bottom: 1.5rem;
  max-height: 280px;
  overflow-y: auto;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cart-item-info {
  flex-grow: 1;
}

.cart-item-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.cart-item-sku {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 1rem;
}

.btn-qty {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-primary);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.btn-qty:hover {
  background: rgba(255, 255, 255, 0.15);
}

.cart-item-remove {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition-smooth);
}

.cart-item-remove:hover {
  color: var(--danger);
}

.empty-cart-message {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem 0;
}

/* ==========================================================================
   8. COMPONENTE VENTANA MODAL (Y DETALLES)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

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

.modal-content {
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  transition: var(--transition-smooth);
  padding: 2rem;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 700;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
}

.btn-close-modal:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   9. EFECTOS ESPECIALES Y ANIMACIONES
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Responsive */
@media (max-width: 991px) {
  .dashboard-grid, .requisition-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 70px;
  }
  .sidebar-brand span, .sidebar-menu a span, .user-info, .sidebar-user .btn-logout {
    display: none;
  }
  .sidebar-brand {
    padding: 1.5rem 0.75rem;
    justify-content: center;
  }
  .sidebar-menu {
    padding: 0 0.5rem;
  }
  .sidebar-menu a {
    justify-content: center;
    padding: 12px;
  }
  .sidebar-user {
    justify-content: center;
    padding: 1rem 0;
  }
  .main-content {
    margin-left: 70px;
    width: calc(100% - 70px);
    padding: 1.5rem;
  }
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}
