/**
 * Estilos del módulo de solicitud de surtido - Sistema Taco Loco
 * - Diseño optimizado para tablets (iPad)
 * - Estilo visual inspirado en iOS
 * - Interfaz responsiva
 */

/* --------------------
   1. VARIABLES Y RESET
   -------------------- */
:root {
    /* Colores principales */
    --primary-color: #007aff;
    --secondary-color: #5ac8fa;
    --success-color: #34c759;
    --error-color: #ff3b30;
    
    /* 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);
    --logo-color: #2c3e50;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ----------------
   2. BASE Y LAYOUT
   ---------------- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.4;
    font-weight: 400;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.container {
    max-width: 100%;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Logo */
.logo-container {
    text-align: center;
    margin-bottom: 15px;
    position: relative;
}

.logo {
    max-width: 180px;
    height: auto;
    margin: 0 auto;
    display: block;
    filter: brightness(0) saturate(100%) hue-rotate(210deg) saturate(70%) brightness(60%);
}

/* -----------------------------
   3. SISTEMA DE PANTALLAS/VIEWS
   ----------------------------- */
.screen {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    /*padding: 20px;*/
}

.screen.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateY(0);
    position: relative;
}

.screen.preparing {
    display: block;
    opacity: 0;
    transform: translateY(10px);
}

/* -----------------
   4. ENCABEZADOS
   ----------------- */
.header {
    text-align: center;
    /*margin-bottom: 30px;*/
    padding: 20px 0;
    padding-bottom: 10px !important;
    position: relative;
}

.header h1 {
    color: var(--text-primary);
    font-size: 34px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.header h2 {
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    /* Ajuste para nombres largos */
    padding: 0 40px;
    word-wrap: break-word;
}

.header p {
    color: var(--text-secondary);
    font-size: 17px;
    font-weight: 400;
}

/* Botón de volver */
.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    padding: 12px;
    position: absolute;
    left: 0;
    top: -5px;
    z-index: 10;
}

.btn-back svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
}

/* ----------------------------
   5. PANTALLA DE SELECCIÓN DE USUARIO
   ---------------------------- */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    overflow-y: auto;
    padding: 5px 0;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - 250px);
    min-height: 200px;
}

.user-card {
    background-color: var(--background-secondary);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 20px;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.1s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 140px;
    justify-content: center;
    border: 1px solid var(--border-color);
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

.user-card:active {
    transform: scale(0.98);
    background-color: rgba(0, 0, 0, 0.03);
}

.user-info h3 {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}

.user-info .area {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* ----------------------------
   6. PANTALLA DE WHATSAPP
   ---------------------------- */
.whatsapp-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: var(--background-secondary);
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    transition: all 0.3s ease;
}

.instruction-text {
    color: var(--text-primary);
    font-size: 18px;
    margin-bottom: 5px;
    text-align: center;
    font-weight: 500;
}

.form-group {
    position: relative;
    margin-bottom: 15px;
}

.form-control {
    display: block;
    width: 100%;
    height: 60px;
    padding: 12px 18px;
    font-size: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: white;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    -webkit-appearance: none;
    text-align: center;
    letter-spacing: 1px;
}

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

.error-feedback {
    color: var(--error-color);
    font-size: 15px;
    margin-top: 8px;
    display: none;
    text-align: center;
    font-weight: 500;
}

.error-feedback.visible {
    display: block;
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

.action-buttons {
    display: flex;
    gap: 16px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 25px;
    font-size: 17px;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    min-width: 160px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
}

.btn-primary:hover {
    background-color: #0062cc;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 122, 255, 0.2);
}

.btn-primary:active {
    background-color: #0056b3;
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 122, 255, 0.1);
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 122, 255, 0.2);
}

.btn-outline-primary:active {
    background-color: #0056b3;
    color: white;
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 122, 255, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.status-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    background-color: #f0f9f0;
    color: #2d862d;
    margin-top: 15px;
    display: none;
    border: 1px solid rgba(45, 134, 45, 0.2);
}

.status-message.visible {
    display: flex;
    animation: fadeIn 0.5s ease;
}

.status-icon svg {
    color: #2d862d;
    width: 24px;
    height: 24px;
}

.status-text {
    font-size: 16px;
    font-weight: 500;
}

.resend-container, .btn-link, #resend-timer {
    /* Estos estilos ya no son necesarios y podrían eliminarse */
    display: none;
}

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

/* Específico para iPad */
@media (min-width: 768px) and (max-width: 1024px) {
    .whatsapp-container {
        max-width: 650px;
        padding: 35px;
    }
    
    .instruction-text {
        font-size: 20px;
    }
    
    .form-control {
        height: 70px;
        font-size: 22px;
    }
    
    .btn {
        padding: 16px 30px;
        font-size: 18px;
        min-width: 180px;
    }
}

