:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --light-color: #f8f9fc;
    --dark-color: #5a5c69;
}

/* Estilos generales */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fc;
    margin: 0;
    padding: 0;
}

.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.login-card {
    border: none;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.sidebar {
    min-height: 100vh;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    background: linear-gradient(180deg, #4e73df 0%, #224abe 100%);
}

.sidebar .nav-link {
    color: #fff;
    padding: 15px 20px;
    border-radius: 5px;
    margin: 5px 10px;
    transition: all 0.3s;
    border: none;
    font-weight: 500;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateX(5px);
}

.sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.35rem 1.5rem 0 rgba(58, 59, 69, 0.2);
}

/* Border colors para stats */
.border-left-primary {
    border-left: 0.25rem solid var(--primary-color) !important;
}

.border-left-success {
    border-left: 0.25rem solid var(--success-color) !important;
}

.border-left-info {
    border-left: 0.25rem solid var(--info-color) !important;
}

.border-left-warning {
    border-left: 0.25rem solid var(--warning-color) !important;
}

.border-left-danger {
    border-left: 0.25rem solid var(--danger-color) !important;
}

/* Botones */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 500;
}

.btn-primary:hover {
    background-color: #2e59d9;
    border-color: #2e59d9;
    transform: translateY(-1px);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: #000;
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Tablas */
.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.075);
    transform: scale(1.01);
    transition: all 0.2s ease;
}

.table th {
    border-top: none;
    font-weight: 600;
    color: var(--dark-color);
}

/* Badges */
.badge {
    font-size: 0.75em;
    padding: 0.5em 0.75em;
    font-weight: 500;
}

/* Navbar */
.navbar-light .navbar-toggler {
    border-color: rgba(0, 0, 0, 0.1);
}

/* Estilos para el escáner */
.scanner-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    aspect-ratio: 2 / 1; /* Proporción 2:1 para móviles y desktop */
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#interactive {
    position: relative;
    width: 100%;
    height: 100%;
}

#interactive video,
#interactive canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.viewport canvas, .viewport video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.scanner-overlay::before {
    content: '';
    position: absolute;
    top: 30%;
    left: 10%;
    width: 80%;
    height: 40%; /* 40% de altura para mantener proporción 2:1 dentro del área de escaneo */
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.scan-line {
    position: absolute;
    top: 30%;
    left: 10%;
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00ff00, transparent);
    animation: scan 2s linear infinite;
    z-index: 11;
}

@keyframes scan {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(calc(40vh - 4px)); /* Se mueve dentro del área de 40% de altura */
    }
}

.corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid #00ff00;
    z-index: 11;
}

.corner.top-left {
    top: 30%;
    left: 10%;
    border-right: none;
    border-bottom: none;
}

.corner.top-right {
    top: 30%;
    right: 10%;
    border-left: none;
    border-bottom: none;
}

.corner.bottom-left {
    bottom: 30%;
    left: 10%;
    border-right: none;
    border-top: none;
}

.corner.bottom-right {
    bottom: 30%;
    right: 10%;
    border-left: none;
    border-top: none;
}

.scan-success {
    animation: pulse-green 1s ease-in-out;
}

@keyframes pulse-green {
    0% { 
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); 
    }
    70% { 
        box-shadow: 0 0 0 15px rgba(40, 167, 69, 0); 
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); 
    }
}

/* Estados de cámara */
.camera-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Botones del escáner en grupo */
.btn-group-scanner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.btn-group-scanner .btn {
    flex: 1;
    min-width: 140px;
    margin: 2px;
    padding: 10px 15px;
    font-weight: 500;
}

/* Botones flotantes para móviles */
@media (max-width: 768px) {
    .btn-group {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1050;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        border-radius: 50px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        padding: 5px;
    }
    
    .btn-group .btn {
        border-radius: 50%;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 2px;
        font-size: 1.2em;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    
    /* Asegurar que el contenido no quede detrás de los botones flotantes */
    main {
        padding-bottom: 80px !important;
    }
    
    /* Sidebar mejorado para móviles */
    #sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        z-index: 1045;
        height: 100vh;
        overflow-y: auto;
    }
    
    #sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
    }
    
    /* Mejoras específicas para el escáner en móviles */
    .scanner-container {
        height: 300px;
    }
    
    .viewport canvas, .viewport video {
        height: 100% !important;
        object-fit: cover;
    }
    
    /* Ajustes para mensajes de estado */
    #cameraStatus {
        font-size: 0.9em;
        padding: 12px;
        margin: 10px 0;
        border-radius: 8px;
    }
    
    /* Botones del escáner en móviles */
    .btn-group-scanner {
        flex-direction: column;
    }
    
    .btn-group-scanner .btn {
        min-width: 100%;
        margin: 3px 0;
    }
    
    /* Stats cards en móviles */
    .stats-card .card-body {
        padding: 1rem;
    }
    
    .stats-card .h5 {
        font-size: 1.1rem;
    }
}

