/* PWA Install Prompt Styles */
.pwa-install-prompt {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 400px;
    margin: 0 auto;
}

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

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

.pwa-install-icon img {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
}

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

.pwa-install-text h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.pwa-install-text p {
    margin: 0;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    line-height: 1.4;
}

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

.pwa-install-button {
    background: linear-gradient(135deg, #ff6b35, #f4550e);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 100px;
    justify-content: center;
}

.pwa-install-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255,107,53,0.4);
}

.pwa-dismiss-button {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-dismiss-button:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* PWA Success Notification */
.pwa-success-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(37,211,102,0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease;
}

/* Allow inline HTML in the banner description */
.pwa-install-text p strong {
    color: #fff;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* PWA Bottom Navigation */
.pwa-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-top: 1px solid rgba(255,255,255,0.1);
    z-index: 1030;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}

.pwa-bottom-nav.show {
    transform: translateY(0);
}

.pwa-nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    height: 65px;
}

.pwa-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: rgba(255,255,255,0.6);
    transition: all 0.3s ease;
    padding: 8px 12px;
    border-radius: 12px;
    min-width: 60px;
    position: relative;
    overflow: hidden;
}

.pwa-nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,107,53,0.1), rgba(255,107,53,0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 12px;
}

.pwa-nav-item:hover::before,
.pwa-nav-item.active::before {
    opacity: 1;
}

.pwa-nav-item:hover,
.pwa-nav-item.active {
    color: #ff6b35;
    transform: translateY(-2px);
}

.pwa-nav-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.pwa-nav-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #ff6b35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.pwa-nav-icon {
    font-size: 20px;
    margin-bottom: 4px;
    transition: transform 0.3s ease;
}

.pwa-nav-item:hover .pwa-nav-icon,
.pwa-nav-item.active .pwa-nav-icon {
    transform: scale(1.1);
}

.pwa-nav-label {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 1;
}

.pwa-menu-btn,
.pwa-share-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

/* Body adjustments for PWA navigation */
body.pwa-nav-active {
    padding-bottom: 65px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .pwa-install-prompt {
        bottom: 10px;
        left: 10px;
        right: 10px;
        padding: 15px;
    }
    
    .pwa-install-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .pwa-install-actions {
        flex-direction: row;
        width: 100%;
    }
    
    .pwa-install-button {
        flex: 1;
    }
    
    .pwa-dismiss-button {
        min-width: auto;
        padding: 10px;
    }
    
    .pwa-nav-container {
        height: 60px;
    }
    
    .pwa-nav-item {
        min-width: 50px;
        padding: 6px 8px;
    }
    
    .pwa-nav-icon {
        font-size: 18px;
    }
    
    .pwa-nav-label {
        font-size: 10px;
    }
}

@media (min-width: 1025px) {
    .pwa-bottom-nav {
        display: none;
    }
    
    body.pwa-nav-active {
        padding-bottom: 0;
    }
}

/* Tablet-specific styles */
@media (min-width: 768px) and (max-width: 1024px) {
    .pwa-nav-container {
        height: 70px;
        padding: 10px 0 max(10px, env(safe-area-inset-bottom));
    }
    
    .pwa-nav-item {
        min-width: 70px;
        padding: 10px 15px;
    }
    
    .pwa-nav-icon {
        font-size: 22px;
        margin-bottom: 6px;
    }
    
    .pwa-nav-label {
        font-size: 12px;
    }
    
    .pwa-install-prompt {
        max-width: 500px;
        bottom: 30px;
        left: 50%;
        transform: translateX(-50%) translateY(100px);
    }
    
    .pwa-install-prompt.show {
        transform: translateX(-50%) translateY(0);
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .pwa-nav-container {
        height: 50px;
        padding: 4px 0 max(4px, env(safe-area-inset-bottom));
    }
    
    .pwa-nav-icon {
        font-size: 16px;
        margin-bottom: 2px;
    }
    
    .pwa-nav-label {
        font-size: 9px;
    }
    
    .pwa-nav-item {
        min-width: 45px;
        padding: 4px 6px;
    }
}

/* Safe area support for iPhone X and similar devices */
@supports (padding: max(0px)) {
    .pwa-nav-container {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }
    
    .pwa-install-prompt {
        bottom: max(20px, env(safe-area-inset-bottom));
        left: max(20px, env(safe-area-inset-left));
        right: max(20px, env(safe-area-inset-right));
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .pwa-install-prompt {
        background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 50%, #2a2a2a 100%);
    }
    
    .pwa-bottom-nav {
        background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 50%, #2a2a2a 100%);
    }
}

/* Animation for navigation appearance */
.pwa-bottom-nav {
    animation: slideUp 0.3s ease forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Focus styles for accessibility */
.pwa-nav-item:focus,
.pwa-install-button:focus,
.pwa-dismiss-button:focus {
    outline: 2px solid #ff6b35;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pwa-nav-item {
        border: 1px solid transparent;
    }
    
    .pwa-nav-item.active {
        border-color: #ff6b35;
    }
}

/* ── PWA Slide-in Drawer ── */
.pwa-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    pointer-events: none;
    visibility: hidden;
}

.pwa-drawer.open {
    pointer-events: auto;
    visibility: visible;
}

/* Overlay */
.pwa-drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pwa-drawer.open .pwa-drawer-overlay {
    opacity: 1;
}

/* Panel */
.pwa-drawer-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

.pwa-drawer.open .pwa-drawer-panel {
    transform: translateX(0);
}

/* Header */
.pwa-drawer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.pwa-drawer-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    background: #fff;
    padding: 2px;
}

.pwa-drawer-user {
    flex: 1;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-drawer-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.pwa-drawer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Menu */
.pwa-drawer-menu {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.pwa-drawer-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 20px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 15px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.pwa-drawer-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    text-decoration: none;
}

.pwa-drawer-item.active {
    color: #ff6b35;
    background: rgba(255, 107, 53, 0.08);
    border-left-color: #ff6b35;
}

.pwa-drawer-item i {
    width: 22px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.pwa-drawer-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 6px 16px;
}

.pwa-drawer-group-title {
    padding: 10px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 600;
}

.pwa-drawer-logout {
    color: rgba(255, 80, 80, 0.8) !important;
}

.pwa-drawer-logout:hover {
    color: #ff5050 !important;
    background: rgba(255, 80, 80, 0.08) !important;
}

/* Tablet drawer is slightly wider */
@media (min-width: 768px) and (max-width: 1024px) {
    .pwa-drawer-panel {
        width: 320px;
    }
}

/* Ensure install banner sits above bottom nav */
body.pwa-nav-active .pwa-install-prompt {
    bottom: 80px;
}

@media (max-width: 480px) {
    body.pwa-nav-active .pwa-install-prompt {
        bottom: 75px;
    }
}
