/* ==========================================================================
   Design Tokens
   ========================================================================== */
:root {
    /* Brand – Deep Teal */
    --brand-50: #e8f1f5;
    --brand-100: #d5e6ee;
    --brand-200: #aac6d3;
    --brand-300: #7ba8bc;
    --brand-400: #4e8aa4;
    --brand-500: #2f6f8a;
    --brand-600: var(--gd-navy, #1f5f78);
    /* primary */
    --brand-700: var(--gd-navy, #184b5f);
    /* hover */
    --brand-800: #123846;
    --brand-900: #0b2631;

    /* Accent – Orange */
    --accent-50: #fff1e7;
    --accent-100: #ffd9c2;
    --accent-200: #ffb889;
    --accent-300: #ff934f;
    --accent-400: #ff7a2b;
    --accent-500: var(--gd-accent, #f36a21);
    /* accent */
    --accent-600: #d65717;
    --accent-700: #b34611;

    /* Surfaces & text */
    --bg: #f6f8fb;
    --card: #ffffff;
    --ink: #0b1a33;
    --muted: #66758a;
    --line: #e5ecf5;

    /* Shadows */
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, .06);
    --shadow-3: 0 10px 28px rgba(0, 0, 0, .10);

    /* Layout */
    --container: 1200px;
    --radius-sm: 10px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    /* Chat sizing (legacy “page chat”) */
    --chat-h-desktop: 65vh;
    --chat-h-mobile: 58vh;

    /* iOS safe area */
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* VFW Post 2130 widget theme */
    --gd-navy: #0f2237;
    --gd-accent: #b22234;
    --gd-primary-rgb: 15, 34, 55;
    --gd-accent-rgb: 178, 34, 52;
}

/* ==========================================================================
   Base
   ========================================================================== */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 16px;
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Header (legacy)
   ========================================================================== */
.site-header {
    background: linear-gradient(180deg, var(--brand-100), #fff);
    border-bottom: 1px solid rgba(0, 0, 0, .04);
    box-shadow: var(--shadow-2);
    backdrop-filter: saturate(120%) blur(4px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 0 12px;
}

/* Brand */
.brand,
.brand-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.logo {
    width: clamp(240px, 34vw, 400px);
    height: auto;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-doctor {
    font-weight: 900;
    font-size: clamp(28px, 4.4vw, 44px);
    line-height: 1.06;
    letter-spacing: .01em;
    color: var(--ink);
}

.brand-clinic {
    font-weight: 700;
    font-size: clamp(18px, 2.6vw, 26px);
    line-height: 1.15;
    letter-spacing: .02em;
    color: var(--ink);
}

.brand-line1,
.brand-line2 {
    display: none !important;
}

/* Nav pills */
.menu,
.menu-centered {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.menu a,
.menu button {
    appearance: none;
    border: 1px solid #e6edf7;
    background: #fff;
    padding: 9px 14px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
    transition: border-color .15s, background .15s, transform .02s, box-shadow .15s;
}

.menu a:hover,
.menu button:hover {
    background: #f8fbff;
    border-color: #d8e6ff;
    transform: translateY(-1px);
}

.menu .cta {
    background: var(--brand-600);
    color: #fff !important;
    padding: 10px 18px;
    border-radius: var(--radius-pill);
    box-shadow: 0 8px 22px rgba(var(--gd-primary-rgb), .28);
}

.menu .cta:hover {
    background: var(--brand-700);
}

/* ==========================================================================
   Main Split (legacy page layout)
   ========================================================================== */
.split {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 18px;
    padding: 18px 0;
}

.left-pane {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-1);
}

.left-pane h2 {
    margin-top: 0;
}

.topics {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}

.topics li {
    margin-bottom: 8px;
}

.topics .group-title {
    margin: 12px 0 6px;
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
}

.topics button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    background: #f6fbff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: border-color .15s, background .15s, transform .02s;
}

.topics button:hover {
    border-color: var(--brand-300);
    background: var(--brand-100);
    transform: translateY(-1px);
}

.topics button.primary {
    background: linear-gradient(180deg, #f1f7ff, #e7f0ff);
    border-color: #cfe2ff;
    box-shadow: 0 1px 0 rgba(13, 110, 253, .12);
}

.lead-card {
    border-top: 1px dashed var(--line);
    padding-top: 14px;
}

.lead-card input,
.lead-card textarea {
    width: 100%;
    margin: 6px 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fbfdff;
}

.lead-card button {
    width: 100%;
    padding: 10px;
    background: var(--brand-600);
    color: #fff;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.lead-card button:hover {
    background: var(--brand-700);
}

.fine {
    color: var(--muted);
    font-size: 12px;
}

.status {
    margin-top: 6px;
    font-size: 13px;
    color: #000;
}

/* ==========================================================================
   Right Pane / Chat (legacy page chat, NOT the floating widget)
   ========================================================================== */
.right-pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 14px;
    height: var(--chat-h-desktop);
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(16px, var(--safe-bottom));
    box-shadow: var(--shadow-1);
}

/* ==========================================================================
   Composer (legacy page chat only)
   ========================================================================== */
.composer {
    display: flex;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: transparent;
    padding-top: 4px;
    padding-bottom: calc(var(--safe-bottom) + 0px);
}

.composer input {
    flex: 1;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 15px;
    transition: border-color .15s, box-shadow .15s;
}

.composer input:focus {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(var(--gd-primary-rgb), .14);
    outline: none;
}

.composer button {
    background: var(--accent-500);
    color: #fff;
    border: 0;
    padding: 12px 16px;
    font-weight: 700;
    letter-spacing: .02em;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 22px rgba(var(--gd-accent-rgb), .22);
}

.composer button:disabled {
    opacity: .65;
    cursor: not-allowed;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width:900px) {
    .split {
        grid-template-columns: 1fr;
    }

    .chat {
        height: var(--chat-h-mobile);
    }

    .logo {
        width: 220px;
    }
}

/* ==========================================================================
   Modal base
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    display: none;
    z-index: 999;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    width: min(560px, 94vw);
    background: #fff;
    color: var(--ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   VFW Post 2130 Floating Chat Widget (anchored input + scroll log)
   ========================================================================== */

/* Launcher */
.gd-chat-launcher {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2147483000;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gd-accent);
    color: #fff;
    border: 0;
    padding: 12px 14px;
    border-radius: 999px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
    cursor: pointer;
    font-weight: 800;
    letter-spacing: .02em;
}

/* Panel: grid = header | log | composer */
.gd-chat-panel {
    position: fixed;
    z-index: 2147483000;
    width: 380px;
    max-width: calc(100vw - 36px);
    height: min(520px, calc(100vh - 120px));
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .18);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
    overflow: hidden;

    /* JS controls visibility */
    display: none;

    /* ✅ Anchored layout */
    grid-template-rows: auto 1fr auto;
}

/* Header (center title, close on right) */
#gdChatPanel .gd-chat-header {
    background: linear-gradient(180deg, var(--gd-navy), var(--gd-accent));
    color: #fff;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    cursor: grab;
}

#gdChatPanel.is-dragging .gd-chat-header {
    cursor: grabbing;
}