/* Mejoras para tablets */
@media (max-width: 992px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .px-md-4 {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .scanner-container {
        height: 350px;
    }
}

/* Soporte para orientación en móviles */
@media (max-width: 768px) {
    .scanner-container {
        max-width: 100%;
        aspect-ratio: 2 / 1; /* Mantener proporción 2:1 en móviles */
        border-radius: 0;
    }
    
    /* Ajustar área de enfoque para móviles */
    .scanner-overlay::before {
        top: 25%;
        left: 5%;
        width: 90%;
        height: 50%; /* Mayor área de escaneo en móviles */
    }
    
    .scan-line {
        top: 25%;
        left: 5%;
        width: 90%;
    }
    
    @keyframes scan {
        0%, 100% {
            transform: translateY(0);
        }
        50% {
            transform: translateY(calc(50vh - 4px));
        }
    }
    
    .corner.top-left {
        top: 25%;
        left: 5%;
    }
    
    .corner.top-right {
        top: 25%;
        right: 5%;
    }
    
    .corner.bottom-left {
        bottom: 25%;
        left: 5%;
    }
    
    .corner.bottom-right {
        bottom: 25%;
        right: 5%;
    }
    
    /* Esquinas más pequeñas en móviles */
    .corner {
        width: 30px;
        height: 30px;
        border-width: 2px;
    }
}

/* Estilos para reportes */
.stats-card {
    transition: all 0.3s ease;
    border: none;
}

.stats-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15) !important;
}

.table-report th {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2e59d9 100%);
    color: white;
    border: none;
    padding: 12px 15px;
    font-weight: 600;
}

.table-report tbody tr:hover {
    background-color: rgba(78, 115, 223, 0.05);
    transform: scale(1.005);
    transition: all 0.2s ease;
}

/* Animaciones */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Estilos para exportación */
.export-options {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    padding: 25px;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.export-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.export-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Mejoras para formularios */
.form-control, .form-select {
    border: 1px solid #e3e6f0;
    border-radius: 8px;
    padding: 10px 15px;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
    transform: translateY(-1px);
}

/* Alertas personalizadas */
.alert {
    border: none;
    border-radius: 10px;
    padding: 15px 20px;
    font-weight: 500;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f1b0b7 100%);
    color: #721c24;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #b6effb 100%);
    color: #0c5460;
}

/* Loaders y estados de carga */
.loader {
    border: 3px solid #f3f3f3;
    border-radius: 50%;
    border-top: 3px solid var(--primary-color);
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mejoras para modales */
.modal-content {
    border: none;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2e59d9 100%);
    color: white;
    border-radius: 15px 15px 0 0;
    border: none;
}

.modal-header .btn-close {
    filter: invert(1);
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2e59d9;
}

/* Utilidades adicionales */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--info-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.shadow-custom {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.hover-lift {
    transition: all 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-3px);
}

/* Estados de botones con iconos */
.btn i {
    transition: transform 0.2s ease;
}

.btn:hover i {
    transform: scale(1.1);
}

/* Mejoras para la tabla DataTables */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: none !important;
    border-radius: 8px !important;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    color: white !important;
}

/* Responsive improvements para pantallas muy pequeñas */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 5px;
        padding-right: 5px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.9em;
    }
    
    .display-6 {
        font-size: 2rem;
    }
    
    h1.h3 {
        font-size: 1.5rem;
    }
}

/* Dark mode support (preparación) */
@media (prefers-color-scheme: dark) {
    .card {
        background-color: #2d3748;
        color: #e2e8f0;
    }
    
    .table {
        color: #e2e8f0;
    }
    
    .form-control, .form-select {
        background-color: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
}

/* Impresión */
@media print {
    .btn, .navbar, .sidebar, .alert {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* Navbar mejorado para móviles */
.navbar-nav .nav-link {
    color: var(--primary-color) !important;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(78, 115, 223, 0.1);
    transform: scale(1.1);
}

/* Sidebar backdrop */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
}

/* Botón de cerrar en sidebar móvil */
.sidebar .btn-close {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.sidebar .btn-close:hover {
    opacity: 1;
}

/* Mejoras específicas para móviles */
@media (max-width: 991.98px) {
    .navbar-brand {
        font-size: 1rem;
    }
    
    .navbar-nav .nav-link {
        padding: 6px 10px;
        margin: 0 2px;
    }
    
    /* Asegurar que el sidebar ocupe toda la pantalla en móviles */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    #sidebar.show {
        transform: translateX(0);
    }
}

/* Mejoras para el escáner en móviles con problemas de cámara */
.camera-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    aspect-ratio: 2 / 1;
}

.camera-fallback-content {
    text-align: center;
    padding: 2rem;
}

.camera-fallback-content i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.camera-fallback-content h4 {
    margin-bottom: 1rem;
}

.camera-fallback-content p {
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

.scan-success .scanner-overlay::before {
    border-color: #00ff00;
    animation: pulse-success 0.5s ease-in-out;
}

@keyframes pulse-success {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@media (max-width: 576px) {
    .btn-group-scanner {
        flex-direction: column;
    }
    
    .btn-group-scanner .btn {
        width: 100%;
        margin: 0 !important;
    }
}