/* eew.css — Earthquake Report Page */

/* === Layout === */
body {
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation Container - Override home.css */
.nav-container {
    display: flex !important;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
}

.brand {
    flex-shrink: 0;
}

#refreshBtn {
    flex-shrink: 0;
}

.nav-center {
    flex: 1;
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.refresh-btn {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    color: #a1a1aa;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.refresh-btn:hover { background: rgba(239,68,68,0.15); color: #f87171; border-color: rgba(239,68,68,0.3); }

.refresh-btn.spinning i { animation: spin 0.8s linear infinite; }

/* Navigation Right Section */
.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.credit-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    color: #60a5fa;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.credit-link:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.credit-link i {
    font-size: 0.9rem;
}

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

/* Two-column main layout */
.eew-layout {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

/* === Sidebar === */
.eq-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: rgba(7, 9, 18, 0.97);
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 300;
}

@media (max-width: 767px) {
    .eq-sidebar {
        position: fixed;
        inset: 0;
        width: 300px;
        max-width: 85vw;
        z-index: 800;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 28px rgba(0,0,0,0.6);
    }

    .eq-sidebar.is-open {
        transform: translateX(0);
    }
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 750;
    backdrop-filter: blur(2px);
}

.sidebar-backdrop.is-active { display: block; }

.sidebar-header {
    padding: 14px 14px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.type-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.type-btn {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: #71717a;
    padding: 7px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.type-btn.active {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.35);
    color: #fca5a5;
}

.type-btn:hover:not(.active) {
    background: rgba(255,255,255,0.08);
    color: #d4d4d8;
}

.list-meta {
    font-size: 0.68rem;
    color: #3f3f46;
    margin: 0;
}

/* Earthquake list */
.eq-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.eq-list::-webkit-scrollbar { width: 4px; }
.eq-list::-webkit-scrollbar-track { background: transparent; }
.eq-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.eq-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.15s;
}

.eq-item:hover { background: rgba(255,255,255,0.04); }

.eq-item.active {
    background: rgba(239,68,68,0.08);
    border-left: 2px solid rgba(239,68,68,0.6);
    padding-left: 12px;
}

.eq-item:focus {
    outline: 1px solid rgba(239,68,68,0.4);
    outline-offset: -1px;
}

.eq-mag-badge {
    font-size: 0.78rem;
    font-weight: 800;
    padding: 4px 6px;
    border-radius: 7px;
    border: 1px solid;
    flex-shrink: 0;
    min-width: 44px;
    text-align: center;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.eq-item-body {
    flex: 1;
    min-width: 0;
}

.eq-item-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-bottom: 2px;
}

.eq-item-meta {
    font-size: 0.68rem;
    color: #52525b;
    display: flex;
    gap: 8px;
}

.eq-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.eq-intensity-chip {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    letter-spacing: 0.03em;
}

.eq-ago {
    font-size: 0.63rem;
    color: #3f3f46;
}

.eq-empty {
    padding: 40px 20px;
    text-align: center;
    color: #3f3f46;
    font-size: 0.85rem;
}

/* === Map Area === */
.map-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

#eewMap {
    width: 100%;
    height: 100%;
    background: #0a0f1e;
}

