/* ─── Variables ─── */
:root {
    --bg:         #080d1a;
    --card:       #0e1628;
    --border:     rgba(255,255,255,0.07);
    --accent:     #00d4aa;
    --accent-dim: rgba(0, 212, 170, 0.2);
    --text:       #e8eaf0;
    --muted:      rgba(232, 234, 240, 0.45);
    --high:       #ff6b6b;
    --cond-green: #00d4aa;
    --cond-amber: #f5a623;
    --cond-red:   #ff4757;
    --low:        #74b9ff;
    --water-top:  #00b896;
    --water-bot:  #003f60;
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

/* ─── Header ─── */
header {
    background: linear-gradient(160deg, #06101f 0%, #0a1830 100%);
    padding: 48px 24px 0;
    position: relative;
}

.header-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-bottom: 40px;
}

.subtitle {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

.header-meta {
    font-size: 0.78rem;
    color: var(--muted);
    padding-bottom: 6px;
}

.wave-divider {
    position: relative;
    height: 70px;
    margin: 0 -24px;
    overflow: hidden;
}

.wave-divider svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ─── Main ─── */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

/* ─── API message ─── */
.api-message {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.api-message.hidden { display: none; }

.api-message.error {
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: #ff8f8f;
}

.api-message.info {
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid var(--accent-dim);
    color: var(--accent);
}

/* ─── Grid ─── */
.grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 820px) {
    .grid { grid-template-columns: 1fr; }
}

/* ─── Cards ─── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
}

.card h2 {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 24px;
}

/* ─── Gauge ─── */
.gauge-wrap {
    display: flex;
    gap: 14px;
    align-items: stretch;
    margin-bottom: 28px;
}

.gauge {
    flex: 1;
    position: relative;
    height: 260px;
    border-radius: 14px;
    border: 1px solid var(--accent-dim);
    overflow: hidden;
    background: rgba(0, 20, 40, 0.6);
}

.water-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%; /* set dynamically by JS */
    background: linear-gradient(to bottom, var(--water-top), var(--water-bot));
    transition: height 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.wave-surface {
    position: absolute;
    top: -22px;
    left: 0;
    width: 200%;
    height: 42px;
    animation: wave-slide 3.5s linear infinite;
}

.wave-svg {
    width: 100%;
    height: 100%;
}

@keyframes wave-slide {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.gauge-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.gauge-value {
    display: flex;
    align-items: baseline;
    gap: 3px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.gauge-value span:first-child {
    font-size: 2.6rem;
    font-weight: 700;
    color: #fff;
}

.gauge-unit {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
}

.tide-direction {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 4px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.tide-direction.rising  { color: #00d4aa; }
.tide-direction.falling { color: #74b9ff; }

/* ─── Scale ─── */
.scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 0 2px;
    font-size: 0.72rem;
    color: var(--muted);
    height: 260px;
}

/* ─── Next Tide Cards ─── */
.next-tides {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.next-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.high-dot { background: var(--high); }
.low-dot  { background: var(--low); }

.next-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 4px;
}

.next-time {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.next-height {
    font-size: 0.82rem;
    color: var(--muted);
}

/* ─── Chart ─── */
.chart-card {
    display: flex;
    flex-direction: column;
}

.chart-container {
    position: relative;
    height: 320px;
    flex: 1;
}

.legend {
    display: flex;
    gap: 20px;
    margin-top: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--muted);
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

/* ─── Tab Navigation ─── */
.tab-nav {
    display: flex;
    background: #06101f;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.tab-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.tab-link:hover  { color: var(--text); }
.tab-link.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Mobile: fixed bottom nav */
@media (max-width: 820px) {
    .tab-nav {
        position: fixed;
        bottom: 0; left: 0; right: 0; top: auto;
        border-top: 1px solid var(--border);
        border-bottom: none;
        padding: 0;
        justify-content: space-around;
        z-index: 200;
    }
    .tab-link {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        padding: 10px 4px;
        font-size: 0.72rem;
        gap: 3px;
        min-height: 56px;
    }
    main { padding-bottom: 80px; }
}

/* ─── Activity page layout ─── */
.activity-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    height: calc(100vh - 120px);
    gap: 0;
}

@media (max-width: 820px) {
    .activity-layout {
        display: block;
        height: auto;
    }
}

/* ─── Map ─── */
#map {
    height: 100%;
    min-height: 300px;
    z-index: 1;
}

@media (max-width: 820px) {
    #map { height: 55vh; }
}

.map-marker {
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.15s;
}
.map-marker:hover { transform: scale(1.2); }
.map-marker.cond-green { background: var(--cond-green); }
.map-marker.cond-amber { background: var(--cond-amber); }
.map-marker.cond-red   { background: var(--cond-red);   }

/* ─── Map popup (dark theme) ─── */
.dark-popup .leaflet-popup-content-wrapper {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.dark-popup .leaflet-popup-tip { background: var(--card); }
.dark-popup .leaflet-popup-content { margin: 10px 14px; }
.popup-name { font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.popup-sub-areas { margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.popup-sub-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.popup-sub-name { font-size: 0.78rem; color: var(--muted); flex: 1; }
.popup-window { margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 6px; font-size: 0.78rem; color: var(--muted); }

/* ─── Side panel ─── */
#site-panel {
    background: var(--card);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 0;
}

@media (max-width: 820px) {
    #site-panel {
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 45vh;
        overflow-y: auto;
    }
}

.panel-header {
    padding: 16px 16px 0;
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 10;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.panel-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 10px;
}

.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}
.filter-btn:hover         { color: var(--text); border-color: rgba(255,255,255,0.2); }
.filter-btn.active        { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.filter-btn[data-filter="green"].active { background: rgba(0,212,170,0.15); color: var(--cond-green); border-color: var(--cond-green); }
.filter-btn[data-filter="amber"].active { background: rgba(245,166,35,0.15); color: var(--cond-amber); border-color: var(--cond-amber); }
.filter-btn[data-filter="red"].active   { background: rgba(255,71,87,0.15);  color: var(--cond-red);   border-color: var(--cond-red);   }

/* ─── Site cards ─── */
.site-card {
    border-bottom: 1px solid var(--border);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    gap: 8px;
    transition: background 0.1s;
}
.site-header:hover { background: rgba(255,255,255,0.03); }
.site-header[role="button"] { cursor: pointer; }

.site-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.expand-icon { color: var(--muted); font-size: 0.7rem; flex-shrink: 0; }

.site-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.site-detail {
    padding: 0 16px 16px;
    background: rgba(0,0,0,0.15);
}

/* ─── Condition badges ─── */
.cond-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.cond-green { background: rgba(0,212,170,0.15); color: var(--cond-green); }
.cond-amber { background: rgba(245,166,35,0.15); color: var(--cond-amber); }
.cond-red   { background: rgba(255,71,87,0.15);  color: var(--cond-red);   }

/* ─── Status badges ─── */
.status-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
}
.status-default  { color: var(--muted);      background: rgba(255,255,255,0.06); }
.status-custom   { color: var(--cond-amber); background: rgba(245,166,35,0.12);  }
.status-verified { color: var(--cond-green); background: rgba(0,212,170,0.12);   }

/* ─── Sub-areas ─── */
.sub-areas { margin: 8px 0; }

.sub-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    gap: 8px;
}
.sub-row:last-child { border-bottom: none; }

.sub-name {
    font-size: 0.82rem;
    color: var(--muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-right {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
    align-items: center;
}

/* ─── Windows ─── */
.windows-section { margin-top: 12px; }

.windows-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 6px;
}

.window-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.82rem;
}
.window-row:last-child { border-bottom: none; }
.window-time { color: var(--text); }
.window-dur  { color: var(--accent); font-weight: 600; }
.no-windows  { font-size: 0.8rem; color: var(--muted); font-style: italic; }

/* ─── Feedback form ─── */
.feedback-toggle {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s;
}
.feedback-toggle:hover { color: var(--accent); }

.feedback-form { margin-top: 10px; }
.feedback-form.hidden { display: none; }

.feedback-form form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feedback-form label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.78rem;
    color: var(--muted);
}

.feedback-form input,
.feedback-form textarea,
.feedback-form select {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 7px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    width: 100%;
    min-font-size: 16px; /* prevent iOS zoom */
}
.feedback-form textarea { resize: vertical; min-height: 70px; }

.btn-submit {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    align-self: flex-start;
}
.btn-submit:hover { background: rgba(0,212,170,0.3); }

.feedback-thanks { font-size: 0.82rem; color: var(--cond-green); }

/* ─── Bottom sheet (mobile) ─── */
#bottom-sheet {
    position: fixed;
    bottom: 56px; /* above mobile tab bar */
    left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 150;
    max-height: 70vh;
    overflow-y: auto;
}
#bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
    width: 40px; height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 10px auto 0;
}

.sheet-content { padding: 12px 20px 24px; }

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.sheet-header h3 { font-size: 1.05rem; font-weight: 700; }
.sheet-close {
    background: none; border: none; color: var(--muted);
    font-size: 1.1rem; cursor: pointer; padding: 4px;
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
}

.sheet-badges { display: flex; gap: 8px; margin-bottom: 14px; }

/* ─── Admin page ─── */
.admin-section { margin-bottom: 32px; }
.admin-section h3 {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--muted); margin-bottom: 16px;
    border-bottom: 1px solid var(--border); padding-bottom: 8px;
}

.admin-site-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.admin-site-name { font-size: 0.88rem; font-weight: 500; }
.admin-sub-name  { font-size: 0.82rem; color: var(--muted); padding-left: 16px; }

.admin-input {
    width: 72px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 5px 8px;
    font-size: 0.85rem;
    text-align: right;
}

.admin-verified {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    color: var(--muted);
    cursor: pointer;
    min-height: 44px;
}
.admin-verified input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.btn-save, .btn-reset {
    padding: 10px 20px; border-radius: 8px; font-size: 0.88rem;
    font-weight: 600; cursor: pointer; border: 1px solid;
}
.btn-save  { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.btn-reset { background: transparent; color: var(--muted); border-color: var(--border); margin-left: 10px; }
.btn-save:hover  { background: rgba(0,212,170,0.3); }
.btn-reset:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }

/* ─── Footer ─── */
footer {
    text-align: center;
    padding: 24px;
    font-size: 0.78rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 24px;
    justify-content: center;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover { text-decoration: underline; }

.disclaimer {
    max-width: 680px;
    font-size: 0.72rem;
    color: rgba(232,234,240,0.3);
    line-height: 1.6;
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 8px;
}
