/* ==========================================================================
   CastGrade - Consolidated Stylesheet
   ========================================================================== */

/* --- CSS Variables & Reset --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --border: #475569;
}

/* --- Base Typography & Layout --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
}

h1, h2, h3 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

/* --- Navigation (Authenticated / Sticky) --- */
nav {
    background: var(--bg-secondary);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

nav a, nav button {
    color: var(--text-primary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.95rem;
}

nav a:hover, nav button:hover {
    background: var(--bg-card);
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 100px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 5px;
    align-items: center;
}

.nav-links form {
    margin: 0;
}

.nav-links button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
}

@media (max-width: 480px) {
    nav {
        justify-content: center;
        gap: 4px;
    }
    .logo {
        width: 100%;
        justify-content: center;
        padding-bottom: 4px;
    }
    .nav-links {
        justify-content: center;
        flex-wrap: wrap;
    }
    nav a, nav button {
        padding: 6px 8px;
        font-size: 0.85rem;
    }
}

/* --- Navigation (Public / Non-Sticky) --- */
.nav-public {
    background: none;
    border-bottom: none;
    position: static;
    padding: 20px 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-public .logo {
    text-decoration: none;
}

.nav-public .logo img {
    height: 160px;
}

.nav-public .nav-links {
    gap: 12px;
}

.nav-public .nav-links a {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.nav-public .nav-links .login {
    color: var(--text-secondary);
}

.nav-public .nav-links .login:hover {
    color: var(--text-primary);
    background: none;
}

.nav-public .nav-links .guide-link {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.15);
}

.nav-public .nav-links .register {
    background: var(--accent);
    color: white;
}

.nav-public .nav-links .register:hover {
    background: var(--accent-hover);
}

/* --- Cards --- */
.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    min-height: 44px;
    transition: background 0.2s;
}

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.9rem;
    min-height: 36px;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.btn-group .btn {
    flex: 1;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
}

.label-hint {
    font-weight: normal;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    min-height: 44px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- Form Hints --- */
.form-hint {
    font-weight: normal;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
    display: block;
}

/* --- Checkbox Groups --- */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.95rem;
    min-height: 44px;
    transition: all 0.2s;
}

.checkbox-group input[type="checkbox"] {
    display: none;
}

.checkbox-group input[type="checkbox"]:checked + span,
.checkbox-group label:has(input:checked) {
    background: var(--accent);
    border-color: var(--accent);
}

/* --- Error Messages --- */
.error {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--danger);
}

/* --- Auth Pages (Login / Register) --- */
.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--bg-secondary);
    padding: 30px 24px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 24px;
}

.auth-card input {
    padding: 14px;
    min-height: 48px;
}

.auth-card input::placeholder {
    color: var(--text-muted);
}

.auth-card .btn {
    width: 100%;
    padding: 14px;
    min-height: 48px;
    margin-top: 8px;
}

.auth-card .error {
    text-align: center;
}

.divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider::before {
    margin-right: 16px;
}

.divider::after {
    margin-left: 16px;
}

.btn-google {
    width: 100%;
    padding: 14px;
    background: #fff;
    color: #1f2937;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
}

.btn-google:hover {
    background: #f8fafc;
}

.btn-google svg {
    width: 20px;
    height: 20px;
}

.register-link,
.login-link {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.register-link a,
.login-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* --- Spot Components --- */
.spot-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spot-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: border-color 0.2s;
}

.spot-card:hover {
    border-color: var(--accent);
}

.spot-card h3 {
    margin-bottom: 4px;
}

