/* ==========================================================================
   Design Tokens
   ========================================================================== */
:root {
    /* Brand – Deep Teal */
    --brand-50: #e8f1f5;
    --brand-100: #d5e6ee;
    --brand-200: #aac6d3;
    --brand-300: #7ba8bc;
    --brand-400: #4e8aa4;
    --brand-500: #2f6f8a;
    /* mid */
    --brand-600: #1f5f78;
    /* primary */
    --brand-700: #184b5f;
    /* hover / strong */
    --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: #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 */
    --chat-h-desktop: 65vh;
    --chat-h-mobile: 58vh;

    /* iOS safe area */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==========================================================================
   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
   ========================================================================== */
.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);
}

/* Legacy no-ops */
.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(31, 95, 120, .28);
}

.menu .cta:hover {
    background: var(--brand-700);
}

/* ==========================================================================
   Main Split
   ========================================================================== */
.split {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 18px;
    padding: 18px 0;
}

/* Left Pane */
.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
   ========================================================================== */
.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);
}

/* Text-message bubbles */
.msg {
    display: flex;
    margin: 8px 0;
}

.msg+.msg {
    margin-top: 6px;
}

.msg .bubble {
    max-width: 70ch;
    padding: 10px 14px;
    border: none !important;
    background-clip: padding-box;
    line-height: 1.35;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .03);
}

.msg.bot {
    justify-content: flex-start;
}

.msg.bot .bubble {
    background: #f1f5f9;
    color: var(--ink);
    border-radius: 18px 18px 18px 6px;
}

.msg.user {
    justify-content: flex-end;
}

.msg.user .bubble {
    background: var(--brand-600);
    color: #fff;
    border-radius: 18px 18px 6px 18px;
}

.msg .bubble a {
    color: inherit;
    text-decoration: underline;
}

.msg .bubble p {
    margin: 0 0 6px;
}

.msg .bubble p:last-child {
    margin-bottom: 0;
}

.msg.user .bubble ::selection {
    background: rgba(255, 255, 255, .25);
}

/* ==========================================================================
   Composer
   ========================================================================== */
.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.busy {
    background: #f3f7ff;
    border-color: var(--brand-300);
}

.composer input:focus {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(31, 95, 120, .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(243, 106, 33, .22);
    transition: filter .15s, transform .02s;
}

.composer button:hover {
    filter: brightness(.98);
}

.composer button:disabled {
    opacity: .65;
    cursor: not-allowed;
}

/* Typing indicator (legacy small version) */
.typing {
    font-size: 13px;
    color: var(--brand-700);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 2px;
}

.typing .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand-600);
    animation: bounce 1s infinite;
}

.typing .dot:nth-child(2) {
    animation-delay: .2s;
}

.typing .dot:nth-child(3) {
    animation-delay: .4s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(.6);
        opacity: .4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    margin-top: 12px;
    background: linear-gradient(180deg, var(--brand-400), var(--brand-600));
}

.site-footer .container {
    padding: 12px 0;
    text-align: center;
}

.site-footer small {
    color: #000;
}

/* ==========================================================================
   Hero strip under header
   ========================================================================== */
.hero-banner {
    background: transparent;
    padding: 0;
    border: 0;
}

.hero-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 18px;
    background: linear-gradient(180deg, #fff, #fcfdff);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    margin: 12px auto 16px;
    padding: 16px 20px;
    box-shadow: var(--shadow-3);
}

.hero-photo {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    border: 2px solid #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
}

.hero-quote {
    font-weight: 800;
    font-size: 22px;
    line-height: 1.22;
}

/* ==========================================================================
   Skeletons
   ========================================================================== */
.skel {
    height: 38px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, #f1f4f9, #e9eef6, #f1f4f9);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border: 1px solid var(--line);
}

@keyframes shimmer {
    0% {
        background-position: 0 0
    }

    100% {
        background-position: -200% 0
    }
}

/* ==========================================================================
   Focus & A11y
   ========================================================================== */
.menu a:focus-visible,
.menu button:focus-visible,
.topics button:focus-visible,
.composer button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Mobile “Chat with Agent” Button (sticky)
   ========================================================================== */
.mobile-chat-btn {
    display: none;
}

