/* Fraunces (warm editorial serif for headings/brand moments - 2026-09-01
   visual refresh, chosen to read as "premium travel" rather than "generic
   SaaS dashboard") + Inter (UI text/body copy) are loaded via <link> tags
   in templates/base.html's <head>, not @import here - a <link> lets the
   browser discover and fetch the font in parallel with this stylesheet
   instead of blocking on it. */

:root {
    --color-primary: #1d6f6a;
    --color-primary-dark: #14514d;
    --color-primary-light: #e4f0ee;
    --color-accent: #c96f3e;
    --color-accent-dark: #a8582e;
    --color-accent-light: #fbeee5;
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-sand: #fbf8f3;
    --color-text: #1f2933;
    --color-text-muted: #5a6572;
    --color-border: #dde2e7;
    --color-success-bg: #e3f6e8;
    --color-success-text: #1e6b3a;
    --color-error-bg: #fdeceb;
    --color-error-text: #a4302a;
    --color-warning-bg: #fff5e0;
    --color-warning-text: #8a5a00;
    --color-info-bg: #e8f0fe;
    --color-info-text: #1c4587;
    --color-danger: #b3392f;
    --radius: 0.65rem;
    --radius-lg: 1.15rem;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(31, 41, 51, 0.06), 0 1px 1px rgba(31, 41, 51, 0.04);
    --shadow-md: 0 8px 24px rgba(31, 41, 51, 0.08), 0 2px 6px rgba(31, 41, 51, 0.05);
    --shadow-lg: 0 20px 48px rgba(31, 41, 51, 0.12), 0 6px 16px rgba(31, 41, 51, 0.06);
    --font-sans:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    /* A fixed height (not min-height) is required so flex children with
       min-height:0 (like .content-flush / .chat-messages) get a bounded
       box to shrink into and scroll internally - min-height alone lets
       body grow past one viewport instead, which is what let the chat
       page's input bar drift off-screen below a long conversation.
       100dvh accounts for mobile browser chrome; a min-height:100vh
       fallback keeps very short/legacy content pages filling the screen
       even in browsers without dvh support. */
    min-height: 100vh;
    height: 100dvh;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

h1 {
    font-size: 1.9rem;
    margin: 0 0 0.6rem;
}

h2 {
    font-size: 1.35rem;
    margin: 1.75rem 0 0.75rem;
}

p {
    line-height: 1.6;
}

a {
    color: var(--color-primary);
}

a:hover {
    color: var(--color-primary-dark);
}

/* Header / nav */

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.site-header-inner {
    max-width: 760px;
    margin: 0 auto;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--color-primary-dark);
    text-decoration: none;
    margin-right: auto;
    letter-spacing: -0.01em;
}

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

.site-nav a {
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.site-nav a:hover {
    color: var(--color-primary);
}

.nav-logout-form {
    margin: 0;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--color-text-muted);
    cursor: pointer;
    text-decoration: underline;
}

.link-button:hover {
    color: var(--color-primary);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: var(--color-text);
    border-radius: 1px;
}

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

    .site-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
        padding-top: 0.75rem;
    }

    .site-header-inner {
        flex-wrap: wrap;
    }

    .site-nav.is-open {
        display: flex;
    }
}

/* Messages */

