/**
 * PWA Styles for MobiFirms
 * Install prompt, update notification, and offline indicators
 */

/* ============================================
   PWA INSTALL PROMPT
   ============================================ */

.pwa-install-prompt {
    position: fixed;
    bottom: 30px;
    left: 30px;
    transform: translateY(100px);
    width: 320px;
    max-width: calc(100% - 60px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 25px;
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease-out;
    text-align: center;
}

.pwa-install-prompt.show {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@keyframes slideInUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pwa-install-prompt .icon {
    font-size: 50px;
    margin-bottom: 15px;
    display: block;
}

.pwa-install-prompt .content {
    margin-bottom: 20px;
}

.pwa-install-prompt .content h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 700;
}

.pwa-install-prompt .content p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.5;
}

.pwa-install-prompt .actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pwa-install-prompt button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 15px;
    width: 100%;
}

.pwa-install-prompt .btn-install {
    background: white;
    color: #667eea;
}

.pwa-install-prompt .btn-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.4);
}

.pwa-install-prompt .btn-dismiss {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.pwa-install-prompt .btn-dismiss:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .pwa-install-prompt {
        bottom: 20px;
        width: 300px;
        padding: 25px 20px;
    }

    .pwa-install-prompt .icon {
        font-size: 45px;
    }

    .pwa-install-prompt .content h3 {
        font-size: 18px;
    }
}

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

.pwa-update-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
    z-index: 9999;
    display: none;
    animation: slideInRight 0.5s ease-out;
}

.pwa-update-notification.show {
    display: flex;
    align-items: center;
    gap: 15px;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.pwa-update-notification .icon {
    font-size: 24px;
}

.pwa-update-notification .content {
    flex: 1;
}

.pwa-update-notification .content p {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 600;
}

.pwa-update-notification .content small {
    font-size: 12px;
    opacity: 0.9;
}

.pwa-update-notification button {
    background: white;
    color: #28a745;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s ease;
    font-size: 13px;
}

.pwa-update-notification button:hover {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .pwa-update-notification {
        top: 10px;
        right: 10px;
        left: 10px;
    }
}

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

.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #dc3545;
    color: white;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    z-index: 99999;
    display: none;
    animation: slideInDown 0.3s ease-out;
}

.offline-indicator.show {
    display: block;
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

.offline-indicator.online {
    background: #28a745;
}

/* ============================================
   INSTALL BUTTON (Optional standalone button)
   ============================================ */

.pwa-install-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.pwa-install-button.show {
    display: inline-flex;
}

.pwa-install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.pwa-install-button .icon {
    font-size: 20px;
}

/* ============================================
   iOS INSTALL INSTRUCTIONS
   ============================================ */

.ios-install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 20px;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none;
    animation: slideInUp 0.5s ease-out;
}

.ios-install-prompt.show {
    display: block;
}

.ios-install-prompt .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.ios-install-prompt h3 {
    margin: 0 0 15px 0;
    color: #667eea;
    font-size: 18px;
}

.ios-install-prompt ol {
    margin: 0;
    padding-left: 20px;
    color: #666;
}

.ios-install-prompt li {
    margin-bottom: 10px;
    font-size: 14px;
}

.ios-install-prompt .icon {
    font-size: 24px;
    vertical-align: middle;
}

/* ============================================
   LOADING SPINNER (for PWA operations)
   ============================================ */

.pwa-spinner {
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================
   STANDALONE MODE DETECTION
   ============================================ */

@media all and (display-mode: standalone) {

    /* Hide browser-specific UI when in standalone mode */
    .browser-only {
        display: none !important;
    }

    /* Add padding for iOS notch in standalone mode */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    .pwa-update-notification {
        background: #1e7e34;
    }

    .ios-install-prompt {
        background: #1a1a1a;
        color: white;
    }

    .ios-install-prompt h3 {
        color: #8fa3f0;
    }

    .ios-install-prompt ol {
        color: #ccc;
    }
}