/**
 * SitePilot PWA Mobile Stylesheet
 * 1:1 Parity with Flutter Native App UI Screenshots
 */

/* Default Desktop Mode: Hide PWA elements */
.pwa-mobile-header,
.pwa-bottom-nav,
.pwa-fab,
.pwa-offline-banner,
.pwa-mobile-only,
.pwa-exit-desktop-btn {
    display: none !important;
}

/* =========================================================
   PWA APP MODE: Activated via class .pwa-active-view OR on mobile screens <= 991px
   ========================================================= */
@media (max-width: 991px) {
    .desktop-only-header,
    .top-navbar,
    .app-sidebar,
    .sidebar-overlay,
    .site-status-pill-bar,
    .filter-search-box-desktop,
    #dateFilterDrawer,
    .projects-grid-container {
        display: none !important;
    }

    .pwa-mobile-header,
    .pwa-bottom-nav,
    .pwa-fab,
    .pwa-mobile-only {
        display: block !important;
    }
    
    .pwa-bottom-nav {
        display: flex !important;
    }

    .pwa-fab {
        display: flex !important;
    }
}

body.pwa-active-view .desktop-only-header,
body.pwa-active-view .top-navbar,
body.pwa-active-view .app-sidebar,
body.pwa-active-view .sidebar-overlay,
body.pwa-active-view .site-status-pill-bar,
body.pwa-active-view .filter-search-box-desktop,
body.pwa-active-view #dateFilterDrawer,
body.pwa-active-view .projects-grid-container {
    display: none !important;
}

body.pwa-active-view .pwa-mobile-header,
body.pwa-active-view .pwa-mobile-only {
    display: block !important;
}

body.pwa-active-view .pwa-bottom-nav,
body.pwa-active-view .pwa-fab {
    display: flex !important;
}

/* Reset layout for mobile app frame */
body.pwa-active-view,
@media (max-width: 991px) {
    html, body {
        background: #f4f6fa !important;
        width: 100%;
        overflow-x: hidden;
        -webkit-tap-highlight-color: transparent;
        font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    }

    .app-layout {
        display: block !important;
        min-height: 100vh;
        background: #f4f6fa !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        background: #f4f6fa !important;
    }

    .page-container {
        padding: 14px 16px 85px !important;
        background: #f4f6fa !important;
    }

    .card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    .card-body {
        padding: 0 !important;
    }
}

/* On Desktop when toggled, center like an iPhone / Android mockup */
@media (min-width: 992px) {
    body.pwa-active-view .page-container {
        max-width: 440px !important;
        margin: 0 auto !important;
        min-height: 100vh !important;
        background: #f4f6fa !important;
        box-shadow: 0 0 50px rgba(15, 23, 42, 0.18) !important;
        position: relative;
        border-left: 1px solid #e2e8f0;
        border-right: 1px solid #e2e8f0;
        padding-bottom: 90px !important;
    }

    body.pwa-active-view .pwa-mobile-header {
        max-width: 440px;
        margin: 0 auto;
        left: 0;
        right: 0;
    }

    body.pwa-active-view .pwa-bottom-nav {
        max-width: 440px;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    body.pwa-active-view .pwa-fab {
        right: calc(50% - 200px) !important;
    }

    body.pwa-active-view .pwa-exit-desktop-btn {
        display: inline-flex !important;
    }
}

/* =========================================================
   1. PWA CURVED HEADER (1:1 with Screenshot 73e61577)
   ========================================================= */
.pwa-mobile-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    padding: 14px 18px 20px;
    border-radius: 0 0 24px 24px;
    box-shadow: 0 8px 20px rgba(30, 58, 138, 0.28);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.pwa-header-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pwa-company-badge-btn {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 13.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.15s ease;
}

.pwa-header-icons-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pwa-header-icon-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    text-decoration: none;
    cursor: pointer;
}

.pwa-badge-pill {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ef4444;
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 9999px;
    border: 1.5px solid #1e3a8a;
}

/* =========================================================
   2. SCREEN TITLE & SEARCH BAR
   ========================================================= */
.pwa-title-section {
    margin: 16px 0 14px;
}

.pwa-main-title {
    font-size: 22px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.4px;
    margin: 0 0 6px 0;
}

.pwa-count-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e0f2fe;
    color: #0284c7;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
}

.pwa-search-pill-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
    padding: 0 16px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    border: 1.5px solid #e2e8f0;
}

.pwa-search-pill-input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: #0f172a;
    background: transparent;
}

/* =========================================================
   3. MOBILE SITE CARDS (1:1 with Screenshot 73e61577)
   ========================================================= */
.pwa-site-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 16px 18px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.03);
    border: 1.5px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease;
}

.pwa-site-card:active {
    transform: scale(0.985);
}

.pwa-site-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pwa-site-card-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.pwa-site-avatar-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #fed7aa;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.15);
}

.pwa-site-card-title {
    font-size: 17.5px;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.pwa-site-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pwa-icon-action-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 6px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-icon-action-btn:hover {
    color: #0284c7;
    background: #f0f9ff;
}

.pwa-icon-action-btn.delete-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

.pwa-site-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid #f8fafc;
    font-size: 12.5px;
}

.pwa-status-pill-badge {
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.pwa-status-ongoing {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.pwa-status-finished {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.pwa-status-on_hold {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.pwa-site-card-dates {
    color: #64748b;
    font-size: 11.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* =========================================================
   4. FIXED BOTTOM NAVIGATION BAR
   ========================================================= */
.pwa-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 66px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding: 0 10px;
    justify-content: space-around;
    align-items: center;
}

.pwa-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: #64748b;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    gap: 4px;
    transition: color 0.15s ease;
}

.pwa-nav-item.active {
    color: #1e3a8a;
    font-weight: 800;
}

.pwa-nav-item svg {
    width: 22px;
    height: 22px;
}

/* =========================================================
   5. FLOATING ACTION BUTTON (FAB)
   ========================================================= */
.pwa-fab {
    position: fixed;
    bottom: 80px;
    right: 18px;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 10px 25px rgba(30, 58, 138, 0.45);
    align-items: center;
    justify-content: center;
    z-index: 999;
    border: none;
    cursor: pointer;
}

/* =========================================================
   6. BOTTOM SHEETS (Modals)
   ========================================================= */
.pwa-bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.pwa-bottom-sheet-backdrop.active {
    display: flex !important;
}

.pwa-bottom-sheet {
    background: #ffffff;
    width: 100%;
    max-width: 480px;
    border-radius: 28px 28px 0 0;
    padding: 16px 20px 30px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
    max-height: 85vh;
    overflow-y: auto;
    animation: pwaSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-sheet-handle {
    width: 42px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 999px;
    margin: 0 auto 16px;
}

.pwa-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.pwa-sheet-title {
    font-size: 19px;
    font-weight: 800;
    color: #0f172a;
}

.pwa-input-box {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    height: 48px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.pwa-input-box:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.pwa-input-box input,
.pwa-input-box select,
.pwa-input-box textarea {
    border: none;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: #0f172a;
    background: transparent;
}

.pwa-primary-submit-btn {
    width: 100%;
    height: 50px;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

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