@media (max-width:640px) {
    .mobile-chat-btn {
        display: inline-flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(16px + var(--safe-bottom));
        margin: 0 auto;
        width: calc(100% - 2rem);
        max-width: 700px;
        justify-content: center;
        align-items: center;
        padding: 14px 16px;
        border-radius: var(--radius-pill);
        background: var(--accent-500);
        color: #fff;
        font-weight: 700;
        text-decoration: none;
        box-shadow: 0 8px 24px rgba(243, 106, 33, .22);
        z-index: 9999;
    }

    .mobile-chat-btn:active {
        transform: translateY(1px);
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width:900px) {
    .split {
        grid-template-columns: 1fr;
    }

    .chat {
        height: var(--chat-h-mobile);
    }

    .logo {
        width: 220px;
    }

    .msg .bubble {
        max-width: 85%;
    }

    .brand-doctor {
        font-size: 24px;
    }

    .brand-clinic {
        font-size: 16px;
    }

    .topics button,
    .menu a,
    .menu button {
        padding: 12px 14px;
    }
}

@media (min-width:1100px) {
    .hero-quote {
        white-space: nowrap;
    }
}

@media (max-width:900px) {
    .hero-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero-photo {
        width: 50px;
        height: 50px;
    }

    .hero-quote {
        font-size: 18px;
        white-space: normal;
    }
}

/* ==========================================================================
   Modal (overlay) – neutral 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;
}

.modal-hero {
    background: linear-gradient(180deg, #f6f9ff, #fff);
    border-bottom: 1px solid var(--line);
}

.modal-hero-inner {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
}

.modal-hero-inner img {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    object-fit: cover;
    object-position: 50% 50%;
}

.modal-body {
    padding: 16px;
}

.modal-body form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.modal-body input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
}

.btn.primary {
    background: var(--brand-600);
    color: #fff;
    border: 0;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

.btn.primary:hover {
    background: var(--brand-700);
}

.btn.ghost {
    background: #f4f7ff;
    color: #1e3a8a;
    border: 1px solid #dbe6ff;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

@media (max-width:700px) {
    .modal-body form {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Chat UX rules (streaming-safe)
   ========================================================================== */
/* Hide chips while typing row is present */
#chat .typing-row+#suggestionsDock,
#chat .typing-row~#suggestionsDock {
    display: none !important;
}

/* Hide truly empty bot bubbles (prevents blank bubble above “Reviewing…”) */
#chat .msg.bot .bubble:empty,
#chat .msg.bot .bubble[data-empty="1"] {
    display: none !important;
}

/* ==========================================================================
   Themed hero for #scheduleModal (large circular avatar)
   ========================================================================== */
#scheduleModal .modal-card {
    border-radius: 16px;
    box-shadow: 0 22px 70px rgba(11, 18, 32, .35);
}

#scheduleModal .modal-hero {
    background: radial-gradient(1200px 600px at -120px -120px,
            var(--brand-200) 0%, var(--brand-400) 28%, var(--brand-500) 62%, var(--brand-600) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, .18);
    color: #fff;
}

#scheduleModal .modal-hero-inner {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: center;
    gap: 20px;
    min-height: 210px;
    padding: 18px 22px;
}

#scheduleModal .modal-hero-inner>img {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover !important;
    object-position: 50% 40% !important;
    background: #fff;
    border: 6px solid #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
}

#scheduleModal #schedTitle {
    margin: 0 0 6px;
    font-weight: 800;
    font-size: 26px;
    line-height: 1.22;
    color: #fff;
}

#scheduleModal .modal-hero-inner>div p {
    margin: 0;
    color: rgba(255, 255, 255, .9);
}

#scheduleModal .modal-body {
    background: #fff;
    padding: 18px 20px;
}

#scheduleModal .modal-actions {
    background: #fff;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
}

#scheduleModal .modal-body form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    max-width: 560px;
}

#scheduleModal .modal-body input {
    width: 100%;
    height: 46px;
    border-radius: 12px;
    font-size: 15px;
}

@media (max-width:700px) {
    #scheduleModal .modal-hero-inner {
        grid-template-columns: 1fr;
        text-align: left;
        min-height: unset;
    }

    #scheduleModal .modal-hero-inner>img {
        width: 120px;
        height: 120px;
        border-width: 5px;
    }
}