/* styles.css */

/* ============================================= */
/* --- RESET BÁSICO Y LAYOUT GENERAL --- */
/* ============================================= */

body {font-family: Arial, sans-serif; margin: 0; background-color: #f8f8f8;color: #333;min-height: 100vh;display: flex; flex-direction: column;}
#app-container {max-width: 1450px;width: 100%;margin: 30px auto;padding: 20px; box-sizing: border-box; flex-grow: 1;}
h1, h2, h3, h4 {color: #007bff;margin-top: 0;}
h1 {font-size: 2.2em;margin-bottom: 5px;border-bottom: 2px solid #007bff;padding-bottom: 5px;}
a {color: #007bff;text-decoration: none;}
a:hover {text-decoration: underline;}

/* ============================================= */
/* --- HEADER, FOOTER Y NAVEGACIÓN PRINCIPAL --- */
/* ============================================= */

/* .site-header {background-color: #333;padding: 10px 20px;box-shadow: 0 2px 5px rgba(0,0,0,0.2);position: sticky;top: 0;z-index: 999;} */
.site-header {background-color: #FF6600; background: linear-gradient(to left, #004e92, #FF6600);color: #FFFFFF;padding: 10px 20px;box-shadow: 0 4px 15px rgba(255, 78, 0, 0.3);position: sticky;top: 0;z-index: 999;}
.site-header h1, .site-header .logo {text-shadow: 0 2px 4px rgba(0,0,0,0.2); font-weight: 700;}
.main-navigation {display: flex;justify-content: center;flex-wrap: wrap;gap: 15px;}
.main-navigation a {color: white; text-decoration: none; font-weight: bold; font-size: 0.9em; padding: 8px 12px; border-radius: 5px; transition: background-color 0.3s, color 0.3s;}
.main-navigation a:hover {background-color: #007bff;color: white !important; text-decoration: none;}
.main-navigation {align-items: center; }
.nav-dropdown .dropdown-toggle {display: flex;    align-items: center; gap: 5px;  height: 100%;   box-sizing: border-box;}
.dropdown-toggle .fa-chevron-down {margin-left: 0 !important;line-height: 1; display: block; }
.site-footer-main {text-align: center;padding: 20px;background: linear-gradient(to right, #004e92, #FF6600);color: #ffffff; font-size: 0.9em;margin-top: 30px;border-top: 1px solid rgba(255, 255, 255, 0.1);}
.hamburger-menu {display: none;position: relative; z-index: 1010;background-color: transparent;border: none;padding: 10px;cursor: pointer;}
.hamburger-box {width: 30px;height: 24px;display: inline-block;position: relative;}
.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {width: 100%;height: 3px; background-color: #fff;border-radius: 4px;position: absolute;transition: transform 0.2s ease-in-out;}
.hamburger-inner {
    top: 50%;transform: translateY(-50%);
}
.hamburger-inner::before,
.hamburger-inner::after {
    content: '';
}
.hamburger-inner::before {
    top: -10px;
}
.hamburger-inner::after {
    bottom: -10px;
}

/* ============================================= */
/* --- ESTILOS DE PÁGINAS ESPECÍFICAS --- */
/* ============================================= */

/* --- LOGIN (login.php) --- */
body.body-login { background-image: url('fondo.webp');background-size: cover; background-position: center center;background-attachment: fixed; background-repeat: no-repeat;}
body.body-login #app-container {margin: 0;display: flex;justify-content: center;align-items: center;max-width: 100%;}

#login-container {max-width: 350px;width: 90%;margin: 20px auto;padding: 25px;background-color: rgba(255, 255, 255, 0.9);border: 1px solid #ddd;border-radius: 8px;box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);text-align: center;backdrop-filter: blur(5px);}
#login-container h1 {    margin-bottom: 20px;color: #007bff;}
#login-container form {display: flex;flex-direction: column;}
#login-container label {text-align: left;margin-bottom: 5px;font-weight: bold;font-size: 0.9em;}
#login-container input[type="text"],
#login-container input[type="password"] {padding: 10px;margin-bottom: 15px;border: 1px solid #ccc;border-radius: 4px;font-size: 1em;width: 100%;box-sizing: border-box;}
#login-container button {background-color: #007bff;color: white;padding: 12px;border: none;border-radius: 4px;cursor: pointer;font-size: 1.1em;transition: background-color 0.3s;}
#login-container button:hover {background-color: #0056b3;}

/* --- DASHBOARD (index.php) --- */
.dashboard-grid {display: flex;flex-wrap: wrap;gap: 20px;margin-top: 30px;justify-content: center;}
.dashboard-card {flex-basis: 300px;flex-grow: 0;background-color: white; border: 1px solid #ddd; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);transition: transform 0.3s, box-shadow 0.3s;text-align: center;padding: 20px;box-sizing: border-box;}
.dashboard-card:hover {transform: translateY(-5px);box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);border-color: #007bff;}
.dashboard-card a {display: flex;flex-direction: column;justify-content: center;align-items: center;width: 100%;height: 100%;color: #333;font-size: 1.1em;font-weight: bold;text-decoration: none;}
.dashboard-card a i {font-size: 3em;margin-bottom: 10px;display: block; color: #007bff;font-family: 'Twemoji Mozilla', 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;}

/* --- ESCÁNER (scanner.php) --- */
#scanner-interface {position: relative;width: 100%;max-width: 500px;height: 350px;overflow: hidden;margin: 10px auto;background: #000;}
#scanner-interface .viewport,#scanner-interface video,#scanner-interface canvas { width: 100% !important; height: 100% !important; position: absolute !important; left: 0 !important; top: 0 !important; object-fit: cover;}

/* ============================================ */
/* --- ESTILOS DE COMPONENTES REUTILIZABLES --- */
/* ============================================ */

/* --- FONDOS DE PÁGINA --- */
body.has-custom-bg #app-container,.body-background #app-container {background-color: rgba(255, 255, 255, 0.92); border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);}

/* --- FORMULARIOS --- */
fieldset {border: 1px solid #ddd;border-radius: 6px;padding: 15px;margin-bottom: 20px;max-width: 100%;box-sizing: border-box;}
legend {font-weight: bold;color: #007bff;padding: 0 10px;}

fieldset input[type="text"],fieldset input[type="number"],fieldset input[type="url"],fieldset input[type="email"],fieldset input[type="password"],fieldset select,fieldset textarea {
    width: 100%;max-width: 450px;padding: 8px;border: 1px solid #ccc;border-radius: 4px;box-sizing: border-box;}

/* --- TABLAS Y ACORDEÓN --- */
table {border-collapse: collapse;width: 100%;margin-top: 15px;}
th, td {border: 1px solid #dee2e6;padding: 8px;text-align: left;}
th {background-color: #e9ecef;}

.table-responsive {display: block;width: 100%;overflow-x: auto;-webkit-overflow-scrolling: touch;border-radius: 6px;margin-bottom: 1.5em;}

/* Tabla con scroll (managebooks.php) */
.table-scrollable {border: 1px solid #ddd;}
.table-scrollable th,.table-scrollable td {white-space: nowrap;} /* Fuerza el scroll */

/* Tabla en formato tarjeta (scanner.php) */
.table-responsive:not(.table-scrollable) {border: none;overflow-x: hidden;}

.category-header{display:flex;align-items:center;cursor:pointer;padding:10px;margin-top:5px;border:1px solid #ddd;-webkit-user-select:none;user-select:none;transition:background-color .2s;background-color:#fff}
.category-header:hover{background-color:#f8f9fa}
.category-header h4{margin:0;flex-grow:1}
.category-header[data-level="0"]{background-color:#007bff;color:white!important;font-size:1.2em;border-radius:5px 5px 0 0;border-color:#0056b3;padding-left: 15px !important;}
.category-header[data-level="0"] h4{color:#fff!important}
.toggle-icon{display:inline-block;width:0;height:0;margin-right:8px;vertical-align:middle;border-top:6px solid transparent;border-bottom:6px solid transparent;border-left:6px solid;transition:transform .3s ease-in-out}
.category-header[data-level="0"] .category-counter {
    color: #d1eaff !important; 
}.category-header.active .toggle-icon{transform:rotate(90deg)}
.accordion-content{display:none;padding:15px;border:1px solid #ddd;border-top:none;background-color:#fdfdfd}
.category-thumbnail{width:40px;height:40px;object-fit:cover;border-radius:4px;margin-right:10px;background-color:#f0f0f0}
.category-thumbnail-placeholder{display:inline-block;width:40px;height:40px;margin-right:10px}
.category-header:hover {transform: translateY(-1px);box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);border-color: #007bff;}

/* --- BOTONES Y ENLACES ESPECIALES --- */
.add-new-button-link {display: inline-block;background-color: #28a745;color: white !important;padding: 8px 15px;border-radius: 5px;font-size: 1.1em;font-weight: bold;margin-top: 10px;text-decoration: none;transition: background-color 0.3s;}
.add-new-button-link:hover {background-color: #1e7e34;text-decoration: none;}

/* --- MODALES --- */
.modal {display: none;position: fixed;z-index: 1000;left: 0;top: 0;width: 100%;height: 100%; background-color: rgba(0, 0, 0, 0.6);}
.modal-content { position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);animation: zoomIn 0.3s ease-out forwards;max-height: 90vh;overflow-y: auto;padding: 20px;width: 80%;max-width: 900px;
    border-radius: 12px;background: #fefefe;border: 2px solid #8B4513;box-shadow:inset 3px 3px 6px rgba(255, 235, 150, 0.7),inset -3px -3px 6px rgba(101, 58, 2, 0.6),0 8px 20px rgba(0, 0, 0, 0.5);}
.close-button {color: #aaa;float: right;font-size: 28px;font-weight: bold;}

/* ================================== */
/* --- ESTILOS PARA LA PAGINACIÓN --- */
/* ================================== */

.pagination-container {display: flex;justify-content: center;margin-top: 20px;}
.pagination {list-style: none;padding: 0;display: flex;gap: 5px;}
.pagination li a {display: block;padding: 8px 12px;border: 1px solid #ddd;background-color: #fff;color: #007bff;text-decoration: none;border-radius: 4px;transition: background-color 0.2s, color 0.2s;}
.pagination li a:hover {background-color: #f0f0f0;}
.pagination li.active a {background-color: #007bff;color: white;border-color: #007bff;cursor: default;}

/* ============================================= */
/* --- MEDIA QUERIES: OPTIMIZACIÓN MÓVIL --- */
/* ============================================= */

@media (max-width: 850px) {
    /* NAVEGACIÓN PRINCIPAL */
    .site-header {display: flex;justify-content: flex-end;align-items: center;}
    .hamburger-menu {display: block;}
    .main-navigation {position: fixed;top: 0;left: 0;width: 280px;height: 100vh;background-color: #333;transform: translateX(-100%);transition: transform 0.3s ease-in-out;flex-direction: column;justify-content: flex-start;padding-top: 80px;gap: 0;z-index: 1000;box-sizing: border-box;}
    .main-navigation.is-active {transform: translateX(0);}
    .main-navigation a {padding: 15px 20px;width: 100%;text-align: left;border-bottom: 1px solid #444;box-sizing: border-box;}
    .hamburger-menu.is-active .hamburger-inner {transform: rotate(45deg);}
    .hamburger-menu.is-active .hamburger-inner::before {top: 0;transform: rotate(-90deg);}
    .hamburger-menu.is-active .hamburger-inner::after {bottom: 0;transform: rotate(-90deg);opacity: 0;}
}

@media (max-width: 768px) {
    body { margin: 0; }
    #app-container {padding: 10px;margin: 0;}
    #login-container {margin: 40px 10px; max-width: none;}
    #scanner-interface {
        width: 100% !important;max-width: 100% !important;height: 40vh;min-height: 250px;margin: 10px auto !important;}
    #camera-selector button {flex-basis: auto;font-size: 0.8em;}
    .dashboard-grid {flex-direction: row;flex-wrap: wrap;justify-content: space-around;gap: 15px;padding: 0 10px;}
    .dashboard-card {flex-basis: calc(50% - 10px);width: auto;margin: 0;padding: 15px 10px;}
    .dashboard-card a {flex-direction: row;justify-content: flex-start;align-items: center;font-size: 0.9em;text-align: left; }
    .dashboard-card a i {font-size: 1.6em;margin-right: 10px; margin-bottom: 0;}
    .table-responsive:not(.table-scrollable) table thead {display: none;}
    .table-responsive:not(.table-scrollable) table tr {display: block;border: 1px solid #ddd;border-radius: 6px;margin-bottom: 15px;padding: 10px;}
    .table-responsive:not(.table-scrollable) table td {display: block;text-align: right;position: relative;padding-left: 50%;border: none;white-space: normal; }
    .table-responsive:not(.table-scrollable) table td:before {content: attr(data-label);position: absolute;left: 10px;width: 45%;padding-right: 10px;font-weight: bold;text-align: left;white-space: nowrap;}
    .pagination-container, .pagination {flex-wrap: wrap;        justify-content: center;}
}

/* ============================================= */
/* --- ESTILOS PARA NUEVO MENÚ DESPLEGABLE --- */
/* ============================================= */
.nav-dropdown {position: relative;display: inline-block;}
.dropdown-toggle .fa-chevron-down {font-size: 0.7em;margin-left: 5px;transition: transform 0.3s ease;}
.dropdown-menu {display: none;position: absolute;background-color: #3d3d3d;min-width: 240px;box-shadow: 0 8px 16px rgba(0,0,0,0.3);z-index: 1001; border-radius: 0 0 5px 5px;overflow: hidden; }
.dropdown-menu a {color: #f2f2f2;padding: 12px 16px;text-decoration: none;display: block;font-size: 0.85em !important;border-bottom: 1px solid #555;transition: background-color 0.2s;}
.dropdown-menu a:last-child {border-bottom: none;}
.dropdown-menu hr {border: 0;height: 1px;background-color: #555;margin: 0;}
.nav-dropdown:hover .dropdown-menu {display: block;}
.nav-dropdown:hover .dropdown-toggle .fa-chevron-down {transform: rotate(180deg);}
.dropdown-menu a:hover {background-color: #575757;color: #fff !important;}
.nav-logout {border-left: 1px solid #555;}
@media (max-width: 850px) {
    .main-navigation {overflow-y: auto;}
    .nav-dropdown {display: block;width: 100%;}
    .dropdown-toggle, .main-navigation a {display: flex;justify-content: space-between;align-items: center;width: 100%;}
    .dropdown-menu {position: static;display: none; width: 100%;box-shadow: none;background-color: rgba(0,0,0,0.2);border-radius: 0;padding-left: 20px; box-sizing: border-box;}
    .dropdown-menu.is-open {display: block;}
    .dropdown-toggle.is-open .fa-chevron-down {transform: rotate(180deg);}
    .dropdown-menu a {border: none !important;}
    
    @media (min-width: 851px) {
        .nav-dropdown:hover .dropdown-menu {display: block;}
        .nav-dropdown:hover .dropdown-toggle .fa-chevron-down {transform: rotate(180deg);}
    }
    .nav-logout {border-left: none; margin-top: 20px; border-top: 1px solid #444;}
    .page-overlay {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background: rgba(0,0,0,0.5);z-index: 998; opacity: 0;visibility: hidden;transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;}
    .page-overlay.is-active {opacity: 1;visibility: visible;}
}

/* ============================================= */
/* --- ANIMACIONES PARA MODALES --- */
/* ============================================= */

@keyframes zoomIn {
  from {opacity: 0;transform: translate(-50%, -50%) scale(0.5); }
  to {opacity: 1;transform: translate(-50%, -50%) scale(1); }
}

/* ============================================= */
/* --- ESTILOS PARA ASIGNACIÓN DE DATOS (NUEVO) --- */
/* ============================================= */

.field-is-active {background-color: #e7f3fe !important;border-color: #007bff !important;box-shadow: 0 0 5px rgba(0,123,255,0.5) !important;}

/* Contenedor para los datos escaneados */
#scanned-results {display: flex;flex-wrap: wrap; gap: 8px;padding: 10px;background-color: #f9f9f9;border: 1px dashed #ccc;border-radius: 4px;min-height: 50px;}

/* Estilo de los botones de datos escaneados */
.scanned-data-item {background-color: #007bff;color: white;border: none; padding: 8px 12px;border-radius: 20px;cursor: pointer;font-size: 0.9em;font-weight: bold;transition: background-color 0.2s, transform 0.2s;max-width: 100%;    height: auto;   white-space: normal;  word-break: break-all;text-align: left;  }
.scanned-data-item:hover {background-color: #0056b3;transform: translateY(-2px);}

/* Contenedor principal del historial */
#image-history-container {background-color: #f8f9fa;border: 1px solid #dee2e6;border-radius: 5px;padding: 10px;overflow-x: auto;white-space: nowrap; }
/* Bandeja que contiene las miniaturas */
#image-history-tray {display: flex;gap: 10px;}  /* flex para alinear las miniaturas */

/* Cada elemento de miniatura */
.thumbnail-item {position: relative;cursor: pointer;border: 3px solid transparent;border-radius: 5px;transition: border-color 0.2s;height: 75px;}
.thumbnail-item img {height: 100%;width: auto;display: block;border-radius: 3px;}
.thumbnail-item.active {border-color: #0d6efd; /* Azul de Bootstrap */}
.close-thumbnail {position: absolute;top: -8px;right: -8px;width: 20px;height: 20px;background-color: #dc3545; /* Rojo de Bootstrap */color: white;border-radius: 50%;display: flex;align-items: center;justify-content: center;font-size: 14px;font-weight: bold;line-height: 1;cursor: pointer;opacity: 0.8;transition: opacity 0.2s;}

.close-thumbnail:hover {opacity: 1;}
.copy-toast {position: fixed;bottom: 20px;left: 50%;transform: translateX(-50%);background-color: #28a745;color: white;padding: 10px 20px;border-radius: 5px;z-index: 10000;opacity: 0;visibility: hidden;transition: opacity 0.3s, visibility 0.3s;}
.copy-toast.show {opacity: 1;visibility: visible;}
.custom-loading-mask { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 9999; color: white; display: flex; align-items: center; justify-content: center; }

/* Estilos de Modales (copiados de NewScan) */
.custom-modal-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1050; }
.custom-modal-mask { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); }
.custom-window-container { position: relative; width: 600px; margin: 50px auto; background-color: #fff; border-radius: 5px; box-shadow: 0 5px 15px rgba(0,0,0,.5); }
.custom-window-title-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; background-color: #f7f7f7; border-bottom: 1px solid #ebebeb; border-radius: 5px 5px 0 0; }
.custom-window-title { font-weight: bold; }
.custom-close-btn { cursor: pointer; font-size: 1.2rem; }

/* Estilos para las nuevas zonas de imagen Frontal/Trasera */
.image-drop-zone {border: 2px dashed #ccc;border-radius: 5px;padding: 10px;text-align: center;cursor: pointer;background-color: #f9f9f9;height: 200px; /* Altura fija */display: flex;flex-direction: column;align-items: center;justify-content: center;transition: background-color 0.2s, border-color 0.2s;}
.image-drop-zone:hover {background-color: #f0f0f0;border-color: #0d6efd;}
.image-drop-zone.drop-zone-active {border-color: #0d6efd;box-shadow: 0 0 10px rgba(13,110,253,0.5);}
.image-drop-zone img {max-height: 150px; /* Ajustado a la altura del drop-zone */max-width: 100%;margin-bottom: 10px;object-fit: contain;}
.image-drop-zone span {font-size: 0.9em;color: #888;}

#open-scanner-panel {background-color: #0d6efd;border: none;font-weight: bold;}
#open-scanner-panel:hover {background-color: #0b5ed7;}
#open-scanner-panel i {margin-right: 10px;}
/* ============================================= */
/* --- ESTILOS PARA EL NUEVO MODAL DE CONFIG --- */
/* ============================================= */

/* Estilos para las pestañas (Tabs) */
.config-nav-tabs {display: flex;border-bottom: 1px solid #dee2e6;margin-bottom: 15px;}
.config-nav-tabs .nav-link {border: 1px solid transparent;border-top-left-radius: .25rem;border-top-right-radius: .25rem;padding: .5rem 1rem;cursor: pointer;background-color: transparent;border-color: transparent transparent #dee2e6;}
.config-nav-tabs .nav-link:hover {border-color: #e9ecef #e9ecef #dee2e6;}
.config-nav-tabs .nav-link.active {background-color: #fff;border-color: #dee2e6 #dee2e6 #fff;font-weight: bold;}
.config-tab-content .tab-pane {display: none;}
.config-tab-content .tab-pane.active {display: block;}

#visual-config-content {display: grid;grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));gap: 20px;}
.config-group {border: 1px solid #eee;padding: 10px;border-radius: 5px;}
.config-group legend {font-size: 1.1em;font-weight: bold;color: #007bff;padding: 0 5px;width: auto;}
.config-item {margin-bottom: 15px;}
.config-item label {display: block;margin-bottom: 5px;font-weight: bold;}

/* Estilos para los Switches (Bootstrap) */
.form-switch {padding-left: 2.5em;display: flex; align-items: center;}
.form-check-input {width: 2em;height: 1em;margin-left: -2.5em;background-color: #6c757d;border: 1px solid #6c757d;background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");background-position: left center;border-radius: 2em;transition: background-position .15s ease-in-out;cursor: pointer;}
.form-check-input:checked {background-position: right center;background-color: #0d6efd;border-color: #0d6efd;}

/* Arreglo para el modal de config en el pop-up */
.custom-window-content {max-height: 60vh; /* Altura máxima del 60% del pop-up */overflow-y: auto; /* ¡Añade el scroll vertical! */}

/* ============================================= */
/* --- ESTILOS PARA EL MODAL DE CONFIG (v8.3) --- */
/* ============================================= */
/* Contenedor principal de la pestaña visual (GRID de 2 Columnas) */
#visual-config-content {display: grid;grid-template-columns: 1fr 1fr; /* ¡Diseño de 2 columnas! */gap: 10px 20px; /* Espacio vertical y horizontal */}
/* Columna individual (para agrupar fieldsets) */
.config-col {display: flex;flex-direction: column;gap: 10px; /* Espacio entre fieldsets */min-width: 0; /* Previene desbordamiento */}
.config-group {margin-bottom: 0;}
.config-item {margin-bottom: 10px; /* Espacio entre cada opción */}
/* Encabezado (Toggle + Label + Tooltip) */
.config-item-header {display: flex;align-items: center;margin-bottom: 5px;}
.config-item-header .form-check-label {font-weight: bold;font-size: 0.85em; /* Letra un poco más pequeña */margin-right: 5px;}
.config-item-header .form-check-input {margin-top: 0;margin-right: 8px;}
/* (NUEVO) Icono de Tooltip (i) */
.config-tooltip {font-size: 0.8em;font-weight: bold;color: #0d6efd;background-color: #e7f3ff;border-radius: 50%;width: 16px;height: 16px;display: inline-flex;align-items: center;justify-content: center;cursor: help;border: 1px solid #0d6efd;line-height: 1;}
/* Contenedor del input (Select, Range, etc.) */
.config-item-input {padding-left: 1.5em; /* Alinear con el texto del label */}
/* Arreglo para el valor del slider */
.config-item-input .form-range {padding: 0; /* Quitar padding de los sliders */}
.range-value {font-weight: bold; min-width: 35px; /* Ancho mínimo para el valor */text-align: right;font-size: 0.9em;}

/* --- MEJORAS TABLA RESPONSIVA (Sticky Actions) --- */
.table-responsive {
    overflow-x: auto;
    position: relative; /* Necesario para el sticky */
}

/* Fijar la última columna (Acciones) a la derecha */
table th:last-child,
table td:last-child {
    position: sticky;
    right: 0;
    background-color: #fff; /* Fondo blanco para tapar lo que pasa por debajo */
    z-index: 5;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1); /* Sombra para separar visualmente */
    text-align: center;
}

/* En modo oscuro o encabezado, ajustar fondo */
table th:last-child {
    background-color: #e9ecef; 
}

/* Estilo para botones de iconos */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    margin: 0 2px;
    text-decoration: none !important;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

.btn-icon.view { color: #17a2b8; background-color: #e0f7fa; border-color: #17a2b8; }
.btn-icon.edit { color: #ffc107; background-color: #fff3cd; border-color: #ffc107; }
.btn-icon.delete { color: #dc3545; background-color: #f8d7da; border-color: #dc3545; }

.btn-icon:hover { opacity: 0.8; transform: translateY(-1px); }

/* --- ESTILOS PARA EL MODAL DE DETALLES --- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    text-align: left;
    margin-top: 10px;
}

.detail-item {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #eee;
}

.detail-item label {
    display: block;
    font-size: 0.85em;
    color: #666;
    font-weight: bold;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.detail-item span, .detail-item div {
    font-size: 1em;
    color: #333;
    word-break: break-word; /* Evita que urls largas rompan el diseño */
}

.detail-full-width {
    grid-column: 1 / -1; /* Ocupa todo el ancho */
}

/* Ajuste móvil para el modal */
@media (max-width: 600px) {
    .detail-grid { grid-template-columns: 1fr; }
}