.spot-card .coords {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.spot-card .prefs {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* --- Ranking Components --- */
.ranking-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.ranking-rank {
    background: var(--accent);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 10px;
}

.ranking-score {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
}

.ranking-summary {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.conditions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.condition-item {
    background: var(--bg-card);
    padding: 10px;
    border-radius: 8px;
}

.condition-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.condition-value {
    font-size: 1rem;
    font-weight: 500;
    margin-top: 2px;
}

.condition-good { color: var(--success); }
.condition-moderate { color: var(--warning); }
.condition-poor { color: var(--danger); }

.best-time {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.best-time-label {
    color: var(--success);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.best-time-value {
    font-size: 1.1rem;
    font-weight: 500;
    margin-top: 4px;
}

/* --- Stepper --- */
.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.stepper-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.stepper-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.stepper-btn:active {
    transform: scale(0.95);
}

.stepper-value {
    font-size: 1.5rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.time-window {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    text-align: center;
}

.time-window-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.time-window-hours {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
    margin-top: 4px;
}

/* --- Map --- */
#map {
    width: 100%;
    height: 300px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.map-small {
    height: 200px;
}

/* --- Data Sections (Tides, Weather) --- */
.data-section {
    margin-top: 16px;
}

.data-section h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.tide-list, .weather-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tide-item, .weather-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 8px;
}

.tide-time, .weather-time {
    font-weight: 500;
}

.tide-type {
    text-transform: capitalize;
}

.tide-type.high { color: var(--accent); }
.tide-type.low { color: var(--warning); }

/* --- Getting Started Steps --- */
.getting-started .steps {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.getting-started .step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.getting-started .step-number {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.getting-started .step-content h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.getting-started .step-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.getting-started .features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.getting-started .feature-item {
    padding: 12px;
    background: var(--bg-card);
    border-radius: 8px;
}

/* --- Guide Page Styles (shared between guide.html and guide_public.html) --- */
.toc-card {
    background: var(--bg-card);
}

.toc {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc li {
    margin-bottom: 8px;
}

.toc a {
    color: var(--accent);
    text-decoration: none;
    font-size: 1rem;
}

.toc a:hover {
    text-decoration: underline;
}

.guide-content,
.placeholder-text {
    color: #cbd5e1;
    background: var(--bg-card);
    padding: 16px;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.guide-content p {
    margin: 0;
}

.guide-content ul,
.placeholder-text ul {
    margin: 12px 0 0 0;
    padding-left: 20px;
}

.guide-content li,
.placeholder-text li {
    margin-bottom: 6px;
}

.location-section,
.lure-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.location-section:first-of-type,
.lure-section:first-of-type {
    margin-top: 16px;
    padding-top: 0;
    border-top: none;
}

.location-section h3,
.lure-section h3 {
    color: var(--text-primary);
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.lure-locations {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.lure-locations .tag {
    color: var(--text-primary);
}

html {
    scroll-behavior: smooth;
}

[id] {
    scroll-margin-top: 70px;
}

/* --- Guide Public Container (wider) --- */
.guide-public-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

.guide-public-container h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.guide-public-container a {
    color: var(--accent);
}

.guide-public-container a.cta-button {
    color: white;
}

/* --- Landing Page --- */
.landing .hero {
    text-align: center;
    padding: 60px 24px 80px;
    max-width: 800px;
    margin: 0 auto;
}

.landing .hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.2;
}

.landing .hero h1 span {
    color: var(--accent);
}

.landing .hero p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-cta {
    display: inline-block;
    padding: 16px 32px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: background 0.2s;
}

.hero-cta:hover {
    background: var(--accent-hover);
}

.features {
    background: var(--bg-secondary);
    padding: 80px 24px;
}

.features-container {
    max-width: 1000px;
    margin: 0 auto;
}

.features h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 48px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 32px;
}

.feature-card {
    background: var(--bg-primary);
    padding: 28px;
    border-radius: 12px;
    border: 1px solid var(--bg-card);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 16px;
}

.feature-card h3 {
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.landing .how-it-works {
    padding: 80px 24px;
    max-width: 900px;
    margin: 0 auto;
}

.landing .how-it-works h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 48px;
}

.landing .steps {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.landing .step {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.landing .step-number {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.landing .step-content h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.landing .step-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* --- CTA Section (shared by landing & guide_public) --- */
.cta {
    background: var(--bg-secondary);
    text-align: center;
    padding: 80px 24px;
}

.guide-public-container .cta {
    padding: 60px 24px;
    margin-top: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.cta h2 {
    font-size: 1.8rem;
    margin-bottom: 16px;
}

.cta p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 1.1rem;
}

.cta-button {
    display: inline-block;
    padding: 16px 32px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: background 0.2s;
}

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

/* --- Footer --- */
.site-footer {
    text-align: center;
    padding: 20px 15px;
    margin-top: 40px;
    border-top: 1px solid var(--border);
}

.public-footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: none;
    margin-top: 0;
}

.feedback-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
}

.feedback-link:hover {
    color: var(--accent);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* --- HTMX Utilities --- */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

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

/* --- Responsive Media Queries --- */
@media (max-width: 600px) {
    .nav-public {
        justify-content: center;
        flex-wrap: wrap;
        gap: 4px;
    }
    .nav-public .logo {
        width: 100%;
        justify-content: center;
        padding-bottom: 4px;
    }
    .nav-public .logo img {
        height: 100px;
    }
    .nav-public .nav-links {
        justify-content: center;
    }
    .landing .hero h1 {
        font-size: 2rem;
    }
    .landing .hero p {
        font-size: 1.1rem;
    }
    .features h2,
    .landing .how-it-works h2,
    .cta h2 {
        font-size: 1.5rem;
    }
    .guide-public-container h1 {
        font-size: 1.6rem;
    }
}

/* --- Tag Badges (spot cards and detail) --- */
.spot-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.spot-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    color: var(--accent);
}

/* --- Tag Filter Bar --- */
.tag-filter {
    margin-bottom: 16px;
}

.tag-filter form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    height: 34px;
    box-sizing: border-box;
    border-radius: 16px;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
}

.tag-chip input[type="checkbox"] {
    display: none;
}

.tag-chip:hover {
    border-color: var(--accent);
    color: var(--text);
}

.tag-chip-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(74, 158, 255, 0.4);
}

.tag-chip-clear {
    color: var(--danger);
    border-color: var(--danger);
    background: transparent;
}

.tag-chip-clear:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* --- Tag Filter in Forms (rankings, best times) --- */
.tag-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 400px) {
    .checkbox-group {
        grid-template-columns: repeat(2, 1fr);
    }
    .conditions-grid {
        grid-template-columns: 1fr;
    }
    .getting-started .features-grid {
        grid-template-columns: 1fr;
    }
}