/* Mobile sidebar toggle button */
.sidebar-toggle {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 500;
    background: rgba(7, 9, 18, 0.9);
    border: 1px solid rgba(255,255,255,0.1);
    color: #a1a1aa;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,0.1); }

@media (max-width: 767px) {
    .sidebar-toggle { display: flex; }
}

/* === Loading Overlay === */
.map-loading {
    position: absolute;
    inset: 0;
    background: rgba(9, 9, 11, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 900;
    color: #a1a1aa;
    font-size: 0.9rem;
}

.loader {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255,255,255,0.06);
    border-top-color: #ef4444;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

/* === Detail Panel === */
.detail-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    overflow-y: auto;
    background: rgba(8, 8, 14, 0.97);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-top: 1px solid rgba(255,255,255,0.07);
    border-radius: 20px 20px 0 0;
    padding: 0 16px 28px;
    z-index: 600;
    transform: translateY(105%);
    transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.detail-panel.is-open { transform: translateY(0); }

@media (min-width: 768px) {
    .detail-panel {
        top: 0;
        bottom: auto;
        left: auto;
        right: 0;
        width: 380px;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border-top: none;
        border-left: 1px solid rgba(255,255,255,0.07);
        transform: translateX(105%);
        padding-bottom: 32px;
    }

    .detail-panel.is-open { transform: translateX(0); }
}

.panel-drag-handle {
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin: 10px auto 0;
}

@media (min-width: 768px) { .panel-drag-handle { display: none; } }

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 0 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    background: rgba(8, 8, 14, 0.99);
    z-index: 1;
}

.ph-toprow {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.ph-no {
    font-size: 0.72rem;
    color: #52525b;
    font-family: monospace;
}

.ph-color {
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.ph-left h2 {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    color: #f1f5f9;
    margin-bottom: 3px;
}

.ph-time {
    font-size: 0.72rem;
    color: #52525b;
    margin: 0;
}

.close-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.09);
    color: #71717a;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    transition: all 0.2s;
    margin-top: 2px;
}

.close-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Panel body */
.panel-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.detail-top-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-mag-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.detail-mag-badge {
    font-size: 1.6rem;
    font-weight: 800;
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid;
    letter-spacing: 0.02em;
    line-height: 1;
}

.detail-mag-label {
    font-size: 0.62rem;
    color: #52525b;
}

.detail-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-stat-row {
    font-size: 0.8rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-stat-row i { color: #52525b; font-size: 0.85rem; }

.detail-maxint {
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
    text-align: center;
    letter-spacing: 0.03em;
}

.detail-report-text {
    font-size: 0.82rem;
    color: #71717a;
    line-height: 1.6;
    margin: 0;
}

.section-label {
    font-size: 0.72rem;
    color: #3f3f46;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -4px;
}

.section-label i { font-size: 0.8rem; }

/* Intensity Table */
.intensity-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.intensity-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
}

.intensity-chip {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 5px;
    color: #fff;
    flex-shrink: 0;
    min-width: 46px;
    text-align: center;
}

.intensity-county {
    font-weight: 600;
    color: #e2e8f0;
    min-width: 60px;
    flex-shrink: 0;
}

.intensity-desc {
    color: #52525b;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Shakemap image */
.shakemap-wrap {
    border-radius: 12px;
    overflow: hidden;
}

.shakemap-img {
    width: 100%;
    display: block;
    border-radius: 12px;
}

/* CWA link */
.cwa-ext-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #60a5fa;
    text-decoration: none;
    padding: 8px 14px;
    border: 1px solid rgba(96,165,250,0.25);
    border-radius: 8px;
    background: rgba(96,165,250,0.08);
    transition: all 0.2s;
    margin-top: 4px;
}

.cwa-ext-link:hover {
    background: rgba(96,165,250,0.15);
    border-color: rgba(96,165,250,0.4);
    color: #93c5fd;
}

/* Map overlay credit */
.map-credit {
    position: absolute;
    bottom: 18px;
    right: 16px;
    font-size: 0.65rem;
    color: #3f3f46;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    pointer-events: none;
}

@media (min-width: 768px) {
    .map-credit { right: 396px; }
}

/* Leaflet custom tooltip */
.eq-tooltip {
    background: rgba(9, 14, 30, 0.9) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    color: #e2e8f0 !important;
    font-size: 0.78rem !important;
    font-family: 'Noto Sans TC', 'Inter', sans-serif !important;
    padding: 5px 10px !important;
    border-radius: 7px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
    white-space: nowrap;
}

.eq-tooltip::before { display: none !important; }

/* Leaflet overrides */
.leaflet-container { background: #0a0f1e; font-family: 'Noto Sans TC', 'Inter', sans-serif; }

.leaflet-control-attribution {
    background: rgba(0,0,0,0.5) !important;
    color: #27272a !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a { color: #3f3f46 !important; }

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    background: rgba(9, 14, 30, 0.92) !important;
    border-color: rgba(255,255,255,0.08) !important;
    color: #71717a !important;
    font-size: 16px !important;
    line-height: 26px !important;
    width: 30px !important;
    height: 30px !important;
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
    background: rgba(239,68,68,0.18) !important;
    color: #fca5a5 !important;
}

.leaflet-bar {
    border: 1px solid rgba(255,255,255,0.08) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4) !important;
}

/* Error state */
.map-error { text-align: center; }
.map-error i { font-size: 2.5rem; color: #f87171; display: block; margin-bottom: 12px; }
.map-error p { color: #f87171; margin-bottom: 6px; }
.map-error small { font-size: 0.78rem; color: #3f3f46; }

.map-retry-btn {
    margin-top: 14px;
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: #f87171;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.map-retry-btn:hover { background: rgba(239,68,68,0.2); }