#gdChatDragHandle {
    touch-action: none;
}

#gdChatPanel .gd-chat-header .title {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-align: center;
    align-items: center;
}

#gdChatPanel .gd-chat-header .title strong {
    font-family: "Cormorant Garamond", serif;
    font-size: 20px;
    letter-spacing: .04em;
}

#gdChatPanel .gd-chat-header .title span {
    font-size: 12px;
    opacity: .92;
}

#gdChatPanel .gd-chat-close {
    position: absolute;
    right: 10px;
    top: 6px;
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

/* Log: scrolls, never affects composer */
#gdChatLog {
    overflow: auto;
    min-height: 0;
    /* critical for grid scroll */
    padding: 12px;
    background: #f6f7f8;
}

/* Composer: fixed bottom row inside panel */
.gd-chat-composer {
    border-top: 1px solid rgba(0, 0, 0, .10);
    padding: 10px;
    padding-bottom: calc(10px + var(--safe-bottom));
    background: #fff;
}

/* Input row (scoped, not .composer) */
.gd-chat-composer .gd-composer {
    display: flex;
    gap: 8px;
    align-items: center;
}

.gd-chat-composer input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, .18);
    border-radius: 10px;
    padding: 10px;
    font: inherit;
}

.gd-chat-composer button {
    background: var(--gd-accent);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 800;
    cursor: pointer;
}

/* Footer row (refresh + hint + upload) */
.gd-chat-footerrow {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    justify-content: space-between;
}

.gd-chat-iconbtn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, .18);
    background: #fff;
    cursor: pointer;
    font-weight: 800;
    line-height: 1;
    user-select: none;
}

.gd-chat-iconbtn:hover {
    filter: brightness(.98);
}

.gd-chat-hint {
    flex: 1;
    font-size: 12px;
    color: rgba(0, 0, 0, .55);
    text-align: center;
    padding: 0 6px;
}

/* Mobile tweaks */
@media (max-width:520px) {
    .gd-chat-panel {
        width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
    }
}