/* AISA Stock Manager - Estilos CSS */
:root {
  --primary: #0284c7;        /* Azul industrial */
  --primary-dark: #0369a1;
  --secondary: #0f172a;      /* Slate oscuro */
  --accent: #f59e0b;         /* Ámbar industrial */
  --success: #10b981;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

/* Splash Screen Post-Login */
.splash-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

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

.splash-logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: splashPulse 2s ease-in-out infinite;
}

.splash-img {
  max-width: 180px;
  max-height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.4));
}

.splash-placeholder {
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  font-size: 2.5rem;
  padding: 1rem 2rem;
  border-radius: 12px;
  letter-spacing: 3px;
  box-shadow: 0 10px 25px rgba(2, 132, 199, 0.4);
}

.splash-title {
  color: #f8fafc;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.splash-sub {
  color: #94a3b8;
  font-size: 0.85rem;
}

.splash-loader {
  margin-top: 1.5rem;
  width: 160px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.splash-loader::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: var(--primary);
  border-radius: 4px;
  animation: splashLoading 1.2s infinite ease-in-out;
}

@keyframes splashLoading {
  0% { left: -40%; width: 30%; }
  50% { width: 60%; }
  100% { left: 100%; width: 30%; }
}

@keyframes splashPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.header-logo-img {
  max-height: 38px;
  max-width: 120px;
  object-fit: contain;
  margin-right: 0.5rem;
}


