/* 
 * ESTILOS PARA PWA REPARTIDOR - MENÚ PURÉPERO
 * Versión: 2.0
 * Optimizado para accesibilidad y experiencia de usuario
 */

/* --- RESET Y BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    overflow: hidden;
}

/* --- IFRAME PRINCIPAL --- */
iframe {
    width: 100%;
    height: 100vh;
    border: none;
    display: block;
    transition: filter 0.3s ease;
}

/* Efecto cuando está offline */
body.offline iframe {
    filter: grayscale(50%) opacity(0.8);
}

/* --- INDICADORES DE ESTADO --- */
.status-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
    font-size: 12px;
    z-index: 9999;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateX(-50%) translateY(-100%);
}

.status-indicator.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.status-indicator.online {
    background: #28a745;
}

.status-indicator.offline {
    background: #dc3545;
}

.status-indicator.updating {
    background: #007bff;
}

/* --- LOADING SCREEN --- */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #333;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-screen .logo {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.loading-screen h2 {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    font-weight: 300;
}

.loading-screen p {
    margin: 0;
    opacity: 0.7;
    font-size: 0.9em;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-top: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- BOTÓN DE ACTUALIZACIÓN --- */
.update-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #007bff;
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 9998;
}

.update-banner.show {
    transform: translateY(0);
}

.update-banner .message {
    flex: 1;
    font-size: 14px;
}

.update-banner .btn-update {
    background: white;
    color: #007bff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    margin-left: 12px;
}

.update-banner .btn-dismiss {
    background: none;
    color: white;
    border: none;
    padding: 8px;
    cursor: pointer;
    margin-left: 8px;
    opacity: 0.7;
}

/* --- OFFLINE PAGE STYLES --- */
.offline-page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f8f9fa;
    z-index: 10000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.offline-page.show {
    display: flex;
}

.offline-page .icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.5;
}

.offline-page h2 {
    color: #333;
    margin-bottom: 10px;
}

.offline-page p {
    color: #666;
    max-width: 400px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.offline-page .retry-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
}

/* --- MEDIA QUERIES RESPONSIVAS --- */
@media (max-width: 768px) {
    .update-banner {
        padding: 10px 12px;
    }
    
    .update-banner .message {
        font-size: 13px;
    }
    
    .update-banner .btn-update {
        padding: 6px 12px;
        font-size: 13px;
    }
}

@media (max-height: 600px) {
    .loading-screen .logo {
        width: 80px;
        height: 80px;
    }
    
    .loading-screen h2 {
        font-size: 1.2em;
    }
}

/* --- ANIMACIONES MEJORADAS --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- FOCUS STYLES PARA ACCESIBILIDAD --- */
button:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* --- PRINT STYLES --- */
@media print {
    .status-indicator,
    .update-banner,
    .loading-screen {
        display: none !important;
    }
}

/* --- DARK MODE SUPPORT --- */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
    }
    
    .loading-screen {
        background: #000;
    }
    
    .offline-page {
        background: #1a1a1a;
        color: white;
    }
    
    .offline-page h2 {
        color: white;
    }
    
    .offline-page p {
        color: #ccc;
    }
}
