/**
 * PWA-specific styles for Rentopi
 * Contains styles for PWA installation prompts, notifications, and offline indicators
 */

/* PWA Install Button */
.pwa-install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    background: rgba(218, 83, 44, 0.9);
    border: none;
    box-shadow: 0 4px 12px rgba(218, 83, 44, 0.3);
    /* Add safe area support for devices with notches/navigation */
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
}

.pwa-install-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(218, 83, 44, 0.4);
}

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

/* PWA Notifications */
.pwa-notification {
    top: 100px;
    position: fixed;
    animation: pwaSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 1040;
}

.pwa-notification.tw-translate-x-full {
    animation: pwaSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pwaSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes pwaSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* PWA Status Indicators */
.pwa-offline-indicator {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #ff6b6b, #ffa726);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

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

/* PWA Splash Screen */
.pwa-splash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #da532c 0%, #b8441f 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    color: white;
    text-align: center;
}

.pwa-splash-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 24px;
    animation: pwaPulse 2s infinite;
}

.pwa-splash-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.pwa-splash-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 32px;
}

.pwa-splash-loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: pwaSpinner 1s linear infinite;
}

@keyframes pwaPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

@keyframes pwaSpinner {
    to {
        transform: rotate(360deg);
    }
}

/* PWA Update Available Banner */
.pwa-update-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.pwa-update-banner.show {
    transform: translateY(0);
}

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

.pwa-update-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.pwa-update-message {
    font-size: 14px;
    opacity: 0.9;
}

.pwa-update-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pwa-update-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.pwa-update-btn.primary {
    background: white;
    color: #4CAF50;
    font-weight: 600;
}

.pwa-update-btn.primary:hover {
    background: rgba(255, 255, 255, 0.9);
}

/* PWA Install Prompt Card */
.pwa-install-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 24px;
    margin: 16px;
    text-align: center;
    border: 2px solid #da532c;
}

.pwa-install-card-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #da532c, #b8441f);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.pwa-install-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #da532c;
    margin-bottom: 8px;
}

.pwa-install-card-description {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.pwa-install-card-benefits {
    text-align: left;
    margin: 20px 0;
}

.pwa-install-card-benefits ul {
    list-style: none;
    padding: 0;
}

.pwa-install-card-benefits li {
    padding: 4px 0;
    display: flex;
    align-items: center;
}

.pwa-install-card-benefits li::before {
    content: "✓";
    color: #4CAF50;
    font-weight: bold;
    margin-right: 8px;
}

.pwa-install-card-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.pwa-install-card-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    min-width: 120px;
}

.pwa-install-card-btn.primary {
    background: #da532c;
    color: white;
}

.pwa-install-card-btn.primary:hover {
    background: #b8441f;
    transform: translateY(-1px);
}

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

.pwa-install-card-btn.secondary:hover {
    background: #eeeeee;
}

/* PWA Offline Status */
body.pwa-offline {
    position: relative;
}

body.pwa-offline::before {
    content: "You're offline";
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #ff6b6b, #ffa726);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    animation: pwaSlideDown 0.3s ease;
}

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

    to {
        transform: translateY(0);
    }
}

/* PWA Loading States */
.pwa-loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.pwa-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #da532c;
    border-radius: 50%;
    animation: pwaSpinner 1s linear infinite;
    z-index: 1000;
}

/* Responsive PWA Elements */
@media (max-width: 768px) {
    .pwa-install-button {
        position: fixed;
        bottom: 16px;
        right: 16px;
        font-size: 14px;
        padding: 12px 16px;
    }

    .pwa-notification {
        position: fixed;
        top: 100px;
        left: 8px;
        right: 8px;
        max-width: none;
        z-index: 1040;
    }

    .pwa-install-card {
        margin: 8px;
        padding: 20px;
    }

    .pwa-install-card-actions {
        flex-direction: column;
    }

    .pwa-update-banner {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .pwa-update-actions {
        width: 100%;
        justify-content: center;
    }
}

/* PWA Standalone Mode Adjustments */
@media (display-mode: standalone) {

    /* Hide any browser-specific UI elements when running as installed app */
    .browser-only {
        display: none !important;
    }

    /* Adjust layout for standalone mode */
    body {
        /* Add any standalone-specific styles */
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    /* Add safe area padding for devices with notches */
    .main-header {
        padding-top: env(safe-area-inset-top, 0);
    }

    .main-footer {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* PWA Accessibility */
.pwa-install-button:focus,
.pwa-update-btn:focus,
.pwa-install-card-btn:focus {
    outline: 2px solid #da532c;
    outline-offset: 2px;
}

/* PWA High Contrast Mode Support */
@media (prefers-contrast: high) {
    .pwa-notification {
        border: 2px solid;
    }

    .pwa-install-button {
        border: 2px solid currentColor;
    }
}

/* PWA Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {

    .pwa-install-button,
    .pwa-notification,
    .pwa-splash-logo,
    .pwa-splash-loader {
        animation: none;
        transition: none;
    }

    .pwa-install-button:hover {
        transform: none;
    }
}