/* ══════════════════════════════════════════════════
   Great Lakes Shipwreck Database — CesarOps
   ══════════════════════════════════════════════════ */

:root {
    --primary: #1e3c72;
    --primary-light: #2a5298;
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --bg-sidebar: #f0f2f5;
    --text: #333333;
    --text-muted: #666666;
    --accent: #2a5298;
    --accent-hover: #1e3c72;
    --found: #22c55e;
    --missing: #ef4444;
    --unknown: #a78bfa;
    --estimated: #f59e0b;
    --donate: #f97316;
    --border: #d1d5db;
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: grid;
    grid-template-columns: 340px 1fr;
    grid-template-rows: auto auto 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ── */
#header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    z-index: 1000;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon { font-size: 22px; }

.tagline {
    font-size: 12px;
    color: rgba(255,255,255,0.8);
    margin-left: 12px;
}

.tagline a { color: rgba(255,255,255,0.95); text-decoration: none; }
.tagline a:hover { text-decoration: underline; }

.header-right {
    display: flex;
    gap: 12px;
}

.stat-pill {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 13px;
    white-space: nowrap;
    color: white;
}

.stat-pill .stat-num { font-weight: 700; }
.stat-pill.found .stat-num { color: #86efac; }
.stat-pill.missing .stat-num { color: #fca5a5; }

/* ── Nav ── */
#site-nav {
    grid-column: 1 / -1;
    background: #333;
    padding: 0;
    text-align: center;
    z-index: 999;
}

#site-nav a {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    display: inline-block;
    transition: background 0.3s;
    font-size: 14px;
}

#site-nav a:hover { background: #555; }
#site-nav a.active { background: #555; font-weight: 600; }

/* ── Sidebar ── */
#sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 900;
}

.sidebar-section h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Search */
#search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus { border-color: var(--accent); }

#search-results {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}

.search-item {
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-item:hover { background: var(--bg-card); }
.search-item .date { color: var(--text-muted); font-size: 11px; }

/* Filters */
.filter-group {
    margin-bottom: 8px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.filter-group select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}

.filter-group input[type="checkbox"] {
    margin-right: 6px;
}

/* Legend */
.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot.found { background: var(--found); }
.dot.missing { background: var(--missing); }
.dot.unknown { background: var(--unknown); }
.dot.estimated { background: var(--estimated); border: 2px dashed #d97706; }

/* About */
.about p { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; line-height: 1.5; }
.about a { color: var(--accent); text-decoration: none; }
.about a:hover { text-decoration: underline; }
.updated { font-size: 11px; font-style: italic; }

/* Promo Cards */
.promo-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.promo-card h3 { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 16px; margin-bottom: 6px; }
.promo-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px; }
.promo-card ul { list-style: none; padding: 0; margin-bottom: 10px; }
.promo-card li { font-size: 13px; color: var(--text-muted); padding: 2px 0; }

.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover { opacity: 0.85; transform: translateY(-1px); }

.btn-donate { background: var(--donate); color: #fff; }
.btn-try { background: var(--accent); color: #fff; }

.sar-note {
    font-size: 11px !important;
    font-style: italic;
    margin-top: 8px !important;
}
.sar-note a { color: var(--accent); text-decoration: none; }

/* ── Map ── */
#map-container {
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text) !important;
    border-radius: var(--radius) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15) !important;
}

.leaflet-popup-tip { background: var(--bg-card) !important; }

.leaflet-popup-content {
    margin: 12px 16px !important;
    font-size: 13px !important;
    line-height: 1.6 !important;
}

.popup-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e3c72;
    margin-bottom: 4px;
}

.popup-date { color: var(--text-muted); margin-bottom: 8px; }

.popup-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.popup-status.found { background: rgba(34, 197, 94, 0.15); color: var(--found); }
.popup-status.missing { background: rgba(239, 68, 68, 0.15); color: var(--missing); }
.popup-status.unknown { background: rgba(167, 139, 250, 0.15); color: var(--unknown); }

.popup-meta { margin: 8px 0; }
.popup-meta div { margin-bottom: 3px; }
.popup-meta .label { color: var(--text-muted); }

.popup-articles { margin-top: 10px; }
.popup-articles h4 { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.popup-articles a {
    display: block;
    color: var(--accent);
    font-size: 12px;
    text-decoration: none;
    padding: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.popup-articles a:hover { text-decoration: underline; }

.popup-links { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.popup-links a {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    padding: 3px 10px;
    border: 1px solid var(--accent);
    border-radius: 4px;
}
.popup-links a:hover { background: rgba(42, 82, 152, 0.1); }

/* ── Detail Panel ── */
#detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 420px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    z-index: 1100;
    overflow-y: auto;
    padding: 20px;
    transition: transform 0.3s ease;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
}

#detail-panel.hidden { transform: translateX(100%); }

#detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

#detail-close:hover { color: var(--text); }

/* ── Loading ── */
#loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 9999;
    transition: opacity 0.4s;
}

#loading.done { opacity: 0; pointer-events: none; }

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading p { color: var(--text-muted); font-size: 14px; }

/* ── Cluster overrides ── */
.marker-cluster-small { background-color: rgba(42, 82, 152, 0.3); }
.marker-cluster-small div { background-color: rgba(42, 82, 152, 0.6); color: white; }
.marker-cluster-medium { background-color: rgba(30, 60, 114, 0.3); }
.marker-cluster-medium div { background-color: rgba(30, 60, 114, 0.6); color: white; }
.marker-cluster-large { background-color: rgba(30, 60, 114, 0.4); }
.marker-cluster-large div { background-color: rgba(30, 60, 114, 0.7); color: white; }

/* ── Responsive ── */
@media (max-width: 768px) {
    body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto 1fr;
    }

    #sidebar {
        max-height: 40vh;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    #detail-panel { width: 100%; }

    .header-right { display: none; }
}
