/**
 * PWA Styles - Arbitrivm
 * Progressive Web App UI Components
 */

/* ==============================================
   PWA NOTIFICAÇÕES E PROMPTS
   ============================================== */

.pwa-notification {
    position: fixed;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 20px;
    max-width: 450px;
    width: 90%;
    z-index: 10000;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-notification.pwa-show {
    bottom: 20px;
}

.pwa-notification-content {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.pwa-notification-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1E3A5F 0%, #2A4A70 100%);
    border-radius: 12px;
    color: #fff;
}

.pwa-notification-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.pwa-notification-text {
    flex: 1;
}

.pwa-notification-text strong {
    display: block;
    font-size: 1.1rem;
    color: #1E3A5F;
    margin-bottom: 5px;
}

.pwa-notification-text p {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

.pwa-notification-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-pwa-primary,
.btn-pwa-secondary {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-pwa-primary {
    background: linear-gradient(135deg, #C9A961 0%, #D4B576 100%);
    color: #1E3A5F;
}

.btn-pwa-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 169, 97, 0.3);
}

.btn-pwa-secondary {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
}

.btn-pwa-secondary:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

/* ==============================================
   PWA UPDATE NOTIFICATION
   ============================================== */

.pwa-notification.pwa-update {
    background: linear-gradient(135deg, #1E3A5F 0%, #2A4A70 100%);
}

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

.pwa-notification.pwa-update .pwa-notification-text strong {
    color: #fff;
}

.pwa-notification.pwa-update .pwa-notification-text p {
    color: rgba(255, 255, 255, 0.9);
}

.pwa-notification.pwa-update .btn-pwa-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.pwa-notification.pwa-update .btn-pwa-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==============================================
   PWA TOAST NOTIFICATIONS
   ============================================== */

.pwa-toast {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #333;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    font-size: 0.95rem;
    font-weight: 500;
    min-width: 300px;
    text-align: center;
    transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pwa-toast.pwa-show {
    top: 20px;
}

.pwa-toast.pwa-toast-success {
    background: linear-gradient(135deg, #6B8E7F 0%, #7FA293 100%);
    color: #fff;
}

.pwa-toast.pwa-toast-warning {
    background: linear-gradient(135deg, #ff9800 0%, #ffa726 100%);
    color: #fff;
}

.pwa-toast.pwa-toast-error {
    background: linear-gradient(135deg, #f44336 0%, #e57373 100%);
    color: #fff;
}

/* ==============================================
   PWA STANDALONE MODE
   ============================================== */

body.pwa-standalone {
    /* Adicionar padding-top para acomodar status bar em iOS */
    padding-top: env(safe-area-inset-top);
}

body.pwa-standalone .navbar-custom {
    top: env(safe-area-inset-top);
}

/* ==============================================
   PWA INSTALL BUTTON (OPCIONAL)
   ============================================== */

.btn-install-pwa {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #C9A961 0%, #D4B576 100%);
    color: #1E3A5F;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-install-pwa:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 169, 97, 0.3);
}

.btn-install-pwa svg {
    width: 20px;
    height: 20px;
}

/* Esconder botão quando já instalado */
body.pwa-standalone .btn-install-pwa {
    display: none;
}

/* ==============================================
   BOTÃO FLUTUANTE DISCRETO DE INSTALAÇÃO
   ============================================== */

.pwa-install-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #1E3A5F 0%, #2A4A70 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
    opacity: 0.6;
    transition: all 0.3s ease;
    animation: pwa-fab-pulse 3s ease-in-out infinite;
}

.pwa-install-fab:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(30, 58, 95, 0.4);
    animation: none;
}

.pwa-install-fab:active {
    transform: scale(0.95);
}

.pwa-install-fab svg {
    width: 24px;
    height: 24px;
    color: #fff;
    fill: currentColor;
}

/* Tooltip no hover */
.pwa-install-fab::before {
    content: 'Instalar App';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #1E3A5F;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    margin-right: 10px;
    transition: all 0.2s ease;
    pointer-events: none;
}

.pwa-install-fab::after {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1E3A5F;
    margin-right: -2px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.pwa-install-fab:hover::before,
.pwa-install-fab:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Animação sutil de pulsação */
@keyframes pwa-fab-pulse {
    0%, 100% {
        opacity: 0.6;
        box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
    }
    50% {
        opacity: 0.75;
        box-shadow: 0 4px 12px rgba(30, 58, 95, 0.35);
    }
}

/* Esconder botão quando já instalado */
body.pwa-standalone .pwa-install-fab {
    display: none !important;
}

/* Ajuste para não sobrepor outros elementos flutuantes */
.pwa-install-fab.pwa-fab-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* Instruções de instalação */
.pwa-install-instructions-content {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.pwa-install-instructions-content ol {
    margin: 0;
    padding-left: 20px;
}

.pwa-install-instructions-content li {
    margin-bottom: 10px;
}

.pwa-install-instructions-content li:last-child {
    margin-bottom: 0;
}

.pwa-install-instructions-content p {
    margin: 0 0 10px 0;
}

.pwa-install-instructions-content p:last-child {
    margin-bottom: 0;
}

/* Responsivo - Mobile */
@media (max-width: 768px) {
    .pwa-install-fab {
        bottom: 80px; /* Evitar área de navegação mobile */
        right: 16px;
        width: 44px;
        height: 44px;
    }

    .pwa-install-fab svg {
        width: 22px;
        height: 22px;
    }

    /* Tooltip acima em mobile */
    .pwa-install-fab::before {
        right: auto;
        left: 50%;
        bottom: 100%;
        top: auto;
        transform: translateX(-50%);
        margin-right: 0;
        margin-bottom: 10px;
    }

    .pwa-install-fab::after {
        right: auto;
        left: 50%;
        bottom: 100%;
        top: auto;
        transform: translateX(-50%);
        margin-right: 0;
        margin-bottom: -10px;
        border-left-color: transparent;
        border-top-color: #1E3A5F;
    }
}

/* ==============================================
   SPLASH SCREEN EFFECT
   ============================================== */

.pwa-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1E3A5F 0%, #2A4A70 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.pwa-splash.pwa-splash-hidden {
    opacity: 0;
    pointer-events: none;
}

.pwa-splash-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    animation: pwa-pulse 2s ease-in-out infinite;
}

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

.pwa-splash-text {
    color: #fff;
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.pwa-splash-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
}

.pwa-splash-loader {
    margin-top: 30px;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #C9A961;
    border-radius: 50%;
    animation: pwa-spin 1s linear infinite;
}

@keyframes pwa-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==============================================
   OFFLINE INDICATOR
   ============================================== */

.pwa-offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff9800;
    color: #fff;
    text-align: center;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

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

.pwa-offline-indicator svg {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 8px;
}

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

@media (max-width: 600px) {
    .pwa-notification {
        max-width: 95%;
        padding: 15px;
    }

    .pwa-notification-content {
        gap: 12px;
    }

    .pwa-notification-icon {
        width: 40px;
        height: 40px;
    }

    .pwa-notification-text strong {
        font-size: 1rem;
    }

    .pwa-notification-text p {
        font-size: 0.85rem;
    }

    .pwa-notification-actions {
        flex-direction: column;
    }

    .btn-pwa-primary,
    .btn-pwa-secondary {
        width: 100%;
    }

    .pwa-toast {
        min-width: 280px;
        font-size: 0.9rem;
    }

    .pwa-splash-text {
        font-size: 1.5rem;
    }

    .pwa-splash-subtitle {
        font-size: 0.9rem;
    }
}

/* ==============================================
   SAFE AREA (IOS NOTCH)
   ============================================== */

@supports (padding: max(0px)) {
    body.pwa-standalone {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* ==============================================
   DARK MODE (FUTURO)
   ============================================== */

@media (prefers-color-scheme: dark) {
    .pwa-notification {
        background: #2A2A2A;
    }

    .pwa-notification-text strong {
        color: #fff;
    }

    .pwa-notification-text p {
        color: #ccc;
    }

    .btn-pwa-secondary {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        border-color: rgba(255, 255, 255, 0.2);
    }

    .btn-pwa-secondary:hover {
        background: rgba(255, 255, 255, 0.15);
    }

    .pwa-toast {
        background: #2A2A2A;
        color: #fff;
    }
}

/* ==============================================
   ANIMAÇÕES ADICIONAIS
   ============================================== */

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

@keyframes pwa-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.pwa-animate-slide-up {
    animation: pwa-slide-up 0.3s ease;
}

.pwa-animate-fade-in {
    animation: pwa-fade-in 0.3s ease;
}
