/**
 * Estilos para el módulo de Entrega de Surtido
 * Sistema de Inventario Taco Loco
 */

:root {
    /* Colores principales */
    --primary-color: #007aff;
    --secondary-color: #5ac8fa;
    --success-color: #34c759;
    --danger-color: #ff3b30;
    --warning-color: #ffcc00;
    
    /* Colores de texto */
    --text-primary: #000000;
    --text-secondary: #8e8e93;
    
    /* Colores de fondo */
    --background-primary: #f2f2f7;
    --background-secondary: #ffffff;
    
    /* Otros colores */
    --border-color: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overscroll-behavior-y: none;
    touch-action: pan-y;
}

/* -----------------
   1. CONTENEDORES PRINCIPALES
   ----------------- */
.container {
    max-width: 100%;
    padding: 0;
}

.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    max-width: 400px;
    margin: 0 auto;
}

.admin-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
}

/* -----------------
   2. PANTALLA DE LOGIN
   ----------------- */
.logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.logo {
    max-width: 180px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.login-form {
    width: 100%;
    background-color: var(--background-secondary);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.form-header {
    text-align: center;
    margin-bottom: 24px;
}

.form-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.form-header p {
    color: var(--text-secondary);
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 16px;
}

.form-control {
    height: 50px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    font-size: 16px;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    outline: none;
}

.btn-primary {
    background-color: var(--primary-color);
    border: none;
    border-radius: 10px;
    height: 50px;
    font-weight: 500;
    font-size: 16px;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: #0062cc;
}

.btn-outline-primary {
    color: var(--primary-color);
    background-color: transparent;
    border: 1px solid var(--primary-color);
    border-radius: 10px;
    height: 50px;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.2s ease;
}

.btn-outline-primary:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

.alert {
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 20px;
    border: none;
}

.alert-danger {
    background-color: #ffeeee;
    color: var(--danger-color);
    border: 1px solid #ffdddd;
}

/* -----------------
   3. PANEL DE ADMINISTRADOR
   ----------------- */
.admin-header {
    background-color: var(--background-secondary);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.admin-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.admin-actions {
    display: flex;
    gap: 10px;
}

.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    will-change: scroll-position;
    min-height: 0;
}

/* Reglas específicas para Android */
@supports (-webkit-overflow-scrolling: touch) and (selector(::-webkit-scrollbar)) {
    /* Solo aplica en Android (no en iOS) */
    .admin-content, 
    #ordenes-container,
    .productos-list {
        scrollbar-width: thin;
        -ms-overflow-style: -ms-autohiding-scrollbar;
        overscroll-behavior-y: contain;
    }
    
    .productos-list {
        max-height: none;
        overflow-y: visible;
    }
    
    /* Asegurar que no haya scroll en la lista de productos dentro de la entrega en Android */
    .entrega-container .productos-list {
        max-height: none;
        overflow-y: visible;
        overscroll-behavior-y: auto;
    }
}

/* -----------------
   4. CARDS DE ÓRDENES
   ----------------- */
.orden-card {
    background-color: var(--background-secondary);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.orden-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.orden-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.orden-details {
    padding: 16px;
}

.orden-info {
    margin-bottom: 12px;
}

.orden-info p {
    margin: 0;
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.orden-info .label {
    font-weight: 500;
    color: var(--text-secondary);
}

.orden-info .value {
    font-weight: 500;
}

.productos-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    max-height: none;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.producto-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.producto-nombre {
    font-weight: 500;
}

.producto-cantidad {
    font-weight: 600;
    color: var(--primary-color);
}

.orden-actions {
    padding: 12px 16px;
    background-color: #f9f9f9;
    display: flex;
    justify-content: flex-end;
}

.btn-entregar {
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.btn-entregar:hover {
    background-color: var(--success-color);
    color: white;
    opacity: 0.9;
}

.btn-entregar:active {
    background-color: #2eb150 !important;
    color: white !important;
    opacity: 1;
}

.btn-entregar:disabled {
    background-color: var(--success-color);
    opacity: 0.5;
    color: white;
}

/* Asegurar que los botones se vean correctamente en dispositivos táctiles */
.btn-entregar:focus,
.btn-entregar:hover:active,
.btn-entregar:focus:active,
.btn-confirmar-entrega:focus,
.btn-confirmar-entrega:hover:active,
.btn-confirmar-entrega:focus:active {
    background-color: #2eb150 !important;
    color: white !important;
    opacity: 1;
    outline: none;
}

/* Estilos para interacción táctil */
.btn-entregar,
.btn-confirmar-entrega {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

@media (hover: none) {
    .btn-entregar:hover,
    .btn-confirmar-entrega:hover {
        /* Evitar cambios de estilo al tocar en dispositivos táctiles */
        background-color: var(--success-color);
    }
}

/* -----------------
   5. ESTADO VACÍO 
   ----------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 60px;
    height: 60px;
    stroke: var(--text-secondary);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.empty-state p {
    max-width: 300px;
    margin: 0 auto;
}

/* -----------------
   6. BADGES PARA DÍAS DE RETRASO
   ----------------- */
.delay-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.delay-normal {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.delay-warning {
    background-color: #fff8e1;
    color: #f57f17;
}

.delay-danger {
    background-color: #ffebee;
    color: #c62828;
}

/* -----------------
   7. PANTALLA DE ENTREGA
   ----------------- */
.entrega-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-primary);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.entrega-container.active {
    display: flex;
}

.entrega-header {
    background-color: var(--background-secondary);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.entrega-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.entrega-header button {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.entrega-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    isolation: isolate;
    z-index: 5;
    position: relative;
}

.entrega-content:focus {
    outline: none;
}

.entrega-resumen {
    background-color: var(--background-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.entrega-section {
    margin-bottom: 24px;
}

.entrega-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: var(--text-primary);
}

.camera-container {
    margin-bottom: 16px;
}

.camera-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 150px;
    background-color: #f2f2f7;
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.camera-button:hover {
    background-color: #e5e5ea;
}

.camera-button svg {
    width: 48px;
    height: 48px;
    stroke: var(--text-secondary);
}

.camera-preview {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    display: none;
}

.camera-preview.active {
    display: block;
}

.pin-verification {
    max-width: 400px;
    margin: 0 auto;
    text-align: center;
}

.pin-input-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.pin-digit {
    width: 60px;
    height: 60px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.pin-digit.filled {
    border-color: var(--primary-color);
    background-color: rgba(0, 122, 255, 0.05);
}

.pin-keypad {
    max-width: 320px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 16px;
}

.pin-key {
    position: relative;
    aspect-ratio: 1/1;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: 400;
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pin-key:active {
    background-color: rgba(0, 0, 0, 0.15);
    transform: scale(0.96);
}

.pin-key-clear {
    background-color: rgba(255, 59, 48, 0.1);
    color: var(--danger-color);
    font-size: 16px;
    font-weight: 500;
}

.pin-key-clear:active {
    background-color: rgba(255, 59, 48, 0.2);
}

.signature-container {
    width: 100%;
    height: 200px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 16px;
}

.clear-signature {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--primary-color);
    font-weight: 500;
    cursor: pointer;
}

.leyenda-firma {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 10px;
    margin-bottom: 10px;
    background-color: rgba(52, 199, 89, 0.05);
    padding: 8px;
    border-radius: 6px;
    border-left: 3px solid var(--success-color);
}

.entrega-actions {
    padding: 16px;
    background-color: var(--background-secondary);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.btn-cancelar-entrega {
    background-color: var(--background-primary);
    color: var(--danger-color);
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-weight: 500;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-confirmar-entrega {
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s ease;
    min-height: 48px;
}

.btn-confirmar-entrega:hover {
    background-color: var(--success-color);
    color: white;
    opacity: 0.9;
}

.btn-confirmar-entrega:active {
    background-color: #2eb150 !important;
    color: white !important;
    opacity: 1;
}

.btn-confirmar-entrega:disabled {
    background-color: var(--success-color);
    opacity: 0.5;
    color: white;
}

/* Estilos para el mensaje de éxito en el modal de confirmación */
.success-message {
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.success-message h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 20px;
}

.success-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(52, 199, 89, 0.1);
    border-radius: 50%;
    width: 90px;
    height: 90px;
}

.success-icon svg {
    color: var(--success-color);
    width: 60px;
    height: 60px;
    animation: success-pulse 1.5s ease-in-out;
}

.confirmacion-actions {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.confirmacion-actions .btn-confirmar-entrega {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    text-decoration: none;
}

@keyframes success-pulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.loader-container {
    padding: 15px 0;
}

.confirmacion-modal .spinner-border {
    color: var(--success-color);
    width: 2.5rem;
    height: 2.5rem;
}

/* -----------------
   8. RESPONSIVIDAD
   ----------------- */
@media (min-width: 768px) {
    .admin-container {
        max-width: 960px;
        margin: 0 auto;
    }
    
    .entrega-container {
        max-width: 960px;
        margin: 0 auto;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px;
        overflow: hidden;
        height: auto;
        max-height: 90vh;
        top: 6vh;
        bottom: 5vh;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        display: none;
    }
    
    .entrega-container.active {
        display: flex;
    }
    
    .camera-container {
        display: flex;
        gap: 16px;
    }
    
    .camera-item {
        flex: 1;
    }
    
    .pin-verification {
        max-width: 500px;
    }
    
    .pin-digit {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }
    
    .pin-keypad {
        max-width: 400px;
        gap: 16px;
    }
    
    .pin-key {
        font-size: 28px;
    }
}

/* En tablets más grandes, hacemos el teclado aún más grande */
@media (min-width: 992px) {
    .pin-verification {
        max-width: 600px;
    }
    
    .pin-digit {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }
    
    .pin-keypad {
        max-width: 480px;
        gap: 20px;
    }
    
    .pin-key {
        font-size: 32px;
    }
}

/* -----------------
   ESTILOS PARA PIN BASADOS EN SOLICITUD/INDEX.PHP
   ----------------- */

.pin-container {
    max-width: 400px;
    margin: 0 auto;
    background-color: var(--background-secondary);
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: none;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1050;
    width: 90%;
}

.pin-container.active {
    display: block;
}

.pin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    display: none;
}

.pin-overlay.active {
    display: block;
}

.pin-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
}

.pin-input {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.pin-digit {
    width: 60px;
    height: 60px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-digit span {
    font-size: 24px;
    font-weight: 600;
}

.error-container {
    text-align: center;
    margin-bottom: 20px;
    height: 24px;
}

.error-message {
    color: var(--danger-color);
    font-size: 14px;
    font-weight: 500;
    display: none;
}

.error-message.visible {
    display: block;
}

.numeric-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.key {
    aspect-ratio: 1/1;
    border: none;
    border-radius: 100%;
    background-color: #f2f2f7;
    font-size: 24px;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s ease-out;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.key:active, .key.pressed {
    background-color: #dbdbdb;
    transform: scale(0.95);
}

.key-clear, .key-enter {
    background-color: #e5e5ea;
}

.key-clear svg, .key-enter svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-primary);
}

/* Botón de verificación y estado verificado */
.btn-verificar-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: var(--background-secondary);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 10px;
    padding: 12px 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin: 0 auto 20px;
}

.btn-verificar-pin:hover {
    background-color: rgba(0, 122, 255, 0.05);
}

.btn-verificar-pin svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.pin-verificado {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: rgba(52, 199, 89, 0.1);
    color: var(--success-color);
    border-radius: 10px;
    padding: 12px 16px;
    font-weight: 500;
    margin: 0 auto 20px;
}

.pin-verificado.activo {
    display: flex;
}

.pin-verificado svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

@media (min-width: 768px) {
    .pin-container {
        max-width: 480px;
        padding: 32px;
    }
    
    .pin-digit {
        width: 70px;
        height: 70px;
    }
    
    .pin-digit span {
        font-size: 28px;
    }
    
    .key {
        font-size: 28px;
    }
}

/* Estilos para modal de entrega exitosa - Previene el cierre accidental */
#confirmacion-modal.entrega-exitosa .confirmacion-header .close {
    display: none !important;
}

#confirmacion-modal.entrega-exitosa ~ #confirmacion-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

#confirmacion-modal.entrega-exitosa .confirmacion-title {
    color: var(--success-color);
    font-weight: 600;
}

#confirmacion-modal.entrega-exitosa .success-message {
    animation: success-pulse 2s 1;
}

/* Contenedor del modal de confirmación */
.confirmacion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
}

.confirmacion-header .close {
    background: none;
    border: none;
    font-size: 20px;
    opacity: 0.5;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirmacion-header .close:hover {
    opacity: 0.8;
}

#ordenes-container {
    width: 100%;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Eliminar scroll y altura máxima en la pantalla de entrega */
.entrega-container .productos-list {
    max-height: none;
    overflow-y: visible;
}

/* Estilo para animación de error en PIN */
.pin-digit.error {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    border-color: var(--danger-color);
    background-color: rgba(255, 59, 48, 0.05);
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
    40%, 60% { transform: translate3d(3px, 0, 0); }
} 