/* =============================================================
   VIFM Header Mega-Menu
   ============================================================= */

/* Extend header to 48px to fit menu buttons */
.app-header {
    height: 48px;
}

/* Nav sits between the logo and the user bar */
.header-nav {
    display: flex;
    align-items: stretch;
    margin-left: 24px;
    gap: 2px;
    height: 100%;
}

/* Client name shown as static (non-interactive) text in the user bar,
   just before the signed-in user's name. */
.client-name-static {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    padding-right: 10px;
    margin-right: 6px;
    border-right: 1px solid rgba(255, 255, 255, 0.25);
}

.client-name-static[hidden] {
    display: none;
}

/* Individual menu trigger buttons */
.menu-trigger {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 14px;
    height: 100%;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    border: none;
    border-bottom: 2px solid transparent;
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    position: relative;
}

.menu-trigger:hover,
.menu-trigger[aria-expanded="true"] {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-bottom-color: #4da3ff;
}

.menu-trigger[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.12);
}

/* Chevron arrow */
.menu-trigger .chevron {
    font-size: 9px;
    opacity: 0.7;
    transition: transform 0.2s;
    display: inline-block;
}

.menu-trigger[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

/* Dot badge: shown when a client or block is selected */
.menu-trigger .menu-sel {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.75;
    font-size: 12px;
}

/* Hidden elements */
[hidden] { display: none !important; }

/* =============================================================
   Mega-panel dropdowns
   ============================================================= */

.mega-panel {
    position: absolute;
    top: 48px;
    background: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    font-size: 13px;
    min-width: 200px;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.mega-panel.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.mega-panel-header {
    padding: 10px 14px 6px;
    font-weight: 600;
    color: #2E4057;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #eee;
}

/* =============================================================
   Map Style panel
   ============================================================= */

#panel-map-style {
    left: 0;
    min-width: 160px;
}

.style-options {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.style-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 5px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
    color: #333;
    transition: background 0.1s;
}

.style-option:hover {
    background: #f0f4ff;
}

.style-option.active {
    background: #e8f0fe;
    color: #1a56db;
    font-weight: 600;
}

.style-option .style-icon {
    width: 28px;
    height: 20px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid #ddd;
    background-size: cover;
}

.style-icon-satellite {
    background: linear-gradient(135deg, #2d5a27, #3a7d44, #1a3a5e);
}

.style-icon-road {
    background: linear-gradient(135deg, #d0d8e0, #b0bcc8, #f5f5f5);
}

/* =============================================================
   BC Layers panel
   ============================================================= */

#panel-bc-layers {
    left: 0;
    min-width: 220px;
}

.layer-list {
    padding: 8px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.layer-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #333;
    font-size: 13px;
    user-select: none;
}

.layer-list label:hover {
    color: #000;
}

.layer-list input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #2E4057;
}

.layer-section-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 8px 0 4px;
}

/* =============================================================
   Clients panel (VIFMInternal only)
   ============================================================= */

#panel-client {
    min-width: 260px;
}

/* =============================================================
   Projects panel (all roles)
   ============================================================= */

#panel-projects {
    min-width: 280px;
}

/* =============================================================
   Blocks panel
   ============================================================= */

#panel-blocks {
    min-width: 280px;
}

/* Shared: search box + scrollable list used in Client and Blocks panels */
.panel-search {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
}

.panel-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
    font-family: "Segoe UI", system-ui, sans-serif;
}

.panel-search input:focus {
    border-color: #4da3ff;
}

.panel-list {
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 0;
}

.panel-list-item[aria-disabled="true"] {
    opacity: 0.45;
    cursor: default;
}

.panel-list-item {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
    color: #333;
    gap: 8px;
    border-radius: 0;
    transition: background 0.1s;
}

.panel-list-item:hover {
    background: #f0f4ff;
}

.panel-list-item.selected {
    background: #e8f0fe;
    color: #1a56db;
    font-weight: 600;
}

.panel-list-item.all-clients {
    color: #666;
    font-style: italic;
    border-bottom: 1px solid #eee;
}

.panel-list-item .item-sub {
    font-size: 11px;
    color: #888;
    font-weight: normal;
    margin-top: 1px;
}

