/* airspace/assets/css/style.css
   Dark Glassmorphism - consistent with NOTAM tool */

:root {
    --bg-dark: #1a2332;
    --primary: #FEEEA5;
    --accent: #f0b90b;
    --text-white: #FFFFFF;
    --text-gray: rgba(255, 255, 255, 0.7);
    --glass-bg: rgba(30, 40, 55, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --blur: blur(12px);
    --radius: 12px;
    --red-zone: #e74c3c;
    --yellow-zone: #f0b90b;
    --green-zone: #2ecc71;
    --header-height: 54px;
    --search-height: 50px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-white);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* --- Header --- */
.app-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    padding: 0 12px;
    background: rgba(55, 58, 70, 0.88);
    backdrop-filter: var(--blur);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1100;
}

.header-logo {
    display: flex;
    align-items: center;
    padding: 4px 8px 4px 0;
    flex-shrink: 0;
}
.header-logo img {
    height: 22px;
    opacity: 0.85;
    transition: opacity 0.2s;
}
.header-logo:hover img { opacity: 1; }

.header-title {
    flex: 1;
    font-size: 1.05em;
    font-weight: 700;
    margin-left: 4px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 4px; }
.header-log-btn {
    background: linear-gradient(135deg, #FEEEA5, #F6A170);
    color: #1a2332;
    border: none;                 /* <button> 預設邊框 reset（與 <a> 更新紀錄一致） */
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    font-family: inherit;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8em;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
}
.header-log-btn:hover { opacity: 0.88; }
.header-btn {
    background: none;
    border: none;
    color: var(--text-gray);
    font-size: 1.3em;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: 0.2s;
}
.header-btn:hover { color: var(--primary); background: rgba(255,255,255,0.05); }

/* --- Search Bar --- */
#search-bar {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    z-index: 1050;
    padding: 8px 12px;
    background: rgba(26, 35, 50, 0.9);
    backdrop-filter: var(--blur);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.search-inner {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 0 12px;
    height: 42px;
    transition: border-color 0.2s;
}
.search-inner:focus-within {
    border-color: var(--primary);
}

.search-icon {
    color: var(--text-gray);
    font-size: 1.2em;
    margin-right: 8px;
    flex-shrink: 0;
}

#coord-input {
    flex: 1;
    background: none;
    border: none;
    color: #fff;
    font-size: 0.95em;
    outline: none;
    font-family: 'Noto Sans TC', sans-serif;
    min-width: 0;
}
#coord-input::placeholder { color: rgba(255,255,255,0.35); }

.search-btn {
    background: linear-gradient(135deg, #FEEEA5, #F6A170);
    color: #1a2332;
    border: none;
    border-radius: 7px;
    padding: 6px 14px;
    font-size: 0.85em;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: 0.2s;
    font-family: 'Noto Sans TC', sans-serif;
}
.search-btn:hover { transform: scale(1.03); }

/* --- Map --- */
#map {
    position: fixed;
    top: calc(var(--header-height) + var(--search-height) + 8px);
    left: 0; right: 0;
    bottom: 0;
    z-index: 1;
}

.dark-mode-filter {
    filter: invert(100%) hue-rotate(180deg) brightness(85%) contrast(90%);
}

/* --- Loading --- */
.loading-indicator {
    position: fixed;
    top: calc(var(--header-height) + var(--search-height) + 24px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(26, 35, 50, 0.92);
    backdrop-filter: var(--blur);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    color: var(--text-gray);
    white-space: nowrap;
}

.loading-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Legend --- */
.map-legend {
    position: fixed;
    bottom: 16px;
    left: 12px;
    z-index: 1000;
    background: rgba(26, 35, 50, 0.9);
    backdrop-filter: var(--blur);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8em;
    transition: bottom 0.3s;
}
.legend-item { display: flex; align-items: center; gap: 8px; color: var(--text-gray); }
.legend-dot {
    width: 12px; height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}
.legend-dot.red { background: var(--red-zone); }
.legend-dot.yellow { background: var(--yellow-zone); }
.legend-dot.green { background: var(--green-zone); }
.legend-dot.gray { background: #8e8e93; }

/* --- Result Panel (bottom sheet) --- */
.result-panel {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    z-index: 1200;
    background: rgba(26, 35, 50, 0.97);
    backdrop-filter: var(--blur);
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 70vh;
    max-height: 70dvh;
    display: flex;
    flex-direction: column;
}

.result-panel.peek {
    transform: translateY(0);
}

.result-panel.expanded {
    transform: translateY(0);
}

.result-panel.collapsed {
    transform: translateY(100%);
}

/* Drag handle */
.panel-drag-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px;
    cursor: grab;
    flex-shrink: 0;
}
.drag-bar {
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.25);
    border-radius: 2px;
}

/* Panel header */
.panel-header {
    padding: 4px 16px 12px;
    flex-shrink: 0;
}

.panel-summary {
    font-size: 0.95em;
    font-weight: 700;
}

