/* ==========================================
   PWA (PROGRESSIVE WEB APP) STYLES
   Mahakarya Integrasi Teknologi
   ========================================== */

/* ==========================================
   PWA INSTALL BUTTON
   ========================================== */

.pwa-install-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: linear-gradient(135deg, var(--primary-color, #e31e24), #c41a1f);
    color: white;
    padding: 14px 24px;
    border: none;
    border-radius: 50px;
    box-shadow: 0 6px 25px rgba(227, 30, 36, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1rem;
    z-index: 999;
    transform: translateY(120px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: pointer;
    border: 2px solid transparent;
}

.pwa-install-btn.show {
    transform: translateY(0);
    opacity: 1;
}

.pwa-install-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 30px rgba(227, 30, 36, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}

.pwa-install-btn:active {
    transform: translateY(-1px) scale(1);
}

.pwa-install-btn i {
    font-size: 1.3rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

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

.pwa-update-notification {
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 20px 25px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 350px;
    max-width: 500px;
    transition: top 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-left: 4px solid var(--primary-color, #e31e24);
}

.pwa-update-notification.show {
    top: 20px;
}

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

.pwa-update-content > i {
    font-size: 1.8rem;
    color: var(--primary-color, #e31e24);
    animation: rotate 2s linear infinite;
}

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

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

.pwa-update-text strong {
    display: block;
    color: var(--secondary-color, #1a1a1a);
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.pwa-update-text p {
    color: var(--text-light, #666);
    font-size: 0.9rem;
    margin: 0;
}

.pwa-update-notification .update-btn {
    padding: 8px 16px;
    white-space: nowrap;
}

.pwa-update-notification .btn-close {
    background: none;
    border: none;
    color: var(--text-light, #666);
    cursor: pointer;
    padding: 5px;
    font-size: 1.2rem;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-update-notification .btn-close:hover {
    color: var(--primary-color, #e31e24);
}

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

.pwa-toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: bottom 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    min-width: 250px;
}

.pwa-toast.show {
    bottom: 30px;
}

.pwa-toast i {
    font-size: 1.5rem;
}

.pwa-toast.success {
    background: linear-gradient(135deg, #51cf66, #37b24d);
    color: white;
}

.pwa-toast.info {
    background: linear-gradient(135deg, #4dabf7, #339af0);
    color: white;
}

.pwa-toast.error {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: white;
}

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

.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: white;
    text-align: center;
    padding: 12px 20px;
    z-index: 10001;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.offline-indicator i {
    animation: pulse 2s ease-in-out infinite;
}

/* ==========================================
   STANDALONE MODE STYLES
   ========================================== */

/* Adjust layout when running as standalone PWA */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .header {
        position: sticky;
        top: env(safe-area-inset-top);
    }

    /* Hide install button in standalone mode */
    .pwa-install-btn {
        display: none !important;
    }
}

/* iOS Safari standalone mode */
@media (display-mode: standalone), (display-mode: fullscreen) {
    /* Add status bar spacing for iOS */
    .header {
        padding-top: max(env(safe-area-inset-top), 10px);
    }
}

/* ==========================================
   SPLASH SCREEN (iOS)
   ========================================== */

/* Apple splash screen meta tags will be in HTML */
.ios-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color, #e31e24);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: fadeOut 0.5s ease 1s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* ==========================================
   LOADING SKELETON (PWA)
   ========================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

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

@media (max-width: 768px) {
    .pwa-install-btn {
        bottom: 80px;
        right: 15px;
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .pwa-install-btn span {
        display: none;
    }

    .pwa-install-btn i {
        margin: 0;
        font-size: 1.4rem;
    }

    .pwa-update-notification {
        min-width: auto;
        left: 10px;
        right: 10px;
        transform: none;
    }

    .pwa-update-notification.show {
        top: 10px;
    }

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

    .pwa-update-notification .update-btn {
        width: 100%;
        margin-top: 10px;
    }

    .pwa-toast {
        min-width: auto;
        left: 20px;
        right: 20px;
        transform: none;
    }
}

/* ==========================================
   DARK MODE (PWA)
   ========================================== */

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

    .pwa-update-text strong {
        color: white;
    }

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

    .pwa-update-notification .btn-close {
        color: #ccc;
    }

    .pwa-update-notification .btn-close:hover {
        color: white;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

.pwa-install-btn:focus,
.update-btn:focus,
.btn-close:focus {
    outline: 2px solid var(--primary-color, #e31e24);
    outline-offset: 2px;
}

/* Skip focus on decorative elements */
.pwa-install-btn i,
.pwa-toast i {
    pointer-events: none;
}

/* ==========================================
   REDUCED MOTION
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    .pwa-install-btn i,
    .pwa-update-content > i,
    .offline-indicator i {
        animation: none;
    }

    .pwa-install-btn,
    .pwa-update-notification,
    .pwa-toast,
    .offline-indicator {
        transition: none;
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .pwa-install-btn,
    .pwa-update-notification,
    .pwa-toast,
    .offline-indicator {
        display: none !important;
    }
}

/* ==========================================
   HIGH CONTRAST MODE
   ========================================== */

@media (prefers-contrast: high) {
    .pwa-install-btn {
        border: 3px solid white;
    }

    .pwa-update-notification {
        border: 2px solid black;
    }
}
