/*
  Reseteo básico para asegurar que el contenedor ocupe toda la pantalla
  y no tenga márgenes, padding o bordes que interfieran con la apariencia de app nativa.
*/
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden; /* Previene las barras de scroll en el contenedor principal */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/*
  El iframe debe expandirse para llenar completamente su contenedor (body).
  El borde se elimina para que la integración sea invisible.
*/
iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    transition: height 0.3s ease, filter 0.3s ease;
}

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

/* Ajuste cuando la navegación debug está visible */
#pwa-navigation:not([style*="display: none"]) ~ iframe {
    height: calc(100% - 50px);
}

/* Estilos para botones de navegación debug */
#nav-toggle {
    transition: all 0.3s ease;
}
#nav-toggle:hover {
    transform: scale(1.1);
    background: #1976d2 !important;
}

/* --- LOADING SCREEN --- */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #2A3443;
    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: 110px;
    height: 110px;
    border-radius: 20px;
    margin-bottom: 20px;
    animation: niPulse 2s infinite;
}

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

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

.loading-screen p {
    margin: 0;
    opacity: 0.65;
    font-size: 0.88em;
}

.loading-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: niSpin 1s linear infinite;
    margin-top: 22px;
}

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

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

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

.status-indicator.online  { background: #28a745; }
.status-indicator.offline { background: #dc3545; }
.status-indicator.updating { background: #2A3443; }

/* --- UPDATE BANNER --- */
.update-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #2A3443;
    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: #2A3443;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 12px;
    font-size: 13px;
}

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

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

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

.offline-page .icon {
    font-size: 3.5em;
    margin-bottom: 16px;
    opacity: 0.55;
}

.offline-page h2 {
    color: #2A3443;
    margin-bottom: 10px;
    font-size: 1.4em;
}

.offline-page p {
    color: #666;
    max-width: 340px;
    line-height: 1.6;
    margin-bottom: 24px;
    font-size: 0.95em;
}

.offline-page .retry-btn {
    background: #2A3443;
    color: white;
    border: none;
    padding: 13px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
}

.offline-page .retry-btn:hover { background: #1a2230; }

/* --- RESPONSIVE --- */
@media (max-width: 480px) {
    .update-banner { padding: 10px 12px; }
    .update-banner .message { font-size: 13px; }
    .loading-screen .logo { width: 80px; height: 80px; }
}