.verdict-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1em;
    margin-bottom: 6px;
}
.verdict-badge.red {
    background: rgba(231, 76, 60, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(231, 76, 60, 0.3);
}
.verdict-badge.yellow {
    background: rgba(240, 185, 11, 0.2);
    color: #f0b90b;
    border: 1px solid rgba(240, 185, 11, 0.3);
}
.verdict-badge.green {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
}
.verdict-badge.gray {
    background: rgba(142, 142, 147, 0.2);
    color: #aaa;
    border: 1px solid rgba(142, 142, 147, 0.3);
}

.zone-count {
    font-size: 0.85em;
    color: var(--text-gray);
    font-weight: 400;
    margin-top: 4px;
}

/* Panel body - scrollable */
.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 24px;
    -webkit-overflow-scrolling: touch;
}

/* Zone card */
.zone-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: 0.2s;
    cursor: pointer;
}
.zone-card:hover {
    background: rgba(255, 255, 255, 0.07);
}
.zone-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(254,238,165, 0.15);
}

.zone-card-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    gap: 10px;
}

.zone-color-tag {
    width: 6px;
    border-radius: 3px;
    align-self: stretch;
    flex-shrink: 0;
}
.zone-color-tag.red { background: var(--red-zone); }
.zone-color-tag.yellow { background: var(--yellow-zone); }
.zone-color-tag.gray { background: #8e8e93; }

.zone-card-title {
    flex: 1;
    min-width: 0;
}
.zone-card-title h4 {
    font-size: 0.92em;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}
.zone-card-title span {
    font-size: 0.78em;
    color: var(--text-gray);
}

.zone-card-chevron {
    color: var(--text-gray);
    font-size: 1.2em;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.zone-card.open .zone-card-chevron {
    transform: rotate(180deg);
}

/* Zone card detail (collapsed by default) */
.zone-card-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.zone-card.open .zone-card-detail {
    max-height: 500px;
}

.zone-detail-inner {
    padding: 0 14px 14px;
    user-select: text;
    -webkit-user-select: text;
    cursor: auto;
}

.zone-info-row {
    display: flex;
    gap: 8px;
    padding: 5px 0;
    font-size: 0.83em;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.zone-info-row:last-child { border-bottom: none; }
.zone-info-label {
    color: rgba(255,255,255,0.45);
    flex-shrink: 0;
    min-width: 56px;
}
.zone-info-value {
    color: #ddd;
    word-break: break-word;
    line-height: 1.4;
    user-select: text;
    -webkit-user-select: text;
}

a.zone-link {
    color: #90CAF9;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
a.zone-link:hover {
    color: #fff;
}

/* --- Click marker pulse --- */
.click-marker {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 0 rgba(254,238,165, 0.5);
    animation: pulse-ring 1.5s ease-out infinite;
}
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(254,238,165, 0.5); }
    100% { box-shadow: 0 0 0 16px rgba(254,238,165, 0); }
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
    background: rgba(10, 16, 26, 0.88) !important;
    color: #fff !important;
    border-radius: 10px !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-tip { background: rgba(10, 16, 26, 0.88) !important; }
.leaflet-popup-content { font-family: 'Noto Sans TC', sans-serif !important; font-size: 0.9em !important; }

/* --- Desktop layout --- */
@media (min-width: 769px) {
    .result-panel {
        left: auto;
        right: 0;
        top: calc(var(--header-height) + var(--search-height) + 8px);
        bottom: 0;
        width: 380px;
        border-radius: 0;
        border-top: none;
        border-left: 1px solid rgba(255,255,255,0.1);
        max-height: none;
        transform: translateX(100%);
    }
    .result-panel.peek,
    .result-panel.expanded {
        transform: translateX(0);
    }
    .result-panel.collapsed {
        transform: translateX(100%);
    }
    .panel-drag-handle { display: none; }

    .map-legend {
        bottom: 16px;
        left: 16px;
    }

    #map {
        right: 0;
    }
    #map.panel-open {
        right: 380px;
    }
}

/* --- Mobile tweaks --- */
@media (max-width: 768px) {
    .map-legend {
        display: none;
    }

    /* 讓底部面板避開 tool-nav (52px) + iOS safe area */
    .result-panel {
        bottom: calc(52px + env(safe-area-inset-bottom, 0px));
        max-height: calc(100dvh - var(--header-height) - var(--search-height) - 60px);
    }
}

/* --- 未來空域 --- */
/* 「未來空域」按鈕沿用 .header-log-btn 樣式（與「更新紀錄」一致），不另加邊框/狀態裝飾 */

/* Leaflet 多邊形脈動邊框（SVG path，由 app.js className 套用）：明顯呼吸（線寬+填色） */
.overlay-pulse {
    animation: overlay-pulse 1.4s ease-in-out infinite;
}
@keyframes overlay-pulse {
    0%, 100% { stroke-width: 2; stroke-opacity: 1;   fill-opacity: 0.15; }
    50%      { stroke-width: 7; stroke-opacity: 0.45; fill-opacity: 0.45; }
}

/* 結果卡：未來空域醒目標示（藍色，避免與黃區限航區混淆） */
.zone-card.overlay-card {
    border-color: rgba(77, 166, 255, 0.55);
    box-shadow: 0 0 10px rgba(77, 166, 255, 0.15);
}
.future-badge {
    display: inline-block;
    background: linear-gradient(135deg, #6fb8ff, #4DA6FF);
    color: #0a2540;
    font-size: 0.72em;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    vertical-align: middle;
}
