/* ============ PWA BOTONES FLOTANTES ============ */

/* Botón flotante PWA instalación */
.pwa-install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: linear-gradient(45deg, #4CAF50, #2E7D32);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
    display: none;
    align-items: center;
    gap: 8px;
    transform: translateY(100px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 140px;
    justify-content: center;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.pwa-install-button:hover {
    background: linear-gradient(45deg, #2E7D32, #1B5E20);
    box-shadow: 0 6px 25px rgba(76, 175, 80, 0.6);
    transform: translateY(0) scale(1.05);
}

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

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

.pwa-install-button.pulse-animation {
    animation: pwa-pulse-green 2s infinite;
}

.pwa-install-button.auto-hide-animation {
    animation: pwa-fadeOut 1s ease-out forwards;
}

.pwa-install-button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.pwa-install-button span {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Botón flotante notificaciones */
.notifications-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    background: linear-gradient(45deg, #2196F3, #1976D2);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4);
    display: none;
    align-items: center;
    gap: 8px;
    transform: translateY(100px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 160px;
    justify-content: center;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.notifications-button:hover {
    background: linear-gradient(45deg, #1976D2, #1565C0);
    box-shadow: 0 6px 25px rgba(33, 150, 243, 0.6);
    transform: translateY(0) scale(1.05);
}

.notifications-button:active {
    transform: translateY(0) scale(0.95);
}

.notifications-button.show {
    transform: translateY(0);
}

.notifications-button.pulse-animation {
    animation: notification-pulse 2s infinite;
}

.notifications-button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.notifications-button span {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ============ BARRA DE ESTADO OFFLINE ============ */

.offline-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(45deg, #d32f2f, #f44336);
    color: white;
    padding: 10px 20px;
    z-index: 2000;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.offline-bar.show {
    transform: translateY(0);
}

.offline-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.offline-content svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.offline-pulse {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: offline-pulse 2s infinite;
}

/* ============ ANIMACIONES ============ */

@keyframes pwa-pulse-green {
    0% {
        box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(76, 175, 80, 0.8), 0 0 0 10px rgba(76, 175, 80, 0.1);
    }
    100% {
        box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
    }
}

@keyframes pwa-pulse {
    0% {
        box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(33, 150, 243, 0.8), 0 0 0 10px rgba(33, 150, 243, 0.1);
    }
    100% {
        box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4);
    }
}

@keyframes notification-pulse {
    0% {
        box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(33, 150, 243, 0.8), 0 0 0 10px rgba(33, 150, 243, 0.1);
    }
    100% {
        box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4);
    }
}

@keyframes pwa-fadeOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
}

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

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .pwa-install-button,
    .notifications-button {
        bottom: 15px;
        padding: 10px 16px;
        font-size: 13px;
        min-width: 120px;
    }
    
    .pwa-install-button {
        right: 15px;
    }
    
    .notifications-button {
        left: 15px;
    }
    
    .pwa-install-button svg,
    .notifications-button svg {
        width: 14px;
        height: 14px;
    }
    
    .pwa-install-button span,
    .notifications-button span {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .pwa-install-button,
    .notifications-button {
        bottom: 10px;
        padding: 8px 12px;
        font-size: 12px;
        min-width: 100px;
    }
    
    .pwa-install-button {
        right: 10px;
    }
    
    .notifications-button {
        left: 10px;
    }
    
    .offline-content {
        font-size: 13px;
        padding: 0 10px;
    }
}

/* ============ MODO OSCURO ============ */

@media (prefers-color-scheme: dark) {
    .offline-bar {
        background: linear-gradient(45deg, #b71c1c, #d32f2f);
    }
    
    .pwa-install-button {
        background: linear-gradient(45deg, #2E7D32, #1B5E20);
        box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
    }
    
    .pwa-install-button:hover {
        background: linear-gradient(45deg, #1B5E20, #0E3B0E);
        box-shadow: 0 6px 25px rgba(76, 175, 80, 0.6);
    }
    
    .notifications-button {
        background: linear-gradient(45deg, #1565C0, #0D47A1);
        box-shadow: 0 4px 20px rgba(21, 101, 192, 0.4);
    }
    
    .notifications-button:hover {
        background: linear-gradient(45deg, #0D47A1, #01579B);
        box-shadow: 0 6px 25px rgba(21, 101, 192, 0.6);
    }
}

/* ============ ACCESIBILIDAD ============ */

@media (prefers-reduced-motion: reduce) {
    .pwa-install-button,
    .notifications-button,
    .offline-bar {
        transition: none;
    }
    
    .pwa-install-button.pulse-animation,
    .notifications-button.pulse-animation {
        animation: none;
    }
    
    .offline-pulse {
        animation: none;
    }
}

/* Ocultar botones cuando están superpuestos con teclado virtual en móviles */
@media (max-height: 500px) and (orientation: landscape) {
    .pwa-install-button,
    .notifications-button {
        display: none !important;
    }
}

/* ============ SISTEMA DE ACTUALIZACIONES PWA ============ */

/* Barra de notificación de actualización disponible */
.update-notification-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(45deg, #FF9800, #F57C00);
    color: white;
    padding: 12px 20px;
    padding-top: calc(12px + env(safe-area-inset-top, 0)); /* Safe area para iOS */
    z-index: 2500;
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

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

.update-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
}

.update-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.update-icon svg {
    width: 20px;
    height: 20px;
    animation: rotate-update 2s linear infinite;
}

.update-text {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
}

.update-text span {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.update-text small {
    font-size: 12px;
    opacity: 0.9;
}

.update-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.update-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 36px; /* Área táctil mínima para móviles */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.update-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

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

.dismiss-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;
    opacity: 0.8;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dismiss-button:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

/* Notificación de actualización completada */
.update-complete-notification {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0)); /* Safe area para iOS */
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(45deg, #4CAF50, #2E7D32);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    z-index: 2000;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 200px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.update-complete-notification.show {
    transform: translateX(-50%) translateY(0);
}

.notification-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
}

.notification-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

.notification-icon.success {
    background: rgba(255, 255, 255, 0.2);
}

.notification-icon svg {
    width: 12px;
    height: 12px;
}

/* Animaciones para actualizaciones */
@keyframes rotate-update {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Responsive para barras de actualización */
@media (max-width: 768px) {
    .update-notification-bar {
        padding: 10px 15px;
        padding-top: calc(10px + env(safe-area-inset-top, 0));
    }
    
    .update-content {
        gap: 10px;
    }
    
    .update-text span {
        font-size: 13px;
    }
    
    .update-text small {
        font-size: 11px;
    }
    
    .update-button {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .update-complete-notification {
        bottom: 15px;
        padding: 10px 16px;
        min-width: 180px;
    }
    
    .notification-content {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .update-notification-bar {
        padding: 10px 12px;
        padding-top: calc(10px + env(safe-area-inset-top, 0));
    }
    
    .update-content {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
    }
    
    .update-icon {
        display: none; /* Ocultar icono en móviles pequeños para ahorrar espacio */
    }
    
    .update-text {
        flex: 1;
        min-width: 0;
    }
    
    .update-actions {
        flex-shrink: 0;
        gap: 5px;
    }
    
    .update-text span {
        font-size: 13px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .update-text small {
        display: none; /* Ocultar texto secundario en móviles muy pequeños */
    }
    
    .update-button {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 32px;
    }
}

/* Modo oscuro para sistema de actualizaciones */
@media (prefers-color-scheme: dark) {
    .update-notification-bar {
        background: linear-gradient(45deg, #E65100, #BF360C);
    }
    
    .update-complete-notification {
        background: linear-gradient(45deg, #2E7D32, #1B5E20);
    }
}