/* PWA Specific Styles */

/* Install Banner */
.pwa-install-banner {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    padding: 12px 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease-out;
}

.pwa-install-button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
}

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

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

/* PWA Installed State */
body.pwa-installed {
    padding-top: 0;
}

body.pwa-installed .navbar {
    border-radius: 0;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .mobile-device .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .mobile-device .card {
        border-radius: 12px;
        margin-bottom: 15px;
    }
    
    .mobile-device .btn {
        min-height: 44px; /* iOS touch target size */
        border-radius: 8px;
    }
    
    .mobile-device .form-control {
        min-height: 44px;
        border-radius: 8px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .mobile-device .table-responsive {
        border-radius: 12px;
        overflow: hidden;
    }
}

/* Standalone Mode (PWA) */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .navbar {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
    
    /* Hide browser-specific elements */
    .browser-only {
        display: none !important;
    }
    
    /* PWA-specific navigation */
    .pwa-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e9ecef;
        padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
        z-index: 1000;
    }
    
    .pwa-nav .nav-item {
        flex: 1;
        text-align: center;
    }
    
    .pwa-nav .nav-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px 4px;
        color: #6c757d;
        text-decoration: none;
        font-size: 12px;
        transition: color 0.2s ease;
    }
    
    .pwa-nav .nav-link.active,
    .pwa-nav .nav-link:hover {
        color: #8b5cf6;
    }
    
    .pwa-nav .nav-link i {
        font-size: 20px;
        margin-bottom: 4px;
    }
    
    /* Adjust content for bottom navigation */
    .main-content {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

/* Pull to Refresh Indicator */
.pull-to-refresh {
    position: fixed;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: #8b5cf6;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    transition: top 0.3s ease;
    z-index: 9999;
}

.pull-to-refresh.active {
    top: 20px;
}

/* Loading States */
.pwa-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #dc3545;
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    z-index: 9998;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

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

/* Enhanced Touch Interactions */
.touch-feedback {
    position: relative;
    overflow: hidden;
}

.touch-feedback::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.touch-feedback:active::after {
    width: 200px;
    height: 200px;
}

/* Card Enhancements for Mobile */
@media (max-width: 768px) {
    .card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    }
    
    .list-group-item {
        border-left: none;
        border-right: none;
        padding: 15px 20px;
    }
    
    .list-group-item:first-child {
        border-top: none;
    }
    
    .list-group-item:last-child {
        border-bottom: none;
    }
}

/* Status Bar Styling */
@supports (padding-top: env(safe-area-inset-top)) {
    .status-bar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: env(safe-area-inset-top);
        background: #8b5cf6;
        z-index: 9999;
    }
}

/* Haptic Feedback Simulation */
.haptic-light:active {
    animation: hapticLight 0.1s ease;
}

.haptic-medium:active {
    animation: hapticMedium 0.15s ease;
}

.haptic-heavy:active {
    animation: hapticHeavy 0.2s ease;
}

@keyframes hapticLight {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.98); }
}

@keyframes hapticMedium {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(0.97); }
    75% { transform: scale(1.01); }
}

@keyframes hapticHeavy {
    0%, 100% { transform: scale(1); }
    20% { transform: scale(0.95); }
    40% { transform: scale(1.02); }
    60% { transform: scale(0.98); }
    80% { transform: scale(1.01); }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .pwa-nav {
        background: #1a1a1a;
        border-top-color: #333;
    }
    
    .pwa-nav .nav-link {
        color: #aaa;
    }
    
    .pwa-nav .nav-link.active,
    .pwa-nav .nav-link:hover {
        color: #8b5cf6;
    }
}

/* PWA Install Popup - Canto Inferior Esquerdo */
.pwa-install-popup {
    position: fixed !important;
    bottom: 20px !important;
    left: 20px !important;
    right: auto !important;
    top: auto !important;
    transform: translateY(100px) scale(0.8) !important;
    width: 280px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.3);
    z-index: 99999;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pwa-install-popup.show {
    transform: translateY(0) scale(1) !important;
    opacity: 1;
}

.pwa-install-popup.hidden {
    transform: translateY(100px) scale(0.8) !important;
    opacity: 0;
    pointer-events: none;
}

.pwa-popup-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pwa-popup-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
}

.pwa-popup-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.pwa-popup-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.pwa-popup-content {
    padding: 16px 20px;
}

.pwa-popup-description {
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 16px;
    opacity: 0.9;
}

.pwa-popup-buttons {
    display: flex;
    gap: 8px;
}

.pwa-popup-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.pwa-popup-btn-primary {
    background: rgba(255, 255, 255, 0.9);
    color: #7c3aed;
}

.pwa-popup-btn-primary:hover {
    background: white;
    transform: translateY(-1px);
}

.pwa-popup-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pwa-popup-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Floating Install Button - Canto Inferior Esquerdo */
.pwa-floating-btn {
    position: fixed;
    bottom: 20px;
    left: 320px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    cursor: pointer;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(0);
    opacity: 0;
}

.pwa-floating-btn.show {
    transform: scale(1);
    opacity: 1;
}

.pwa-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(139, 92, 246, 0.5);
}

.pwa-floating-btn:active {
    transform: scale(0.95);
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .pwa-install-popup {
        width: calc(100vw - 40px) !important;
        max-width: 320px !important;
        bottom: 20px !important;
        left: 20px !important;
        right: auto !important;
        top: auto !important;
        transform: translateY(100px) scale(0.8) !important;
    }
    
    .pwa-install-popup.show {
        transform: translateY(0) scale(1) !important;
    }
    
    .pwa-install-popup.hidden {
        transform: translateY(100px) scale(0.8) !important;
    }
    
    .pwa-floating-btn {
        bottom: 20px;
        left: calc(100vw - 100px);
    }
}

/* Animação de Pulse para chamar atenção */
@keyframes pulsePWA {
    0% {
        box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(139, 92, 246, 0.6), 0 0 0 10px rgba(139, 92, 246, 0.1);
    }
    100% {
        box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    }
}

.pwa-floating-btn.pulse {
    animation: pulsePWA 2s infinite;
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .pwa-floating-btn.pulse {
        animation: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }
    
    .card {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
    
    .pwa-install-popup {
        border-width: 2px;
        border-color: white;
    }
    
    .pwa-floating-btn {
        border: 2px solid white;
    }
}