/* =========================================================
   Map Header Layout
   - Geometry/spacing/typography only
   - Interactive "open/active/hover" states are defined in:
     - map_header_state.css
     - map_header_interaction.css
   ========================================================= */

/* ---------------------------------------------------------
   Header Shell / Brand
   --------------------------------------------------------- */
#map-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.map-header-text {
    min-width: 0;
}

.map-header-logo {
    height: 80px;
    width: auto;
    object-fit: contain;
}

.map-header-logo-emoji {
    font-size: 28px;
}

.map-header-title {
    margin: 0;
    font-size: 20px;
    font-weight: bold;
    line-height: 1.2;
    white-space: nowrap;
}

.map-header-subtitle {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.2;
    white-space: nowrap;
}

/* ---------------------------------------------------------
   Search Container / Form Layout
   --------------------------------------------------------- */
#map-search-container {
    display: block;
    margin-right: 0;
    max-width: 0;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transform: translateY(-6px);
    pointer-events: none;
    transition:
        max-width 0.24s ease,
        max-height 0.22s ease,
        opacity 0.2s ease,
        transform 0.2s ease,
        margin-right 0.24s ease,
        visibility 0s linear 0.22s;
}

#map-search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.map-search-field {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.4);
    min-width: 240px;
}

.map-search-input,
.map-search-tag {
    border: 0;
    background: transparent;
    color: #fff;
    height: 100%;
    width: 100%;
    padding: 0 8px 0 10px;
    font-size: 13px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.map-search-input:focus,
.map-search-input:not(:placeholder-shown) {
    background: transparent;
}

.map-search-input:-webkit-autofill,
.map-search-input:-webkit-autofill:hover,
.map-search-input:-webkit-autofill:focus,
.map-search-input:-webkit-autofill:active {
    -webkit-text-fill-color: #ffffff;
    box-shadow: 0 0 0px 1000px transparent inset;
    -webkit-box-shadow: 0 0 0px 1000px transparent inset;
    transition: background-color 9999s ease-out 0s;
}

.map-search-field:focus-within {
    background: rgba(255, 255, 255, 0.18);
}

.map-search-field:focus-within .map-search-input-clear {
    background: rgba(255, 255, 255, 0.18);
}

.map-search-input-clear {
    width: 24px;
    height: 24px;
    margin-right: 6px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.92);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.map-search-input-clear.is-hidden {
    visibility: hidden;
    pointer-events: none;
}

.map-search-input::placeholder {
    color: rgba(255, 255, 255, 0.86);
}

/* ---------------------------------------------------------
   Tag Filter Panel Layout
   --------------------------------------------------------- */
.map-tag-filter {
    position: relative;
    z-index: 1200;
}

.map-tag-filter summary {
    list-style: none;
    cursor: pointer;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 13px;
    padding: 0 12px;
    min-width: 82px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.map-tag-filter summary::-webkit-details-marker {
    display: none;
}

.map-tag-summary-label {
    font-weight: 700;
    font-size: 12px;
}

.map-tag-count {
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.map-tag-options {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    width: max-content;
    z-index: 1300;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(209, 213, 219, 0.9);
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    max-width: min(80vw, 360px);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.map-tag-live-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #374151;
    background: rgba(243, 244, 246, 0.9);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 8px;
    margin-bottom: 8px;
}

.map-tag-live-summary strong {
    color: #111827;
    font-weight: 800;
}

.map-tag-live-divider {
    opacity: 0.6;
}

.map-tag-selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 9px;
    margin-bottom: 8px;
    min-height: 34px;
    max-height: none;
    overflow: visible;
    align-content: flex-start;
    border-bottom: 1px solid #e5e7eb;
}

.map-tag-selected-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex: 0 0 auto;
}

.map-tag-selected-remove {
    opacity: 0.72;
}

.map-tag-selected-clear {
    border: 0;
    background: transparent;
    color: #374151;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 2px;
    cursor: pointer;
}

.map-tag-option-list {
    max-height: 220px;
    overflow-y: auto;
}

.map-tag-option {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1f2937;
    font-size: 13px;
    padding: 6px 2px;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.map-tag-option input[type="checkbox"] {
    accent-color: #3b82f6;
    width: 14px;
    height: 14px;
}

.map-tag-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.3;
    font-weight: 600;
}

.tag-color-blue { background: #355e95; color: #e8f0ff; }
.tag-color-purple { background: #5d4b7b; color: #f2e9ff; }
.tag-color-rose { background: #7f4b59; color: #ffe8ef; }
.tag-color-orange { background: #7a5a3f; color: #ffefde; }
.tag-color-yellow { background: #6f6138; color: #fff8db; }
.tag-color-brown { background: #5d4d40; color: #f4e7dd; }
.tag-color-green { background: #445f49; color: #e3f6e8; }
.tag-color-gray { background: #4b4f56; color: #eceff4; }

/* ---------------------------------------------------------
   Header Action Buttons (Search / Hamburger)
   --------------------------------------------------------- */
#search-toggle-button {
    margin-left: auto;
    width: 45px;
    height: 45px;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

#search-toggle-button svg {
    width: 18px;
    height: 18px;
    display: block;
}

#hamburger-button {
    width: 45px;
    height: 45px;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.hamburger-icon {
    width: 18px;
    height: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger-line {
    display: block;
    width: 100%;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* ---------------------------------------------------------
   Responsive Layout: <= 768px
   --------------------------------------------------------- */
@media screen and (max-width: 768px) {
    #map-header {
        padding: 8px 6px 8px 15px;
        display: grid;
        grid-template-columns: minmax(160px, 1fr) auto auto;
        grid-template-areas:
            "brand search-toggle hamburger"
            "search search search";
        align-items: center;
        column-gap: 2px;
        row-gap: 0;
    }

    .map-header-brand {
        grid-area: brand;
        min-width: 0;
    }

    .map-header-title {
        font-size: 16px;
        white-space: nowrap;
        max-width: 100%;
    }

    .map-header-subtitle {
        font-size: 12px;
        white-space: nowrap;
        max-width: 100%;
    }

    #map-search-form {
        width: 100%;
        gap: 6px;
        flex-wrap: nowrap;
        align-items: center;
    }

    #map-search-container {
        grid-area: search;
        width: 100%;
        margin: 0;
        max-width: 100%;
    }

    #search-toggle-button {
        grid-area: search-toggle;
        margin-left: 0;
        justify-self: end;
        width: 40px;
        height: 40px;
    }

    #hamburger-button {
        grid-area: hamburger;
        justify-self: end;
        width: 40px;
        height: 40px;
    }

    .map-search-field {
        flex: 1 1 auto;
        min-width: 0;
    }

    .map-search-input {
        font-size: 16px;
    }

    .map-tag-filter summary {
        min-width: 74px;
        padding: 0 8px;
    }

    .map-tag-options {
        position: absolute;
        top: calc(100% + 6px);
        left: auto;
        right: 0;
        width: max-content;
        min-width: 0;
        max-width: min(92vw, 300px);
        transform-origin: top right;
        background: rgba(255, 255, 255, 0.42) !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }
}

/* ---------------------------------------------------------
   Responsive Layout: <= 480px
   --------------------------------------------------------- */
@media (max-width: 480px) {
    #map-header {
        grid-template-columns: minmax(130px, 1fr) auto auto;
    }

    .map-tag-options {
        max-width: min(92vw, 260px);
    }
}