/* Block with no processed map data — visible to internal users but not selectable */
.panel-list-item.block-no-map {
    opacity: 0.45;
    cursor: default;
}

.panel-list-item.block-no-map:hover {
    background: none;
}

.panel-list-item-inner {
    display: flex;
    flex-direction: column;
}

.panel-empty {
    padding: 16px 14px;
    color: #999;
    font-style: italic;
    font-size: 12px;
    text-align: center;
}

.panel-loading {
    padding: 14px;
    color: #888;
    font-size: 12px;
    text-align: center;
}

/* =============================================================
   Progress panel (mega-panel variant)
   ============================================================= */

#panel-progress {
    right: 0;
    min-width: 300px;
    max-width: 340px;
}

.progress-sub-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
}

.progress-sub-tab {
    flex: 1;
    padding: 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.progress-sub-tab:hover {
    color: #2E4057;
}

.progress-sub-tab.active {
    color: #2E4057;
    border-bottom-color: #2E4057;
    font-weight: 600;
}

.progress-sub-content {
    display: none;
    padding: 10px 14px 14px;
}

.progress-sub-content.active {
    display: block;
}

/* Volume stat row */
.progress-volume-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.progress-volume-label {
    color: #555;
}

.progress-volume-value {
    font-weight: 600;
    color: #2E4057;
}

/* =============================================================
   Mobile: hamburger (≤640px)
   ============================================================= */

@media (max-width: 640px) {
    .header-nav {
        display: none;
        position: absolute;
        top: 48px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: #111;
        z-index: 1099;
        gap: 0;
        height: auto;
        align-items: stretch;
        margin-left: 0;
    }

    .header-nav.mobile-open {
        display: flex;
    }

    .hamburger-btn {
        display: flex !important;
    }

    .menu-trigger {
        height: 44px;
        padding: 0 20px;
        border-bottom: none;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .mega-panel {
        position: static;
        box-shadow: none;
        border-radius: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        background: #222;
        color: #eee;
    }

    .mega-panel.open {
        transform: none;
    }

    .mega-panel-header,
    .layer-list label,
    .panel-list-item,
    .style-option {
        color: #eee;
    }

    .style-option:hover,
    .panel-list-item:hover,
    .style-option.active,
    .panel-list-item.selected {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }
}

/* Block-unavailable notice — shown when ?block= is not accessible to current user */
.block-unavailable-notice {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 30, 0.92);
    color: #f0f0f0;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 20px 28px;
    font-size: 14px;
    text-align: center;
    pointer-events: none;
    z-index: 500;
}

/* Hidden by default; shown only on mobile */
.hamburger-btn {
    display: none;
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 12px;
    line-height: 48px;
}

/* =============================================================
   Heli Pads — dropdown items + info panel
   ============================================================= */

/* "<Add Heli Pad>" / "<Select block>" action items in dropdown lists */
.helipad-add-item,
.block-clear-item {
    font-weight: 600;
    color: #2E4057;
    font-style: italic;
}

/* Heli Pad info panel — pinned beside the Progress panel (which pins at
   left:12px, max-width 340px) so both can be open side by side. */
.helipad-panel {
    position: absolute;
    top: 48px;
    left: 368px;
    width: 300px;
    background: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
    z-index: 1090;
    font-size: 13px;
}

.helipad-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 6px;
    font-weight: 600;
    color: #2E4057;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #eee;
}

.helipad-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
}

.helipad-fields label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: #666;
}

.helipad-fields input {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    font-family: "Segoe UI", system-ui, sans-serif;
    color: #222;
}

/* Client read-only view: quiet the inputs down to plain values */
.helipad-fields input[readonly] {
    border-color: transparent;
    background: #f7f7f7;
    cursor: default;
}

.helipad-loc-row {
    display: flex;
    gap: 8px;
}

.helipad-loc-row label {
    /* Half the row each; min-width:0 lets the inputs shrink below their
       intrinsic default width instead of overflowing the panel. */
    flex: 1 1 50%;
    max-width: 50%;
    min-width: 0;
}

.helipad-report-link {
    padding: 2px 0;
}

.helipad-report-link a {
    color: #1a73e8;
    font-weight: 600;
    text-decoration: none;
}

.helipad-report-link a:hover {
    text-decoration: underline;
}