/* ----------------------------
   7. PANTALLA DE PIN
   ---------------------------- */
.pin-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 30px;
    max-width: 340px;
    margin: 0 auto;
    width: 100%;
    padding-top: 20px;
}

/* Dígitos del PIN */
.pin-input {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.pin-digit {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background-color: var(--background-secondary);
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

.pin-digit span {
    font-size: 34px;
}

.pin-digit.filled {
    background-color: rgba(0, 0, 0, 0.03);
}

/* Contenedor de error */
.error-container {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
}

.error-message {
    color: white;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    padding: 12px 20px;
    border-radius: 25px;
    opacity: 0;
    position: absolute;
    transition: all 0.3s ease;
    background-color: var(--error-color);
    box-shadow: 0 4px 20px rgba(255, 59, 48, 0.3);
    max-width: 320px;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.error-message.visible {
    opacity: 1;
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* Teclado numérico */
.numeric-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    width: 100%;
    margin-top: 10px;
}

.key {
    background-color: var(--background-secondary);
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-size: 28px;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.15s ease;
    -webkit-font-smoothing: antialiased;
    margin: 0 auto;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

.key:active {
    background-color: rgba(0, 0, 0, 0.1);
    transform: scale(0.95);
}

.key-action, .key-clear, .key-enter {
    background-color: rgba(142, 142, 147, 0.12);
    color: var(--text-primary);
}

.key-clear svg, .key-enter svg, .key-action svg {
    width: 30px;
    height: 30px;
    stroke-width: 2.5;
}

.key-enter {
    background-color: var(--success-color);
    color: white;
}

/* ---------------------
   8. COMPONENTES UI
   --------------------- */
/* Loading spinner */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.loading.visible {
    display: flex;
}

.loading .spinner-border {
    width: 50px;
    height: 50px;
    border-width: 4px;
    color: var(--primary-color);
}

/* -------------------
   9. ANIMACIONES
   ------------------- */
/* Animación shake para PIN incorrecto */
@keyframes shake {
    0%, 100% {
        transform: translateX(-50%);
    }
    10%, 90% {
        transform: translateX(calc(-50% - 2px));
    }
    20%, 80% {
        transform: translateX(calc(-50% + 3px));
    }
    30%, 50%, 70% {
        transform: translateX(calc(-50% - 5px));
    }
    40%, 60% {
        transform: translateX(calc(-50% + 5px));
    }
}

/* --------------------
   10. MEDIA QUERIES
   -------------------- */
/* Responsive para iPad y tabletas */
@media (min-width: 768px) {
    .container {
        /*padding: 30px; no descomentar*/
    }
    
    .screen {
        /*padding: 30px; no descomentar*/
    }
    
    .user-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .pin-digit {
        width: 65px;
        height: 65px;
    }
    
    .key {
        width: 85px;
        height: 85px;
    }
}

/* iPad específico */
@media (min-width: 768px) and (max-width: 1024px) {
    .user-grid {
        max-height: calc(100vh - 300px);
        overflow-y: auto;
    }
    
    .header h1 {
        font-size: 38px;
    }
    
    .header p {
        font-size: 19px;
    }
}

/* Orientación horizontal */
@media (min-width: 1024px) and (orientation: landscape) {
    .user-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        max-height: calc(100vh - 250px);
        overflow-y: auto;
    }
    
    .pin-container {
        max-width: 320px;
        flex-direction: column;
        gap: 15px;
        padding-top: 0;
    }
    
    .pin-input {
        margin-bottom: 5px;
    }
    
    .error-container {
        position: fixed;
        top: 20px;
        left: 20px;
        right: 20px;
        height: 30px;
        z-index: 9999;
        pointer-events: none;
    }
    
    .numeric-keypad {
        gap: 10px;
        margin-top: 0;
    }
    
    .key {
        width: 65px;
        height: 65px;
        font-size: 26px;
    }
    
    .pin-digit {
        width: 55px;
        height: 55px;
    }
    
    .pin-digit span {
        font-size: 30px;
    }
    
    .pin-screen .header {
        margin-bottom: 10px;
    }
}

/* Tablets más pequeñas en modo landscape */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
    .pin-container {
        max-width: 300px;
        padding-top: 0;
        gap: 10px;
    }
    
    .key {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .pin-digit {
        width: 50px;
        height: 50px;
    }
    
    .pin-digit span {
        font-size: 28px;
    }
    
    .key-clear svg, .key-enter svg {
        width: 24px;
        height: 24px;
    }
    
    .pin-screen .header {
        margin-bottom: 5px;
    }
    
    .header h2 {
        font-size: 24px;
        margin-bottom: 5px;
    }
    
    .header p {
        font-size: 16px;
    }
    
    .pin-input {
        margin-bottom: 5px;
    }
    
    .error-container {
        position: fixed;
        top: 20px;
        left: 20px;
        right: 20px;
        height: 25px;
        z-index: 9999;
        pointer-events: none;
    }
    
    .numeric-keypad {
        gap: 8px;
    }
}

.btn-hidden {
    display: none;
}

.countdown {
    font-weight: normal;
    color: inherit;
}

/* Permitir selección solo en campos de entrada de texto */
input, textarea {
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
}

/* Asegurar que el loader siempre esté por encima */
.loading {
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.8);
}

/* Media queries para dispositivos móviles */
@media (max-width: 767px) {
    /* Reducir tamaño del logo en móviles */
    .logo {
        max-width: 120px;
        margin-bottom: 10px;
    }
    
    /* Reducir espacio en el encabezado */
    .header {
        margin-bottom: 15px;
    }
    
    .header h1, .header h2 {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .header p {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    /* Ajustes para tarjetas en pantallas pequeñas */
    .user-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
        max-height: calc(100vh - 200px);
    }
    
    .user-card {
        height: 110px;
        padding: 15px;
    }
    
    .user-info h3 {
        font-size: 16px;
    }
    
    /* Ajustes específicos para el PIN pad */
    .pin-screen .pin-container {
        margin-top: 0;
        padding: 0 10px;
    }
    
    .pin-input {
        margin-bottom: 10px;
    }
    
    .pin-digit {
        width: 40px;
        height: 40px;
        margin: 0 5px;
    }
    
    /* Mover el mensaje de error arriba para ganar espacio */
    .error-container {
        position: fixed;
        top: 20px;
        left: 20px;
        right: 20px;
        min-height: 20px;
        z-index: 9999;
        pointer-events: none;
    }
    
    .error-message {
        padding: 10px 16px;
        font-size: 14px;
        font-weight: 500;
        display: inline-block;
        max-width: 280px;
        margin: 0 auto;
        background-color: var(--error-color);
        color: white;
        border-radius: 20px;
        box-shadow: 0 3px 15px rgba(255, 59, 48, 0.3);
        left: 50%;
        transform: translateX(-50%);
    }
    
    .numeric-keypad {
        margin-top: 5px;
        gap: 8px;
    }
    
    .key {
        width: 60px;
        height: 60px;
        font-size: 1.2rem;
    }
    
    .key-action svg, .key-clear svg, .key-enter svg {
        width: 20px;
        height: 20px;
    }
}

/* Ajustes adicionales para pantallas muy pequeñas como iPhone SE */
@media (max-width: 380px) {
    /* Ajustes para tarjetas en pantallas extra pequeñas */
    .user-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 8px;
        max-height: calc(100vh - 180px);
        padding: 0;
        margin-bottom: 10px;
    }
    
    .user-card {
        height: 90px;
        padding: 12px;
    }
    
    .user-info h3 {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .pin-screen {
        padding-bottom: 10px;
    }
    
    .key {
        width: 50px;
        height: 50px;
        font-size: 1.1rem;
        margin: 0 auto;
    }
    
    .pin-digit {
        width: 35px;
        height: 35px;
    }
    
    .numeric-keypad {
        gap: 6px;
    }
    
    /* Reducir espacio vertical */
    .pin-container {
        margin-top: 0;
    }
    
    /* Optimización para mostrar correctamente en iPhone SE y dispositivos pequeños */
    .container {
        padding-bottom: 15px;
        min-height: calc(100vh - 15px);
        display: flex;
        flex-direction: column;
    }
    
    /* Modificado para no interferir con las propiedades táctiles */
    .pin-screen {
        padding-bottom: 10px;
        position: relative;
        height: auto;
    }
    
    .pin-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
}

/* Mejoras modernas para táctil - elimina el retraso de 300ms */
a, button, .user-card, .area-card, .sucursal-card, .key, .btn, .btn-back {
    touch-action: manipulation;
}

/* Mejora la retroalimentación visual en dispositivos táctiles */
.user-card, .area-card, .sucursal-card {
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.1s ease;
}

.user-card:active, .area-card:active, .sucursal-card:active {
    transform: scale(0.98);
    background-color: rgba(0, 0, 0, 0.03);
}

/* Fix para evitar problemas con vh en iOS */
@supports (-webkit-touch-callout: none) {
    .container {
        height: -webkit-fill-available;
    }
    
    .user-grid {
        max-height: calc(100vh - 180px);
        max-height: calc(-webkit-fill-available - 180px);
    }
} 