/* ===== Airspace Planner — DRONESHOT.TW =====
   沿用 eaip-map 工具頁模式：tokens.css 為色彩來源，本檔僅佈局與元件組裝 */

:root {
    --header-h: 54px;
    --panel-w: 340px;
}

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

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

/* ===== Header（同 eaip-map .app-header 模式）===== */
.app-header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--glass-bg);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center;
    padding: 0 16px; z-index: 1100; gap: 12px;
}
.header-logo img { height: 30px; display: block; }
.header-title { flex: 1; display: flex; flex-direction: column; justify-content: center; line-height: 1.15; min-width: 0; }
.header-main { font-size: 14px; font-weight: 700; white-space: nowrap; }
.header-sub { font-size: 10px; font-weight: 400; color: var(--text-secondary); white-space: nowrap; }
.header-actions { display: flex; gap: 6px; }
.header-btn {
    background: var(--surface); border: none; color: var(--text-white);
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 20px; transition: background .2s;
    text-decoration: none;   /* 用於 <a> 返回鈕時去除連結底線 */
}
.header-btn:hover { background: var(--glass-border); }

/* ===== Map ===== */
#map {
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0; bottom: 0;
    z-index: 1;
}

/* ===== Control Panel ===== */
.ctrl-panel {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    left: 12px;
    width: var(--panel-w);
    max-height: calc(100vh - var(--header-h) - 48px);
    background: var(--glass-bg);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    z-index: 1000;
    display: flex; flex-direction: column;
    overflow: hidden;
    transition: transform .25s ease, opacity .2s;
}
.ctrl-panel.collapsed { transform: translateX(calc(-100% - 16px)); opacity: 0; pointer-events: none; }
.ctrl-grab { display: none; }
.ctrl-body { overflow-y: auto; padding: 16px; }

.ctrl-section { margin-bottom: 16px; }
.ctrl-heading {
    font-size: 12px; font-weight: 700; color: var(--text-secondary);
    letter-spacing: .05em; margin-bottom: 8px;
}

/* 中心點 */
.center-row { display: flex; gap: 8px; }
.center-row input {
    flex: 1; min-width: 0;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-white); font-size: 13px; font-family: inherit;
    padding: 8px 10px; outline: none;
}
.center-row input:focus { border-color: var(--primary); }
.center-row input::placeholder { color: var(--text-decorative); }
.center-hint { font-size: 12px; color: var(--text-secondary); margin-top: 8px; line-height: 1.5; word-break: break-all; }

/* 參數 */
.param-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 8px;
}
.param-row label { font-size: 13px; color: var(--text-white-80); display: flex; flex-direction: column; }
.param-unit { font-size: 10px; color: var(--text-secondary); }
.param-row input {
    width: 96px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-white); font-size: 14px; font-family: inherit;
    padding: 6px 8px; outline: none; text-align: right;
}
.param-row input:focus { border-color: var(--primary); }
.chk-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-secondary);
    padding: 4px 0; cursor: pointer;
}
.chk-row input { accent-color: var(--primary); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }

/* 圖層 */
.layer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.layer-toggle {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 0; font-size: 12px; cursor: pointer;
    color: var(--text-secondary); white-space: nowrap;
}
.layer-toggle input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
.layer-color { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.layer-color-ring { background: none !important; border-radius: 50%; }

/* 計算按鈕 */
.compute-btn {
    width: 100%;
    background: var(--primary); color: var(--on-accent);
    border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 700; font-family: inherit;
    padding: 10px 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: filter .15s;
}
.compute-btn:hover:not(:disabled) { filter: brightness(1.08); }
.compute-btn:disabled { opacity: .45; cursor: not-allowed; }

.status-msg { font-size: 12px; line-height: 1.5; margin-top: 8px; color: var(--text-secondary); min-height: 1em; }
.status-msg.err { color: var(--status-danger); }
.status-msg.ok { color: var(--text-white-80); }

/* ===== Result ===== */
.result { margin-top: 16px; border-top: 1px solid var(--glass-border); padding-top: 16px; }
.result.hidden { display: none; }
.result-stats { font-size: 13px; color: var(--text-white-80); line-height: 1.7; margin-bottom: 8px; }
.result-stats b { color: var(--primary); font-weight: 700; }

.vtable-wrap { overflow-x: auto; margin-bottom: 8px; }
.vtable { width: 100%; border-collapse: collapse; font-size: 11px; }
.vtable th {
    text-align: left; color: var(--text-secondary); font-weight: 500;
    padding: 4px 6px; border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}
.vtable td {
    padding: 4px 6px; color: var(--text-white-80);
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap; font-variant-numeric: tabular-nums;
}
.vtable td.lim { color: var(--text-secondary); }

.result-actions { display: flex; gap: 8px; margin-top: 8px; }
.mini-btn {
    background: var(--surface); color: var(--text-white);
    border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 500; font-family: inherit;
    padding: 7px 12px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px;
    transition: background .15s;
}
.mini-btn:hover { background: var(--glass-border); }
.mini-btn-primary { background: var(--primary); color: var(--on-accent); border-color: transparent; font-weight: 700; }
.mini-btn-primary:hover { background: var(--primary); filter: brightness(1.08); }

/* ===== Footer ===== */
.map-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-dark);
    font-size: 9px; color: var(--text-secondary);
    text-align: center; padding: 3px 8px;
    z-index: 999;
}

/* ===== Leaflet ===== */
.leaflet-control-zoom { margin-top: 10px !important; }
.leaflet-control-zoom a {
    background: var(--glass-bg) !important;
    color: var(--text-white) !important;
    border-color: var(--glass-border) !important;
}
.center-marker {
    background: var(--primary);
    width: 16px; height: 16px; border-radius: 50%;
    border: 3px solid var(--text-white);
}
/* 可拖曳頂點：28px 觸控熱區、18px 視覺圓點含編號 */
.vertex-marker {
    display: flex; align-items: center; justify-content: center;
    cursor: grab;
}
.vertex-marker:active { cursor: grabbing; }
.vertex-marker span {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--primary); color: var(--on-accent);
    border: 2px solid var(--text-white);
    font-size: 10px; font-weight: 700; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--glass-shadow);
}
.airspace-popup { font-size: 12px; line-height: 1.6; }
.airspace-popup .popup-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }

/* ===== Mobile: bottom sheet ===== */
@media (max-width: 640px) {
    .ctrl-panel {
        top: auto; left: 0; right: 0; bottom: 0;
        width: 100%;
        max-height: 62vh;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        border-left: none; border-right: none; border-bottom: none;
    }
    .ctrl-panel.collapsed {
        transform: translateY(calc(100% - 40px));
        opacity: 1; pointer-events: auto;
    }
    .ctrl-grab {
        display: block; flex-shrink: 0;
        padding: 18px 0 6px; cursor: grab; position: relative;
    }
    .ctrl-grab::before {
        content: ''; position: absolute; top: 8px; left: 50%;
        transform: translateX(-50%);
        width: 44px; height: 5px; border-radius: 3px;
        background: var(--glass-border);
    }
    .map-footer { display: none; }
    #map { bottom: 0; }
}
