:root {
  --bg-dark: #0f172a; /* Slate 900 */
  --bg-card: #1e293b; /* Slate 800 */
  --bg-sidebar: #0b1120; /* Slate 950 */
  --text-main: #f8fafc; /* Slate 50 */
  --text-muted: #94a3b8; /* Slate 400 */
  --primary-color: #38bdf8; /* Light Blue/Cyan */
  --primary-hover: #0ea5e9;
  --success-color: #10b981; /* Emerald 500 */
  --success-bg: rgba(16, 185, 129, 0.1);
  --danger-color: #ef4444; /* Red 500 */
  --border-color: #334155; /* Slate 700 */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body.light-mode {
  /* --sidebar-logo-filter removed */
  --bg-dark: #f1f5f9; /* Slate 100 */
  --bg-card: #ffffff; /* White */
  --bg-sidebar: #ffffff; /* White */
  --text-main: #0f172a; /* Slate 900 */
  --text-muted: #64748b; /* Slate 500 */
  --border-color: #e2e8f0; /* Slate 200 */
  color-scheme: light;
}

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

html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  display: flex;
  height: 100%;
  overflow: hidden;
  color-scheme: dark;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
}

#app-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
}

.sidebar-logo img {
  filter: var(--sidebar-logo-filter, none);
}

