/**
 * Estilos para el frontend de Colfarma PWA
 * Contiene estilos para el banner de instalación, indicador offline y otros elementos de la PWA
 */

/* -------------------------------------
   Banner de instalación
   ------------------------------------- */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 15px 20px;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #e0e0e0;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.pwa-install-banner.visible {
    display: flex;
    transform: translateY(0);
}

.pwa-install-content {
    display: flex;
    align-items: center;
    flex-grow: 1;
    max-width: 100%;
}

.pwa-install-icon {
    width: 40px;
    height: 40px;
    margin-right: 15px;
    flex-shrink: 0;
    border-radius: 8px;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pwa-install-icon img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.pwa-install-text h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #333333;
    font-weight: 600;
}

.pwa-install-text p {
    margin: 0;
    font-size: 14px;
    color: #666666;
    line-height: 1.4;
}

.pwa-install-buttons {
    display: flex;
    margin-left: 15px;
    flex-shrink: 0;
}

.pwa-install-button {
    background: #4a9e54;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    margin-left: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.pwa-install-button:hover {
    background: #3d8246;
    transform: translateY(-1px);
}

.pwa-install-button:active {
    transform: translateY(0);
}

.pwa-install-button.secondary {
    background: #f0f0f0;
    color: #333333;
}

.pwa-install-button.secondary:hover {
    background: #e0e0e0;
}

.pwa-install-close {
    background: none;
    border: none;
    color: #999999;
    font-size: 20px;
    cursor: pointer;
    margin-left: 15px;
    padding: 0 5px;
    line-height: 1;
    transition: color 0.2s;
}

.pwa-install-close:hover {
    color: #333333;
}

/* -------------------------------------
   Indicador de sin conexión
   ------------------------------------- */
.pwa-offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f8d7da;
    color: #721c24;
    padding: 10px 20px;
    text-align: center;
    z-index: 9998;
    display: none;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.pwa-offline-indicator.visible {
    display: block;
    animation: slideDown 0.3s ease-out;
}

/* -------------------------------------
   Toast de actualización
   ------------------------------------- */
.pwa-update-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 15px 20px;
    z-index: 9997;
    display: none;
    max-width: 320px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid #4a9e54;
}

.pwa-update-toast.visible {
    display: block;
}

.pwa-update-toast h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #333333;
}

.pwa-update-toast p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666666;
    line-height: 1.4;
}

.pwa-update-toast .buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Estilos para el botón flotante */
.pwa-floating-button {
    position: fixed;
    top: 65%;
    right: 10px;
    width: 5%; /* Ajusta según el tamaño deseado */
    height: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 10000;
    padding: 0;
    margin: 0;
    border-radius: 3%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transition: transform 0.3s ease;
}

.pwa-floating-button:hover {
    transform: scale(1.1);
}

.pwa-floating-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 158, 84, 0.5);
}

/* Estilos para la imagen dentro del botón */
.pwa-floating-button img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 0;
}

/* -------------------------------------
   Estilos para el modo offline
   ------------------------------------- */
body.offline .pwa-offline-content {
    padding: 20px;
    text-align: center;
    max-width: 600px;
    margin: 40px auto;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body.offline .pwa-offline-icon {
    font-size: 48px;
    color: #6c757d;
    margin-bottom: 20px;
}

body.offline h1 {
    color: #343a40;
    margin-bottom: 15px;
}

body.offline p {
    color: #6c757d;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* -------------------------------------
   Animaciones
   ------------------------------------- */
@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* -------------------------------------
   Estilos responsivos
   ------------------------------------- */
@media (max-width: 768px) {
    .pwa-install-banner {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }
    
    .pwa-install-content {
        flex-direction: column;
        margin-bottom: 15px;
    }
    
    .pwa-install-icon {
        margin: 0 auto 10px;
    }
    
    .pwa-install-text {
        text-align: center;
    }
    
    .pwa-install-buttons {
        margin: 10px 0 0 0;
        width: 100%;
        justify-content: center;
    }
    
    .pwa-install-button {
        flex-grow: 1;
        margin: 0 5px;
        padding: 10px;
    }
    
    .pwa-update-toast {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

/* -------------------------------------
   Estilos para el modo standalone
   ------------------------------------- */
@media all and (display-mode: standalone) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Ajustar el padding superior para dispositivos con notch */
    @supports (padding-top: env(safe-area-inset-top)) {
        body {
            padding-top: env(safe-area-inset-top);
        }
    }
    
    /* Ocultar elementos innecesarios en modo standalone */
    .pwa-install-banner,
    .pwa-floating-button {
        display: none !important;
    }
}

/* -------------------------------------
   Mejoras de accesibilidad
   ------------------------------------- */
.pwa-install-button:focus,
.pwa-install-close:focus,
.pwa-floating-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 158, 84, 0.5);
}

/* -------------------------------------
   Estilos para la página de error sin conexión
   ------------------------------------- */
.pwa-offline-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.pwa-offline-page__icon {
    font-size: 64px;
    color: #6c757d;
    margin-bottom: 20px;
}

.pwa-offline-page__title {
    font-size: 24px;
    color: #343a40;
    margin-bottom: 15px;
}

.pwa-offline-page__message {
    color: #6c757d;
    margin-bottom: 30px;
    line-height: 1.6;
}

.pwa-offline-page__button {
    display: inline-block;
    background: #4a9e54;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}

.pwa-offline-page__button:hover {
    background: #3d8246;
    color: #ffffff;
}
