/* ============================================================
   Sefari Customer Portal – Hotfix CSS
   Injected directly into dist to avoid full rebuild.
   ============================================================ */

/* ── Global scroll unlock for portal pages ────────────────── */
html:has(body.sefari-portal) {
    overflow-y: auto !important;
    height: auto !important;
}

body.sefari-portal {
    overflow-y: auto !important;
    height: auto !important;
    max-height: none !important;
}

body.sefari-portal .sefari-next-container,
body.sefari-portal .sefari-next-container {
    overflow: visible !important;
    height: auto !important;
    min-height: 100vh !important;
    max-height: none !important;
}

/* ── Order workspace toolbar: keep buttons in a row ───────── */
.sefari-portal .portal-order-workspace-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 0.5rem !important;
}

/* The map/table toggle group */
.sefari-portal .portal-order-view-toggle {
    display: inline-flex !important;
    flex-shrink: 0 !important;
}

/* ── Section header: row layout on all sizes ──────────────── */
.sefari-portal .portal-section-header.portal-order-workspace-header {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.75rem !important;
}

/* ── Mobile-specific overrides (≤ 1024px) ─────────────────── */
@media (max-width: 1024px) {
    /* Keep toolbar horizontal */
    .sefari-portal .portal-order-workspace-actions,
    .sefari-portal .portal-order-workspace-header {
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: wrap !important;
    }

    /* Sidebar: compact horizontal grid on tablet */
    .sefari-portal .portal-nav-group {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.25rem !important;
    }

    .sefari-portal .portal-nav-label {
        grid-column: 1 / -1 !important;
    }
}

/* ── Small mobile overrides (≤ 640px) ─────────────────────── */
@media (max-width: 640px) {
    /* Keep the order workspace header content flowing */
    .sefari-portal .portal-section-header.portal-order-workspace-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    /* But KEEP the actions row horizontal */
    .sefari-portal .portal-order-workspace-actions {
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.375rem !important;
        width: 100% !important;
    }

    /* Buttons: compact sizing on mobile */
    .sefari-portal .portal-order-workspace-actions .btn {
        padding: 0.375rem 0.625rem !important;
        font-size: 0.8125rem !important;
        min-height: 2rem !important;
    }

    .sefari-portal .portal-order-view-toggle .btn {
        padding: 0.375rem 0.5rem !important;
    }

    /* New Order button gets pushed to end */
    .sefari-portal .portal-order-workspace-actions > .btn-wrapper:last-child {
        margin-left: auto !important;
    }

    /* Topbar on mobile: keep items in a row */
    .sefari-portal .portal-topbar {
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .sefari-portal .portal-topbar-actions {
        flex-wrap: wrap !important;
        gap: 0.375rem !important;
    }

    /* Main content area: reduce padding on mobile */
    .sefari-portal .portal-container > .portal-main {
        padding: 0.5rem !important;
        gap: 0.5rem !important;
    }

    /* Order list panel: full width on mobile */
    .sefari-portal .portal-order-list-panel {
        position: relative !important;
        width: 100% !important;
        max-height: 50vh !important;
        overflow-y: auto !important;
    }

    /* Order route panel / detail sidebar */
    .sefari-portal .portal-order-route-panel {
        position: relative !important;
        width: 100% !important;
        min-height: auto !important;
    }

    /* Form actions: horizontal */
    .sefari-portal .portal-form-actions {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Invoice summary: 2 cols instead of 4 */
    .sefari-portal .portal-invoice-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Dashboard quick actions: wrap nicely */
    .sefari-portal .portal-dashboard-quick-actions {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Sidebar nav: single column on very small screens */
    .sefari-portal .portal-nav-group {
        grid-template-columns: 1fr !important;
    }
}

/* ── Map container: proper sizing ─────────────────────────── */
.sefari-portal .portal-order-map-stage {
    position: relative !important;
    min-height: 400px !important;
}

/* Leaflet map: ensure it fills container */
.sefari-portal .portal-order-map-stage .leaflet-container {
    min-height: 400px !important;
}

/* ── Fix broken avatar fallback ───────────────────────────── */
.sefari-portal img[src*="no-avatar"]:not([src*="s3.sefari.io"]),
.sefari-portal img.avatar-image[src=""],
.sefari-portal img.avatar-image:not([src]) {
    content: url("https://s3.sefari.io/sfr-assets/static/no-avatar.png") !important;
}

/* ============================================================
   Performance — Core Web Vitals Optimizations
   ============================================================ */

/* INP: Skip rendering of off-screen/collapsed content panels */
.next-content-panel-is-closed {
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
}

/* INP: Prevent invisible notification container from intercepting clicks */
.ember-cli-notifications-notification__container,
.ember-cli-notifications-notification__container--top {
    pointer-events: none !important;
}

.ember-cli-notifications-notification__container > *,
.ember-cli-notifications-notification__container--top > * {
    pointer-events: auto !important;
}

/* ============================================================
   Green Obsidian — Light Mode Darkened Accents
   Makes green richer/deeper on white backgrounds.
   ============================================================ */

/* Text accents: use green-700 (#15803d) instead of green-500 */
body:not([data-theme='dark']) .text-green-500,
body:not([data-theme='dark']) .text-sky-500,
body:not([data-theme='dark']) .text-blue-500 {
    color: #15803d !important;
}

/* Background accents: use green-600 (#16a34a) */
body:not([data-theme='dark']) .bg-green-500,
body:not([data-theme='dark']) .bg-sky-500,
body:not([data-theme='dark']) .bg-blue-500 {
    background-color: #16a34a !important;
}

/* Portal: darken sidebar active text for light mode */
body:not([data-theme='dark']).sefari-portal .next-nav-item.active {
    color: #166534 !important;
    border-color: #16a34a !important;
    background: #dcfce7 !important;
}

/* Portal: darken hero link/button hover text */
body:not([data-theme='dark']).sefari-portal .portal-header-link:hover,
body:not([data-theme='dark']).sefari-portal .portal-quick-link:hover {
    color: #166534 !important;
    border-color: #16a34a !important;
}

/* Portal: darken the primary action button */
body:not([data-theme='dark']).sefari-portal .portal-quick-link.primary {
    background: #16a34a !important;
    border-color: #15803d !important;
}

/* Portal: darken account mark icon in light mode */
body:not([data-theme='dark']).sefari-portal .portal-account-mark {
    color: #166534 !important;
    border-color: #16a34a !important;
}

/* Portal: KPI accent icons */
body:not([data-theme='dark']).sefari-portal .portal-kpi-accent-blue .portal-kpi-icon,
body:not([data-theme='dark']).sefari-portal .portal-kpi-accent-green .portal-kpi-icon {
    color: #166534 !important;
    background: #bbf7d0 !important;
}

/* Console: primary buttons in light mode */
body:not([data-theme='dark']) .btn-primary,
body:not([data-theme='dark']) .btn.btn-primary {
    background-color: #16a34a !important;
    border-color: #15803d !important;
}

body:not([data-theme='dark']) .btn-primary:hover,
body:not([data-theme='dark']) .btn.btn-primary:hover {
    background-color: #15803d !important;
}

/* Console: link text in light mode */
body:not([data-theme='dark']) a.text-green-500,
body:not([data-theme='dark']) a.text-sky-500 {
    color: #15803d !important;
}

/* Focus rings: deeper green */
body:not([data-theme='dark']) .focus\:ring-green-500:focus,
body:not([data-theme='dark']) .focus\:border-green-300:focus {
    border-color: #16a34a !important;
}