.main-logo-img {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  border: 2px solid var(--border-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
}

.auth-logo .main-logo-img {
  width: 85px;
  height: 85px;
}

.logo-text {
  text-align: center;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  margin-top: 10px;
  letter-spacing: 0.5px;
  line-height: 1.4;
}

.theme-toggle-btn:hover {
  color: var(--primary-color) !important;
}

.sidebar-logo h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 8px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--primary-color);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.user-profile {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.user-details h4 {
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.user-details p {
  font-size: 0.75rem;
  color: var(--primary-color);
}

.btn-logout {
  background: transparent;
  color: var(--danger-color);
  border: 1px solid var(--danger-color);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}

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

/* Main Content */
.main-content {
  flex: 1;
  padding: 15px 25px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sistema de Pestañas */
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.top-bar h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main) !important;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.3s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.alert-success {
  background-color: var(--success-bg);
  color: var(--success-color);
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--success-color);
  margin-bottom: 20px;
  display: none;
  align-items: center;
  gap: 10px;
}

/* Filter Card */
.filter-card {
  background-color: var(--bg-card);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.form-control {
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.3s;
}

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

/* Data Table Card */
.table-card {
  background-color: var(--bg-card);
  border-radius: 12px;
  padding: 15px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.table-responsive {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.table-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

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

.export-btns {
  display: flex;
  gap: 10px;
}

.btn-export {
  background-color: var(--bg-dark);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-export.excel { border-color: #10b981; color: #10b981; }
.btn-export.excel:hover { background-color: rgba(16, 185, 129, 0.1); }

.btn-export.pdf { border-color: #ef4444; color: #ef4444; }
.btn-export.pdf:hover { background-color: rgba(239, 68, 68, 0.1); }

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th {
  text-align: center;
  padding: 12px 15px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

td {
  text-align: center;
  color: var(--text-main) !important;
  padding: 12px 15px;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5); /* lighter border */
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.no-truncate {
  max-width: none !important;
  text-overflow: clip !important;
  overflow: visible !important;
}

tbody tr {
  transition: background-color 0.2s;
}

tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Editable Cells */
.editable-cell {
  color: var(--text-main) !important;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative; /* Para el cuadrito de arrastre */
}

.editable-cell:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px dashed var(--border-color);
}

.multi-selected {
  background-color: rgba(59, 130, 246, 0.2) !important; /* Tailwind Blue 500 at 20% opacity */
  border: 2px solid var(--primary-color) !important;
}

.editable-cell:focus, .editable-cell.editing {
  background-color: var(--bg-dark);
  border: 1px solid var(--primary-color);
  outline: none;
  color: var(--text-main);
}

/* Drag to Fill Handle (Excel-like) */
.fill-handle {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 8px;
  height: 8px;
  background-color: var(--primary-color);
  border: 1px solid var(--bg-card);
  cursor: crosshair;
  z-index: 10;
  display: none;
}

.editable-cell:hover > .fill-handle,
.multi-selected > .fill-handle {
  display: block;
}

.fill-highlight {
  background-color: rgba(56, 189, 248, 0.2) !important;
  border: 1px dashed var(--primary-color) !important;
}

.multi-selected {
  background-color: rgba(14, 165, 233, 0.3) !important;
  border: 1px solid var(--primary-color) !important;
}

/* File Upload hidden */
#file-upload {
  display: none;
}

/* Custom Editable Inputs */
.edit-select, .edit-input {
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  color: var(--text-main) !important;
  background-color: var(--bg-dark) !important;
  border: 1px solid var(--primary-color) !important;
  box-shadow: 0 0 5px rgba(56, 189, 248, 0.5) !important;
  border-radius: 6px;
  padding: 8px 12px !important;
}

.edit-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2338bdf8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px top 50%;
  background-size: 12px auto;
  padding-right: 30px !important;
}

.edit-select:focus, .edit-input:focus {
  outline: none;
  border-color: var(--primary-hover) !important;
}

/* Make native calendar icon visible in dark mode */
body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

/* Spacer Column */
th.spacer-col, td.spacer-col {
  width: 30px !important;
  min-width: 30px !important;
  padding: 0 !important;
  border: none !important;
  background-color: var(--bg-dark) !important; 
  position: relative;
  pointer-events: none; /* No interactivo */
}

/* Dibujar la línea exactamente en el centro del espacio */
th.spacer-col::after, td.spacer-col::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px; /* Grosor de la línea */
  background-color: var(--primary-color);
}

/* AUTHENTICATION STYLES */
.auth-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f4f6f9; /* Light background from image */
  font-family: var(--font-family);
}

body.dark-mode .auth-container {
  background-color: var(--bg-dark);
}

.auth-card {
  background-color: #ffffff;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 450px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.05);
  text-align: center;
}

body.dark-mode .auth-card {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.auth-logo {
  margin-bottom: 20px;
}

.logo-circle {
  width: 80px;
  height: 80px;
  background-color: #38bdf8;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 24px;
  font-weight: 300;
  margin: 0 auto 10px;
}

.logo-text {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.2;
}

.auth-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 5px;
}

body.dark-mode .auth-title {
  color: var(--text-main);
}

.auth-subtitle {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 30px;
}

.auth-group {
  text-align: left;
  margin-bottom: 20px;
}

.auth-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.input-icon {
  position: relative;
}

.input-icon > svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.input-icon .form-control {
  width: 100%;
  padding: 12px 40px 12px 40px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background-color: #f8fafc;
  color: #1e293b;
}

body.dark-mode .input-icon .form-control {
  background-color: var(--bg-dark);
  border-color: var(--border-color);
  color: var(--text-main);
}

.input-icon .form-control:focus {
  border-color: #38bdf8;
  background-color: #ffffff;
}

.btn-eye {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  z-index: 10;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  font-size: 0.85rem;
}

.checkbox-container {
  display: flex;
  align-items: center;
  color: #64748b;
  cursor: pointer;
}

.checkbox-container input {
  margin-right: 8px;
}

.auth-link {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 500;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-btn {
  width: 100%;
  padding: 14px;
  border-radius: 8px;
  font-size: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

#app-wrapper {
  width: 100%;
  min-height: 100vh;
}

/* RESPONSIVE SCALING FOR LAPTOPS (50% reduction as requested) */
@media (max-width: 1440px) {
  #app-wrapper {
    /* Reduce by scaling */
    zoom: 0.8; 
  }
}

/* Modals */
 
.cell-error {
  background-color: rgba(239, 68, 68, 0.15) !important;
  border: 2px solid #ef4444 !important;
  color: #ef4444 !important;
  font-weight: bold !important;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(11, 17, 32, 0.85); /* Slate 950 semi-transparent */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

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

.modal-content {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 25px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

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

.modal-content.modal-lg {
  max-width: 900px;
}

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

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}

.btn-close:hover {
  color: var(--danger-color);
}

.modal-body {
  margin-bottom: 20px;
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  background-color: var(--bg-dark);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

.btn-confirm {
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-confirm:hover {
  background-color: var(--primary-hover);
}

/* History Table specifics */
.history-table-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.btn-history {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-history:hover {
  background-color: rgba(56, 189, 248, 0.1);
}

.highlight-change {
  color: var(--primary-color);
  font-weight: 600;
}

/ *  
 M o d a l s  
 * /  
 



/* === REGLAS DEFINITIVAS SIN SUPERPOSICIÓN DE FILTROS === */
.filter-card {
  padding: 12px 15px !important;
  overflow: visible !important;
}

.filter-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: flex-end !important;
  gap: 12px 18px !important;
  width: 100% !important;
}

.filter-grid > div:not(.filter-range-group),
.filter-grid > .form-group:not(.filter-range-group) {
  margin-bottom: 0 !important;
  flex: 1 1 auto !important;
  min-width: 170px !important;
  max-width: 300px !important;
}

.filter-grid > .col-md-3 {
  width: 170px !important;
  min-width: 170px !important;
  max-width: 250px !important;
  flex: 1 1 auto !important;
}

.filter-grid > .col-md-5 {
  width: 240px !important;
  min-width: 240px !important;
  max-width: 300px !important;
  flex: 1 1 auto !important;
}

/* GRUPO DE RANGOS DE FECHA (SIN CAP DE ANCHO SUPERPUESTO) */
.filter-grid > .filter-range-group,
.filter-range-group {
  margin-bottom: 0 !important;
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 320px !important;
  max-width: 340px !important;
}

.filter-range-group > div {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  width: 100% !important;
}

.filter-range-group input[type="date"] {
  width: 130px !important;
  min-width: 125px !important;
  max-width: 135px !important;
  height: 38px !important;
  padding: 4px 8px !important;
  font-size: 0.82rem !important;
  box-sizing: border-box !important;
}

.filter-grid .form-control {
  height: 38px !important;
  padding: 6px 10px !important;
  font-size: 0.85rem !important;
  box-sizing: border-box !important;
}

.filter-grid label {
  font-size: 0.73rem !important;
  white-space: normal !important;
  line-height: 1.1 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  margin-bottom: 4px !important;
}

#add-filter-wrapper,
#add-filter-wrapper-cursos {
  min-width: 190px !important;
  max-width: 300px !important;
  flex: 1 1 auto !important;
}

/* === CORRECCIÓN BARRA FILTROS REMISIÓN POR TABLA === */
.remision-filter-bar {
  display: flex !important;
  align-items: flex-end !important;
  justify-content: flex-start !important;
  gap: 15px !important;
  width: 100% !important;
}

.remision-filter-item {
  width: 220px !important;
  min-width: 200px !important;
  flex: 0 0 220px !important;
  margin: 0 !important;
}

.remision-filter-item select.form-control {
  height: 38px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.btn-nuevo-reporte-btn {
  margin-left: auto !important;
  height: 38px !important;
  padding: 0 18px !important;
  font-weight: 600 !important;
  font-size: 0.88rem !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  border-radius: 6px !important;
  border: none !important;
  background-color: var(--success-color, #10b981) !important;
  color: #ffffff !important;
  white-space: nowrap !important;
  transition: opacity 0.2s ease !important;
}

.btn-nuevo-reporte-btn:hover {
  opacity: 0.9 !important;
}

/* === SWEETALERT2 INTEGRACIÓN CON MODO OSCURO === */
.swal2-popup {
  background-color: var(--bg-card) !important;
  color: var(--text-main) !important;
}
.swal2-title {
  color: var(--text-main) !important;
}
.swal2-html-container {
  color: var(--text-muted) !important;
}

/* === RESTRICCIONES DE COLABORADOR === */
body.is-colaborador .editable-cell {
  pointer-events: none !important;
}
body.is-colaborador .btn-eliminar-fila {
  display: none !important;
}