.brand-logo {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  letter-spacing: 1px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
  display: block;
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-badge {
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-badge .role-tag {
  background: var(--primary);
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background-color: var(--primary-dark); }

.btn-secondary {
  background-color: #e2e8f0;
  color: #334155;
}
.btn-secondary:hover { background-color: #cbd5e1; }

.btn-danger {
  background-color: #fee2e2;
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover { background-color: #fecaca; }

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border);
  color: #334155;
}
.btn-outline:hover { background-color: #f1f5f9; }

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 0.4rem;
  border-radius: 6px;
}

/* Layout Principal */
.main-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
  width: 100%;
  flex: 1;
}

/* Buscador y Controles */
.search-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

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

.search-icon {
  position: absolute;
  left: 1rem;
  color: #94a3b8;
  width: 20px;
  height: 20px;
}

.search-input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.75rem;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.recent-searches-box {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.search-chip {
  background: #f1f5f9;
  color: #334155;
  padding: 0.25rem 0.65rem;
  border-radius: 16px;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.search-chip:hover {
  background: #e2e8f0;
  color: var(--primary-dark);
  border-color: #cbd5e1;
}

/* Barra de Acciones de Vista */
.action-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toolbar-stats {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toolbar-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Tabla de Productos (Desktop) */
.table-responsive {
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

table.stock-table th {
  background: #f8fafc;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

table.stock-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.stock-table tr:hover {
  background-color: #f8fafc;
}

.badge-stock {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  min-width: 45px;
}
.stock-ok { background: #dcfce7; color: #166534; }
.stock-low { background: #fef9c3; color: #854d0e; }
.stock-zero { background: #fee2e2; color: #991b1b; }

.badge-modifier {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fef08a;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-top: 0.25rem;
}


.part-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  color: #0369a1;
  background: #f0f9ff;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #bae6fd;
}

/* Tarjetas Móviles (Para pantallas pequeñas) */
.mobile-card-list {
  display: none;
  flex-direction: column;
  gap: 0.85rem;
}

.product-card {
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.card-specs {
  font-size: 0.82rem;
  color: #475569;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 0.65rem 0;
  background: #f8fafc;
  padding: 0.5rem;
  border-radius: 6px;
}

.card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

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

.modal-card {
  background: #fff;
  border-radius: 12px;
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  transform: translateY(10px);
  transition: transform 0.2s ease-in-out;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

.modal-body {
  padding: 1.4rem;
}

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

/* Formularios */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

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

.help-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.alert-box {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.alert-warning {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  color: #92400e;
}
.alert-info {
  background: #f0f9ff;
  border: 1px solid #e0f2fe;
  color: #0369a1;
}

/* Ficha Técnica Imprimible */
.technical-sheet {
  background: #fff;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.sheet-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-spec-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.spec-item {
  border-bottom: 1px dotted #cbd5e1;
  padding-bottom: 0.35rem;
}
.spec-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}
.spec-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
}

/* Estilos de Impresión (@media print) */
@media print {
  /* Ocultar elementos no imprimibles */
  .app-header,
  .search-card,
  .toolbar-buttons,
  .btn,
  .modal-overlay:not(.active),
  .no-print {
    display: none !important;
  }

  body, .main-container {
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .table-responsive {
    border: 1px solid #000 !important;
    box-shadow: none !important;
  }

  table.stock-table th, table.stock-table td {
    border-color: #666 !important;
    padding: 6px 8px !important;
    font-size: 10pt !important;
  }

  .modal-overlay.active {
    position: static !important;
    background: none !important;
    padding: 0 !important;
  }

  .modal-card {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
  }

  .modal-footer, .modal-header .btn-close {
    display: none !important;
  }

  .print-only-header {
    display: block !important;
    margin-bottom: 15px;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
  }
}

.print-only-header {
  display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .table-responsive {
    display: none;
  }
  .mobile-card-list {
    display: flex;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .sheet-spec-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    padding: 0.75rem 1rem;
  }
  .brand-subtitle {
    display: none;
  }
  .user-nav {
    gap: 0.4rem;
  }
  .user-badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
}

/* Barra flotante de acciones a granel */
.bulk-action-bar {
  background: #0f172a;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.bulk-action-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.bulk-action-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.row-selected {
  background-color: #f0fdf4 !important;
}

.checkbox-cell {
  width: 36px;
  text-align: center;
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* === ENCABEZADOS DE TABLA ORDENABLES === */
.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.sortable-th:hover {
  background-color: #e2e8f0;
  color: var(--primary);
}

.sortable-th.th-active-sort {
  color: var(--primary);
  background-color: #eff6ff;
}

.sort-icon {
  display: inline-block;
  font-size: 0.8rem;
  margin-left: 4px;
  color: #94a3b8;
  vertical-align: middle;
}

.th-active-sort .sort-icon {
  color: var(--primary);
  font-weight: bold;
}

/* === BOTÓN Y BADGE DE FILTROS EN TOOLBAR === */
.filter-count-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  display: inline-block;
}

/* === BARRA RESUMEN DE FILTROS ACTIVOS === */
.active-filters-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  animation: fadeIn 0.2s ease;
}

.filter-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #bae6fd;
}

.filter-tag-chip .chip-remove {
  cursor: pointer;
  font-weight: bold;
  opacity: 0.7;
  transition: opacity 0.1s;
}

.filter-tag-chip .chip-remove:hover {
  opacity: 1;
  color: #dc2626;
}

.btn-clear-inline {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.2rem 0.4rem;
}

/* === MENÚ LATERAL (SIDEBAR DRAWER) === */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.filter-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  background: #ffffff;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.filter-sidebar.active {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

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

.sidebar-section {
  display: flex;
  flex-direction: column;
}

.sidebar-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.45rem;
}

.filter-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-chip {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.filter-list-box {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
}

.filter-item-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: none;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.8rem;
  text-align: left;
  color: #334155;
  cursor: pointer;
  transition: background 0.1s ease;
}

.filter-item-btn:last-child {
  border-bottom: none;
}

.filter-item-btn:hover {
  background: #f8fafc;
  color: var(--primary);
}

.filter-item-btn.active {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 700;
}

.filter-item-count {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-weight: 600;
}

.filter-item-btn.active .filter-item-count {
  background: #dbeafe;
  color: var(--primary);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  gap: 0.6rem;
}

/* === PAGINACIÓN === */
.pagination-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 0;
  margin-top: 0.5rem;
}

.pagination-info {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.page-btn:hover:not(:disabled):not(.active) {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  cursor: default;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #e2e8f0;
}

.page-dots {
  padding: 0 0.3rem;
  color: #94a3b8;
  font-size: 0.85rem;
}

