/* PWA Splash Screen & Icon Enhancements */

/* iOS Status Bar Enhancements */
@supports (-webkit-touch-callout: none) {
    :root {
        --safe-area-top: env(safe-area-inset-top);
        --safe-area-bottom: env(safe-area-inset-bottom);
    }
    
    body {
        padding-top: var(--safe-area-top);
        padding-bottom: var(--safe-area-bottom);
    }
}

/* Android Adaptive Icon Shadow */
@media (display-mode: standalone) {
    .app-icon {
        filter: drop-shadow(0 4px 8px rgba(44, 85, 48, 0.3));
    }
}

/* Splash Screen Loading Animation */
.pwa-splash-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #2c5530;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.pwa-splash-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    animation: pulse 2s ease-in-out infinite;
}

.splash-text {
    color: white;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.splash-progress {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.splash-progress-bar {
    height: 100%;
    background: white;
    border-radius: 2px;
    animation: progressLoad 2s ease-out forwards;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes progressLoad {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* Standalone PWA Detection & Styling */
@media (display-mode: standalone) {
    /* Add top padding for status bar on iOS */
    body {
        padding-top: max(20px, env(safe-area-inset-top));
    }
    
    /* Hide browser chrome indicators */
    .browser-only {
        display: none !important;
    }
    
    /* Show PWA-specific UI */
    .pwa-only {
        display: block !important;
    }
}

/* Improved Icon Rendering */
img[src*="/icons/"] {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* App Badge Indicator */
.app-badge {
    position: relative;
}

.app-badge::after {
    content: attr(data-badge);
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Installation Success Animation */
@keyframes installSuccess {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.install-success-icon {
    animation: installSuccess 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Quick Actions Floating Bar (Android-style) */
.pwa-quick-actions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 85, 48, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
}

@media (display-mode: standalone) {
    .pwa-quick-actions {
        display: block;
    }
}

.quick-actions-container {
    display: flex;
    gap: 5px;
}

.quick-action {
    background: transparent;
    border: none;
    color: white;
    padding: 12px 16px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    font-size: 11px;
}

.quick-action:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.quick-action i {
    font-size: 20px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .splash-logo {
        width: 100px;
        height: 100px;
    }
    
    .splash-text {
        font-size: 20px;
    }
    
    .quick-action {
        padding: 10px 12px;
        font-size: 10px;
    }
    
    .quick-action i {
        font-size: 18px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .pwa-splash-loader {
        background: #1a2e1e;
    }
}

/* Installation Prompt Enhancements */
.pwa-aggressive-install {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    animation: fadeIn 0.3s ease-out;
}

.install-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.install-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

.install-header {
    text-align: center;
    margin-bottom: 20px;
}

.install-header img {
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(44, 85, 48, 0.2);
}

.install-steps h3 {
    color: #2c5530;
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 10px 0;
    text-align: center;
}

.install-subtitle {
    color: #666;
    font-size: 14px;
    text-align: center;
    margin: 0 0 20px 0;
}

.install-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.steps-container {
    margin: 20px 0;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
}

.step-number {
    background: #2c5530;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.step-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    padding-top: 4px;
}

.install-benefits {
    background: #e8f5e9;
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
}

.install-benefits h4 {
    color: #2c5530;
    font-size: 16px;
    margin: 0 0 10px 0;
}

.install-benefits ul {
    margin: 0;
    padding-left: 20px;
}

.install-benefits li {
    font-size: 13px;
    line-height: 1.8;
    color: #333;
}

.install-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-auto-install,
.btn-manual-install,
.btn-remind-later {
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-auto-install {
    background: #2c5530;
    color: white;
}

.btn-auto-install:hover {
    background: #234422;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 85, 48, 0.3);
}

.btn-manual-install {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #dee2e6;
}

.btn-manual-install:hover {
    background: #e9ecef;
}

.btn-remind-later {
    background: transparent;
    color: #6c757d;
    border: none;
    font-size: 14px;
}

.btn-remind-later:hover {
    color: #495057;
    text-decoration: underline;
}

.install-footer {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.install-footer small {
    color: #6c757d;
    font-size: 12px;
}

/* Install Guide Bar */
.pwa-install-guide {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #2c5530 0%, #3e6b3e 100%);
    color: white;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    animation: slideDown 0.3s ease-out;
}

.guide-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 15px;
}

.guide-text {
    font-size: 14px;
}

.guide-close {
    background: white;
    color: #2c5530;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.guide-close:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translate(-50%, -40%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

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

/* Mobile Responsive */
@media (max-width: 600px) {
    .install-modal {
        padding: 25px 20px;
        width: 95%;
    }
    
    .install-steps h3 {
        font-size: 20px;
    }
    
    .step {
        padding: 10px;
    }
    
    .step-text {
        font-size: 13px;
    }
    
    .install-benefits li {
        font-size: 12px;
    }
}
