:root {
    --bg: #0a1628;
    --surface: #12233d;
    --surface2: #1a3050;
    --accent: #00b4d8;
    --accent2: #0077b6;
    --text: #e0e8f0;
    --text2: #8ea4bc;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --radius: 10px;
}

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

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

nav {
    background: var(--surface);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--surface2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav .logo {
    color: var(--accent);
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-link {
    color: var(--text2);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover { color: var(--text); }

.btn-nav {
    background: var(--accent2);
    color: white !important;
    padding: 0.4rem 1rem;
    border-radius: 6px;
}

.btn-nav:hover { background: var(--accent); }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.hero {
    text-align: center;
    padding: 2rem 0 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--text2);
    font-size: 1.1rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--surface2);
}

.card h2 {
    color: var(--accent);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field.full-width { grid-column: 1 / -1; }

label {
    font-size: 0.85rem;
    color: var(--text2);
    font-weight: 500;
}

input, select, textarea {
    background: var(--bg);
    border: 1px solid var(--surface2);
    color: var(--text);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 180, 216, 0.2);
}

button, .btn {
    background: var(--accent2);
    color: white;
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s;
}

button:hover, .btn:hover {
    background: var(--accent);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-accent {
    background: var(--accent);
}

.surfer-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.surfer-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--surface2);
    padding: 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s, box-shadow 0.2s;
}

.surfer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tag {
    display: inline-block;
    background: var(--accent2);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.surfer-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.surfer-header h1 {
    font-size: 1.8rem;
}

.tags { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.insights-bar {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
}

.stat { text-align: center; }

.stat-val {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text2);
    text-transform: uppercase;
}

.action-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

#train-status {
    color: var(--text2);
    font-size: 0.9rem;
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.session-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--accent2);
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.rating {
    font-weight: 700;
    color: var(--warning);
}

.predicted-rating {
    background: var(--accent);
    color: white;
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

.session-details {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.detail {
    color: var(--text2);
}

.session-conditions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    padding-top: 0.25rem;
}

.session-notes {
    margin-top: 0.5rem;
    color: var(--text2);
    font-style: italic;
    font-size: 0.9rem;
}

.tag-offshore { background: var(--success); }
.tag-onshore { background: var(--danger); }
.tag-cross-shore { background: var(--warning); color: #222; }

/* Spot search dropdown */
.spot-search-wrap { position: relative; }

.spot-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--surface2);
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.spot-item {
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--surface2);
}

.spot-item:hover { background: var(--surface2); }
.spot-item:last-child { border-bottom: none; }
.spot-item.spot-empty { color: var(--text2); cursor: default; font-style: italic; }

.spot-meta {
    color: var(--text2);
    font-size: 0.8rem;
}

.prediction-card {
    border-left-color: var(--accent);
}

.favorite-card { border-left-color: var(--warning) !important; }
.fav-star { color: var(--warning); margin-right: 0.25rem; }

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 4px;
}

/* Board recommendation */
.board-rec-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

.board-rec-details {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}

.btn-small {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover { opacity: 0.8; }

/* Conditions report */
.condition-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--surface2);
}

.condition-item:last-child { border-bottom: none; }

.condition-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.condition-value {
    color: var(--accent);
    font-weight: 600;
}

.condition-explain {
    color: var(--text2);
    font-size: 0.9rem;
    margin-top: 0.3rem;
    line-height: 1.5;
}

.edu-box {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    border-left: 3px solid var(--accent);
}

.edu-title {
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.edu-box p {
    color: var(--text2);
    line-height: 1.6;
    font-size: 0.9rem;
}

.rec-list {
    list-style: none;
    padding: 0;
    margin-top: 0.5rem;
}

.rec-list li {
    color: var(--text2);
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

.rec-list li::before {
    content: "→ ";
    color: var(--accent);
}

/* ── Bottom Tab Bar ──────────────────────────── */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--surface2);
    display: flex;
    justify-content: space-around;
    padding: 0.4rem 0 env(safe-area-inset-bottom, 0.4rem);
    z-index: 200;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.3rem 1rem;
    text-decoration: none;
    color: var(--text2);
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 8px;
    transition: color 0.2s;
}

.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--accent); }
.tab-icon { font-size: 1.3rem; }
.tab-label { text-transform: uppercase; letter-spacing: 0.5px; }

/* Add bottom padding to main so content isn't hidden behind tab bar */
main { padding-bottom: 5rem !important; }

/* ── Sub-tabs (inside spot detail) ──────────── */
.sub-tabs {
    display: flex;
    gap: 0;
    margin-top: 1rem;
    border-bottom: 2px solid var(--surface2);
}

.sub-tab {
    padding: 0.6rem 1.2rem;
    text-decoration: none;
    color: var(--text2);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

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

/* ── Breaks Grid ────────────────────────────── */
.breaks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.break-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    border-left: 3px solid var(--accent2);
    transition: transform 0.2s, border-color 0.2s;
}

.break-card:hover {
    transform: translateY(-2px);
    border-left-color: var(--accent);
}

/* ── Floating Chat Button ───────────────────── */
.chat-fab {
    position: fixed;
    bottom: 5rem;
    right: 1rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent2);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 201;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.chat-fab:hover { background: var(--accent); transform: scale(1.08); }

/* ── Chat Panel ─────────────────────────────── */
.chat-panel {
    position: fixed;
    bottom: 5rem;
    right: 1rem;
    width: 340px;
    max-height: 450px;
    background: var(--surface);
    border: 1px solid var(--surface2);
    border-radius: 12px;
    display: none;
    flex-direction: column;
    z-index: 300;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.chat-panel.open { display: flex; }

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--accent2);
    color: white;
    font-size: 0.95rem;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
}

.chat-close:hover { opacity: 0.8; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
}

.chat-msg {
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
}

.chat-msg.bot {
    background: var(--bg);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    background: var(--accent2);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-input-row {
    display: flex;
    padding: 0.5rem;
    gap: 0.5rem;
    border-top: 1px solid var(--surface2);
}

.chat-input-row input {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.5rem;
}

.chat-input-row button {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
    .insights-bar { gap: 1rem; }
    main { padding: 1rem 0.5rem 5rem !important; }
    .chat-panel { left: 0.5rem; right: 0.5rem; width: auto; }
    .chat-fab { bottom: 5.5rem; right: 0.75rem; }
    .breaks-grid { grid-template-columns: 1fr; }
}
