/* ===================================
   PWA STYLES - Sistema de Gestão de Peças
   =================================== */

/* ===================================
   1. INSTALL BUTTON
   =================================== */

.pwa-install-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all 0.3s ease;
}

.pwa-install-btn.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.pwa-install-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.5);
}

.pwa-install-btn:active {
    transform: translateY(-1px) scale(1.02);
}

.pwa-install-btn svg {
    width: 24px;
    height: 24px;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .pwa-install-btn {
        bottom: 15px;
        right: 15px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .pwa-install-btn span {
        display: none;
    }
    
    .pwa-install-btn {
        width: 56px;
        height: 56px;
        padding: 0;
        justify-content: center;
    }
}

/* ===================================
   2. UPDATE NOTIFICATION
   =================================== */

.pwa-update-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.pwa-update-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.pwa-update-content span {
    font-weight: 500;
    color: #333;
}

.pwa-update-content button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-update-content button:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.pwa-update-content button.dismiss {
    background: #e0e0e0;
    color: #666;
}

.pwa-update-content button.dismiss:hover {
    background: #d0d0d0;
}

@media (max-width: 768px) {
    .pwa-update-notification {
        left: 10px;
        right: 10px;
        transform: translateY(-100px);
    }
    
    .pwa-update-notification.show {
        transform: translateY(0);
    }
    
    .pwa-update-content {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .pwa-update-content button {
        width: 100%;
    }
}

/* ===================================
   3. OFFLINE BANNER
   =================================== */

.pwa-offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 9998;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.pwa-offline-banner.show {
    transform: translateY(0);
}

.pwa-offline-banner svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .pwa-offline-banner {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .pwa-offline-banner span {
        font-size: 13px;
    }
}

/* ===================================
   4. TOAST MESSAGES
   =================================== */

.pwa-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: white;
    color: #333;
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.pwa-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pwa-toast.success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.pwa-toast.error {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

@media (max-width: 768px) {
    .pwa-toast {
        bottom: 80px;
        padding: 12px 25px;
        font-size: 14px;
    }
}

/* ===================================
   5. LOADING STATES
   =================================== */

.pwa-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: pwa-spin 0.8s linear infinite;
}

@keyframes pwa-spin {
    to { transform: rotate(360deg); }
}

.pwa-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
}

.pwa-loading-overlay .pwa-loading {
    width: 60px;
    height: 60px;
    border-width: 5px;
}

/* ===================================
   6. SPLASH SCREEN (iOS)
   =================================== */

@media (display-mode: standalone) {
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        z-index: 999999;
        animation: pwa-splash-fade 0.5s ease forwards;
        animation-delay: 0.5s;
        pointer-events: none;
    }
}

@keyframes pwa-splash-fade {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* ===================================
   7. MOBILE OPTIMIZATIONS
   =================================== */

@media (display-mode: standalone) {
    /* Remover seleção de texto em elementos interativos */
    button, a {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Melhorar área de toque */
    .btn, button, a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Safe area para dispositivos com notch */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ===================================
   8. PULL-TO-REFRESH INDICATOR
   =================================== */

.pwa-pull-refresh {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: top 0.3s ease;
    z-index: 9997;
}

.pwa-pull-refresh.active {
    top: 20px;
}

.pwa-pull-refresh svg {
    width: 24px;
    height: 24px;
    animation: pwa-spin 1s linear infinite;
}

/* ===================================
   9. INSTALL BANNER (Alternative)
   =================================== */

.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 20px;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.pwa-install-banner.show {
    transform: translateY(0);
}

.pwa-install-banner-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pwa-install-banner-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 30px;
    flex-shrink: 0;
}

.pwa-install-banner-text {
    flex: 1;
}

.pwa-install-banner-text h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.pwa-install-banner-text p {
    margin: 5px 0 0;
    font-size: 14px;
    color: #666;
}

.pwa-install-banner-actions {
    display: flex;
    gap: 10px;
}

.pwa-install-banner-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-install-banner-actions .primary {
    background: #667eea;
    color: white;
}

.pwa-install-banner-actions .primary:hover {
    background: #5568d3;
}

.pwa-install-banner-actions .secondary {
    background: #e0e0e0;
    color: #666;
}

.pwa-install-banner-actions .secondary:hover {
    background: #d0d0d0;
}

@media (max-width: 768px) {
    .pwa-install-banner-content {
        flex-direction: column;
        text-align: center;
    }
    
    .pwa-install-banner-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .pwa-install-banner-actions button {
        width: 100%;
    }
}

/* ===================================
   10. SYNC STATUS INDICATOR
   =================================== */

.pwa-sync-status {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transform: translateX(-100px);
    transition: all 0.3s ease;
}

.pwa-sync-status.show {
    opacity: 1;
    transform: translateX(0);
}

.pwa-sync-status .sync-icon {
    width: 16px;
    height: 16px;
    animation: pwa-spin 1s linear infinite;
}

.pwa-sync-status.syncing {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.pwa-sync-status.success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.pwa-sync-status.error {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

@media (max-width: 768px) {
    .pwa-sync-status {
        left: 15px;
        bottom: 80px;
        font-size: 13px;
        padding: 8px 15px;
    }
}

/* ===================================
   11. ANIMATIONS
   =================================== */

@keyframes pwa-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pwa-slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes pwa-slide-down {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes pwa-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Utility classes */
.pwa-animate-fade-in {
    animation: pwa-fade-in 0.3s ease;
}

.pwa-animate-slide-up {
    animation: pwa-slide-up 0.3s ease;
}

.pwa-animate-slide-down {
    animation: pwa-slide-down 0.3s ease;
}

.pwa-animate-pulse {
    animation: pwa-pulse 2s ease infinite;
}

/* ===================================
   12. PRINT STYLES (Hide PWA elements)
   =================================== */

@media print {
    .pwa-install-btn,
    .pwa-update-notification,
    .pwa-offline-banner,
    .pwa-toast,
    .pwa-install-banner,
    .pwa-sync-status {
        display: none !important;
    }
}