/* Report PDF upload/replace/remove (admin-only row under the report link) */
.helipad-report-upload {
    display: flex;
    gap: 8px;
    padding: 2px 0 4px;
}

.helipad-report-upload button {
    padding: 4px 10px;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.helipad-report-upload button:hover {
    background: #e8e8e8;
}

.helipad-report-upload #hpRemoveReportBtn {
    color: #b3261e;
    border-color: #b3261e;
}

.helipad-report-upload #hpRemoveReportBtn:hover {
    background: #fbeae9;
}

.helipad-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #eee;
}

.helipad-actions button {
    flex: 1;
    padding: 6px 10px;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.helipad-actions button:hover {
    background: #e8e8e8;
}

/* Armed state (e.g. Move waiting for a drag/click) — all-around glow so it
   clearly reads as "active" */
.helipad-actions button.active {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.30), 0 0 10px 2px rgba(26, 115, 232, 0.55);
}

.helipad-actions button.active:hover {
    background: #1557b0;
}

.helipad-actions .helipad-btn-primary {
    background: #1a73e8;
    color: #fff;
    border: none;
    font-weight: 600;
}

.helipad-actions .helipad-btn-primary:hover {
    background: #1557b0;
}

.helipad-actions .helipad-btn-danger {
    color: #b3261e;
    border-color: #b3261e;
}

.helipad-actions .helipad-btn-danger:hover {
    background: #fbeae9;
}

.helipad-hint {
    min-height: 14px;
    padding: 0 14px 10px;
    font-size: 11px;
    color: #B85C00;
}

/* Salus-created pads: placeholder-position warning + confirm action */
.helipad-placement-banner {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 14px 0;
    padding: 8px 10px;
    background: #FFF4E5;
    border: 1px solid #FF8C00;
    border-radius: 4px;
    font-size: 12px;
    color: #7A4A00;
}

.helipad-placement-banner button {
    align-self: flex-start;
    padding: 4px 10px;
    background: #FF8C00;
    color: #fff;
    border: 1px solid #E67E00;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.helipad-placement-banner button:hover {
    background: #E67E00;
}

/* Provenance line for pads imported by the Salus sync */
.helipad-salus-info {
    padding: 0 14px 4px;
    font-size: 11px;
    color: #777;
}

@media (max-width: 760px) {
    .helipad-panel {
        left: 12px;
        right: 12px;
        width: auto;
    }
}

/* =============================================================
   View Options (trigger in the user bar + dropdown panel)
   ============================================================= */

/* The trigger sits in the user bar (right side of the header), not in the
   nav — give it the header height so it aligns with the nav triggers. */
.user-bar .menu-trigger {
    height: 48px;
}

#panel-view-options {
    left: auto;
    right: 12px;
    min-width: 210px;
}

@media (max-width: 640px) {
    /* Keep View Options a floating dropdown on mobile — its trigger lives in
       the user bar, not the collapsing hamburger nav, so the generic
       position:static mobile mega-panel rule doesn't apply to it. */
    #panel-view-options {
        position: absolute;
        top: 48px;
        left: auto;
        right: 8px;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
    }
}

/* --- Header busy indicator (HeaderBusy) --- */

.header-busy {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 12px;
    color: rgba(255, 255, 255, 0.85);
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
    white-space: nowrap;
    /* Never absorb header overflow — it can't compress below its label anyway. */
    flex-shrink: 0;
}

.header-busy-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #4da3ff;
    border-radius: 50%;
    animation: header-busy-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    /* Text-only — the ring is decorative and the label carries the meaning. */
    .header-busy-spinner { display: none; }
}

@media (max-width: 640px) {
    /* Out of flow on mobile: as an in-flow flex item it displaced the
       hamburger by its own width every time a load started, moving the primary
       nav control out from under the user's finger. Absolute keeps the header
       layout fixed while it appears and disappears. */
    .header-busy {
        position: absolute;
        top: 0;
        right: 52px;   /* clears the hamburger glyph + its padding */
        height: 48px;
        padding: 0;
        z-index: 1100;
    }
}

@media (max-width: 480px) {
    /* Very narrow: spinner only — the label would crowd the user bar. */
    .header-busy { font-size: 0; gap: 0; }
    .header-busy-spinner { font-size: 13px; }
}