.messages {
    list-style: none;
    margin: 0 auto;
    padding: 0.75rem 1rem 0;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.message.success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.message.error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.message.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.message-close {
    background: none;
    border: none;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.message-close:hover {
    opacity: 1;
}

/* Page content */

.site-content {
    flex: 1 1 auto;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 1.5rem 1rem 2.5rem;
}

/* Used by pages that manage their own full-height layout with an
   internally-scrolling region (e.g. /chat/'s .chat-messages) - grows to
   fill the space left by the header/footer like .site-content, but
   without imposing padding/max-width of its own. min-height:0 is
   required here so the flex child can be squeezed to exactly one
   viewport's worth of space, letting its own internal overflow:auto
   region absorb anything taller - never use this class for a page
   without such a region (see .content-wide below for why: found live,
   2026-09-01, on production - the landing page reused this class before
   it had any internal scroll area, which silently capped <main> at a
   flex-computed height shorter than its actual content and caused the
   footer to render on top of the overflowing destinations section
   instead of below it). */
.content-flush {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Used by full-width pages that are simply taller than one viewport and
   should scroll normally (e.g. the landing page) - same flush styling as
   .content-flush (no padding/max-width imposed) but without min-height:0,
   so <main> is free to grow to its full content height instead of being
   capped to the flex-computed space left by the header/footer. */
.content-wide {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

/* Forms - targets the default {{ form.as_p }} output, no per-template markup needed */

form p {
    margin: 0 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

form label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

input, select, textarea {
    font: inherit;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

textarea {
    resize: vertical;
    min-height: 4.5rem;
}

/* Checkbox/radio option lists (e.g. CheckboxSelectMultiple) render as a
   plain <ul> inside the wrapping <p> - style them as a clean option list
   instead of a bulleted list. */
form ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

form ul label {
    font-weight: 400;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

form ul input[type="checkbox"], form ul input[type="radio"] {
    width: auto;
}

ul.errorlist {
    list-style: none;
    margin: 0 0 0.4rem;
    padding: 0;
    color: var(--color-error-text);
    font-size: 0.85rem;
}

/* Buttons */

button, .btn {
    display: inline-block;
    font: inherit;
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease,
        box-shadow 0.15s ease;
}

button:hover, .btn:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

button:active, .btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

button:focus-visible, .btn:focus-visible {
    outline: 2px solid var(--color-primary-dark);
    outline-offset: 2px;
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

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

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

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

.btn-danger:hover {
    background: #8f2d25;
    border-color: #8f2d25;
}

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1.05rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1rem 0;
}

/* Cards / item lists (trips, travel history) */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.item-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.item-list li {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: box-shadow 0.15s ease;
}

.item-list li:hover {
    box-shadow: var(--shadow-sm);
}

.item-list .item-title {
    font-weight: 600;
}

.item-list .item-actions {
    display: flex;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.item-list .item-status {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.empty-state {
    color: var(--color-text-muted);
}

/* Footer */

.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.site-footer small {
    color: var(--color-text-muted);
    max-width: 760px;
    display: inline-block;
}

/* Tags / badges - used by destination recommendation cards and the
   landing page (trip type, cost tier, climate, "why this fits you"). */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-radius: var(--radius-pill);
    padding: 0.25rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.tag-accent {
    background: var(--color-accent-light);
    color: var(--color-accent-dark);
}

.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* Chat bubbles and recommendation cards - shared between the real chat
   page (ai/templates/ai/chat.html) and the landing page's product
   preview (core/templates/core/landing.html), so a visitor's first
   look at "what happens after the CTA" is the *actual* UI, not a
   disconnected marketing mockup (2026-09-01 second UX pass, §4: "show
   the product, not just describe it"). Previously lived only in
   chat.html's own <style> block - moved here once a second page needed
   the exact same components, rather than duplicating the rules. */

.chat-bubble {
    max-width: 85%;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-lg);
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--color-primary);
    color: #fff;
    white-space: pre-wrap;
    border-bottom-right-radius: 0.3rem;
}

/* Assistant replies are rendered from Markdown (see chat.html's
   renderMarkdown()) into real <p>/<table>/<ul> elements, so they don't
   need white-space: pre-wrap - these reset the browser's default block
   margins so spacing stays tight and consistent between chunks. */
.chat-bubble.assistant p {
    margin: 0 0 0.6rem;
}

.chat-bubble.assistant p:last-child {
    margin-bottom: 0;
}

.chat-bubble.assistant ul,
.chat-bubble.assistant ol {
    margin: 0 0 0.6rem;
    padding-left: 1.4rem;
}

.chat-bubble.assistant li {
    margin-bottom: 0.2rem;
}

.chat-bubble.assistant .table-scroll {
    overflow-x: auto;
    margin: 0 0 0.6rem;
}

.chat-bubble.assistant table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.92rem;
}

.chat-bubble.assistant th,
.chat-bubble.assistant td {
    border: 1px solid var(--color-border);
    padding: 0.4rem 0.6rem;
    text-align: left;
    vertical-align: top;
}

.chat-bubble.assistant th {
    background: rgba(0, 0, 0, 0.04);
}

.chat-bubble.assistant {
    align-self: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 0.3rem;
}

.chat-bubble.error {
    align-self: flex-start;
    background: var(--color-error-bg);
    color: var(--color-error-text);
    border-bottom-left-radius: 0.3rem;
}

.chat-bubble.loading {
    align-self: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    border-bottom-left-radius: 0.3rem;
    animation: chat-loading-pulse 1.6s ease-in-out infinite;
}

@keyframes chat-loading-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.recommendation-cards {
    align-self: flex-start;
    max-width: 100%;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.recommendation-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recommendation-card .destination-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.1rem;
}

.recommendation-card .destination-country {
    color: var(--color-text-muted);
    font-size: 0.88rem;
    margin-top: -0.35rem;
}

/* "Why this fits you" - visually separated from the destination's own
   facts (name/country/tags above) per direct request: the personalized
   rationale should read as clearly distinct from generic description. */
.recommendation-card .fit-reasons-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-accent-dark);
    margin: 0.15rem 0 -0.15rem;
}

.recommendation-card .fit-reasons {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.85rem;
    color: var(--color-text);
}

.recommendation-card .fit-reasons li::before {
    content: "✓ ";
    color: var(--color-primary);
    font-weight: 700;
}

.recommendation-card .btn {
    margin-top: auto;
    align-self: flex-start;
    font-size: 0.88rem;
    padding: 0.45rem 0.9rem;
}

@media (max-width: 480px) {
    .chat-bubble { max-width: 95%; }
    .recommendation-cards { grid-template-columns: 1fr; }
}

/* Auth pages (login/register) - a centered card instead of a bare
   {{ form.as_p }} dropped into the generic content column. */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem 1.75rem;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 0.35rem;
}

.auth-card .auth-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
}

.auth-card button, .auth-card .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
    margin-top: 0.25rem;
}

.auth-card .auth-footer {
    text-align: center;
    margin: 1.25rem 0 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* Landing page */

.landing-hero {
    background: linear-gradient(180deg, var(--color-sand) 0%, var(--color-bg) 100%);
    border-bottom: 1px solid var(--color-border);
}

.landing-hero-inner {
    max-width: 760px;
    margin: 0 auto;
    padding: 4.5rem 1.25rem 3.5rem;
    text-align: center;
}

.landing-eyebrow {
    display: inline-block;
    color: var(--color-accent-dark);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.landing-hero h1 {
    font-size: 2.6rem;
    line-height: 1.15;
    margin: 0 auto 1rem;
    max-width: 640px;
}

.landing-hero-lede {
    font-size: 1.15rem;
    color: var(--color-text-muted);
    max-width: 540px;
    margin: 0 auto 2rem;
}

.landing-hero-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.landing-hero-hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.landing-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 2.75rem 1.25rem;
}

.landing-section h2 {
    text-align: center;
    margin-top: 0;
}

/* Product preview - a real .chat-bubble + .recommendation-card, not an
   illustration, per direct request (2026-09-01 second UX pass, §4). */
.landing-preview-caption {
    text-align: center;
    color: var(--color-text-muted);
    margin: -0.5rem 0 1.75rem;
}

.landing-preview-mock {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.landing-preview-mock .chat-bubble.user {
    align-self: flex-end;
}

.landing-preview-mock .recommendation-cards {
    display: block;
}

.landing-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2.25rem;
}

.landing-step {
    text-align: center;
}

.landing-step-icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-pill);
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin: 0 auto 1rem;
}

.landing-step h3 {
    font-size: 1.05rem;
    margin: 0 0 0.4rem;
}

.landing-step p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin: 0;
}

.landing-destinations {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.landing-destination-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-top: 2.25rem;
}

.landing-destination-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.landing-destination-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.landing-destination-card .destination-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    margin-bottom: 0.1rem;
}

.landing-destination-card .destination-country {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.landing-final-cta {
    text-align: center;
    padding: 4rem 1.25rem;
}

.landing-final-cta h2 {
    margin-top: 0;
}

@media (max-width: 720px) {
    .landing-hero h1 {
        font-size: 2rem;
    }

    .landing-steps {
        grid-template-columns: 1fr;
    }
}
