/**
 * PWA Styles - Install Prompts, Push Notifications, and Mobile Optimizations
 */

/* ==================== INSTALL PROMPT ==================== */
#pwa-install-prompt,
#pwa-push-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    z-index: 10000;
    width: 90%;
    max-width: 420px;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide PWA prompts when onboarding wizard is open */
#ob-overlay.visible ~ #pwa-install-prompt,
#ob-overlay.visible ~ #pwa-push-prompt,
#ob-overlay.visible ~ #pwa-ios-prompt {
    display: none !important;
}

#pwa-install-prompt.pwa-prompt-visible,
#pwa-push-prompt.pwa-prompt-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.pwa-prompt-content {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(197, 160, 89, 0.3);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.pwa-prompt-icon {
    font-size: 40px;
    flex-shrink: 0;
}

.pwa-prompt-text {
    flex: 1;
    min-width: 0;
}

.pwa-prompt-text h4 {
    font-family: 'DM Sans', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 6px 0;
}

.pwa-prompt-text p {
    font-size: 13px;
    color: #94a3b8;
    margin: 0;
    line-height: 1.4;
}

.pwa-prompt-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-btn-install {
    background: linear-gradient(135deg, #c5a059, #a68543);
    color: #0f172a;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pwa-btn-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(197, 160, 89, 0.4);
}

.pwa-btn-dismiss {
    background: transparent;
    color: #64748b;
    border: none;
    padding: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s;
}

.pwa-btn-dismiss:hover {
    color: #f8fafc;
}

.pwa-btn-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 6px;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pwa-btn-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ==================== iOS INSTALL MODAL ==================== */
#pwa-ios-prompt {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#pwa-ios-prompt.pwa-ios-visible {
    opacity: 1;
    pointer-events: all;
}

.pwa-ios-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.pwa-ios-modal {
    position: relative;
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(197, 160, 89, 0.3);
    border-radius: 20px;
    padding: 28px;
    max-width: 380px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

#pwa-ios-prompt.pwa-ios-visible .pwa-ios-modal {
    transform: translateY(0);
}

.pwa-ios-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: #64748b;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-ios-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.pwa-ios-header {
    text-align: center;
    margin-bottom: 24px;
}

.pwa-ios-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.pwa-ios-header h3 {
    font-family: 'DM Sans', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 6px 0;
}

.pwa-ios-header p {
    font-size: 14px;
    color: #94a3b8;
    margin: 0;
}

.pwa-ios-steps {
    margin-bottom: 24px;
}

.pwa-ios-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin-bottom: 12px;
}

.pwa-ios-step-num {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #c5a059, #a68543);
    color: #0f172a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.pwa-ios-step-text {
    flex: 1;
}

.pwa-ios-step-text strong {
    display: block;
    color: #f8fafc;
    font-size: 14px;
    margin-bottom: 4px;
}

.pwa-ios-step-text small {
    color: #64748b;
    font-size: 12px;
}

.pwa-ios-share-icon {
    font-size: 24px;
    margin: 8px 0;
}

.pwa-ios-a2hs-text {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #c5a059;
    margin: 8px 0;
    font-weight: 600;
}

.pwa-ios-benefits {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.pwa-ios-benefit {
    font-size: 13px;
    color: #34d399;
    padding: 6px 0;
    border-bottom: 1px solid rgba(16, 185, 129, 0.1);
}

.pwa-ios-benefit:last-child {
    border-bottom: none;
}

.pwa-ios-btn-gotit {
    width: 100%;
    background: linear-gradient(135deg, #c5a059, #a68543);
    color: #0f172a;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-ios-btn-gotit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(197, 160, 89, 0.4);
}

/* ==================== UPDATE NOTIFICATION ==================== */
.pwa-update-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 10001;
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.pwa-update-toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.pwa-update-toast button {
    background: white;
    color: #2563eb;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.pwa-update-toast button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.pwa-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10002;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.pwa-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.pwa-toast-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.pwa-toast-info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.pwa-toast-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

/* ==================== PWA INSTALLED MODE ==================== */
body.pwa-installed {
    /* Adjustments when running as installed app */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* ==================== MOBILE OPTIMIZATIONS ==================== */
@media (max-width: 640px) {
    #pwa-install-prompt,
    #pwa-push-prompt {
        bottom: 10px;
        width: 95%;
    }

    .pwa-prompt-content {
        padding: 16px;
        gap: 12px;
    }

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

    .pwa-prompt-text h4 {
        font-size: 14px;
    }

    .pwa-prompt-text p {
        font-size: 12px;
    }

    .pwa-btn-install {
        padding: 8px 16px;
        font-size: 12px;
    }

    .pwa-update-toast {
        left: 16px;
        right: 16px;
        top: auto;
        bottom: 100px;
        justify-content: space-between;
    }

    .pwa-toast {
        bottom: 80px;
        left: 16px;
        right: 16px;
        transform: translateY(20px);
    }

    .pwa-toast.visible {
        transform: translateY(0);
    }
    
    /* iOS Modal Mobile */
    .pwa-ios-modal {
        padding: 20px;
        margin: 10px;
    }
    
    .pwa-ios-header h3 {
        font-size: 18px;
    }
    
    .pwa-ios-step {
        padding: 12px;
        gap: 12px;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .pwa-ios-modal {
        padding: 16px;
    }
    
    .pwa-ios-icon {
        font-size: 40px;
    }
    
    .pwa-ios-step-num {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* ==================== SMS DEEP LINK BUTTONS ==================== */
.sms-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    margin-top: 12px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.sms-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

.sms-action-btn::before {
    content: '💬';
    font-size: 16px;
}

/* ==================== VOICE INPUT BUTTON ==================== */
.voice-input-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.voice-input-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

.voice-input-btn.recording {
    animation: voice-pulse 1.5s ease infinite;
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

@keyframes voice-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
    }
}

.voice-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
}

/* ==================== OFFLINE INDICATOR ==================== */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10003;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

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

/* Safe area adjustments for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    .offline-indicator {
        padding-top: max(8px, env(safe-area-inset-top));
    }
}

/* ==================== LOADING SPINNER ==================== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(197, 160, 89, 0.2);
    border-top-color: #c5a059;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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