:root {
    --ai-green: #8dc63f;
    --ai-green-dark: #5f9f25;
    --ai-navy: #063d5b;
    --ai-blue: #0e7490;
    --ai-coral: #f9735b;
    --ai-ink: #0f172a;
    --ai-muted: #64748b;
    --ai-line: #dbe5ee;
    --ai-soft: #f4f8fa;
    --ai-card: #ffffff;
    --ai-radius: 8px;
    --ai-shadow: 0 16px 44px rgba(15, 23, 42, .14);
}

.ai-page { background: #f7fafb; }
.ai-page .v-nav { background: rgba(255,255,255,.94); }

.ai-shell {
    min-height: calc(100vh - 86px);
    padding: 112px 0 56px;
    background:
        linear-gradient(135deg, rgba(6,61,91,.96), rgba(14,116,144,.86)),
        url('/frontend/images/hero-medical.png') center/cover no-repeat;
}

.ai-shell__inner {
    display: grid;
    grid-template-columns: minmax(320px, .82fr) minmax(0, 1.18fr);
    gap: 22px;
    align-items: stretch;
}

.ai-side,
.ai-chat {
    border: 1px solid rgba(255,255,255,.22);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    overflow: hidden;
}

.ai-side {
    background: rgba(255,255,255,.95);
    color: var(--ai-ink);
    display: flex;
    flex-direction: column;
}

.ai-side__media {
    position: relative;
    aspect-ratio: 1.35;
    background: var(--ai-navy);
}

.ai-side__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-side__status {
    position: absolute;
    inset-inline-start: 18px;
    bottom: 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: rgba(255,255,255,.94);
    color: var(--ai-navy);
    border-radius: var(--ai-radius);
    font-weight: 900;
}

.ai-side__status i { color: var(--ai-green-dark); }
.ai-side__body { padding: 24px; }
.ai-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ai-green-dark);
    font-weight: 900;
}
.ai-side h1 {
    margin: 12px 0 12px;
    color: var(--ai-navy);
    font-size: 34px;
    line-height: 1.2;
    font-weight: 900;
    letter-spacing: 0;
}
.ai-side p {
    margin: 0;
    color: var(--ai-muted);
    line-height: 1.85;
}
.ai-side__metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    margin-top: 24px;
    background: var(--ai-line);
    border: 1px solid var(--ai-line);
    border-radius: var(--ai-radius);
    overflow: hidden;
}
.ai-side__metrics div { background: #fff; padding: 14px 10px; text-align: center; }
.ai-side__metrics strong { display: block; color: var(--ai-navy); font-size: 20px; font-weight: 900; }
.ai-side__metrics span { color: var(--ai-muted); font-size: 13px; font-weight: 800; }

.ai-chat {
    background: var(--ai-card);
    min-height: 680px;
    max-height: calc(100vh - 150px);
    display: grid;
    grid-template-rows: auto 1fr auto auto auto;
}

.ai-chat__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--ai-line);
    background: #fff;
}

.ai-chat__identity,
.ai-message,
.ai-quick,
.ai-composer {
    display: flex;
    align-items: center;
}

.ai-chat__identity { gap: 12px; }
.ai-chat__avatar,
.ai-message__avatar {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ai-radius);
    background: #eaf6d9;
    color: var(--ai-green-dark);
    flex: 0 0 auto;
}
.ai-chat__identity h2 { margin: 0 0 4px; color: var(--ai-navy); font-size: 20px; font-weight: 900; }
.ai-chat__identity p { margin: 0; color: var(--ai-muted); font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.ai-live-dot { width: 8px; height: 8px; border-radius: 99px; background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.14); }
.ai-chat__back {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ai-line);
    border-radius: var(--ai-radius);
    color: var(--ai-navy);
    background: #fff;
}

.ai-chat__messages {
    padding: 22px;
    overflow-y: auto;
    background:
        linear-gradient(180deg, #f8fbfd 0%, #ffffff 100%);
}

.ai-message {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}
.ai-message--user { flex-direction: row-reverse; }
.ai-message__content { max-width: 76%; }
.ai-message--user .ai-message__content { display: grid; justify-items: end; }
.ai-message__bubble {
    padding: 13px 15px;
    border: 1px solid var(--ai-line);
    border-radius: var(--ai-radius);
    background: #fff;
    color: var(--ai-ink);
    line-height: 1.8;
    box-shadow: 0 6px 18px rgba(15,23,42,.06);
}
.ai-message--user .ai-message__bubble {
    background: var(--ai-navy);
    color: #fff;
    border-color: var(--ai-navy);
}
.ai-message__bubble p { margin: 0 0 8px; }
.ai-message__bubble p:last-child { margin-bottom: 0; }
.ai-message__bubble a { color: var(--ai-green-dark); font-weight: 900; }
.ai-message--user .ai-message__bubble a { color: #d8f7ad; }
.ai-message time,
.ai-message__content time { display: block; margin-top: 6px; color: var(--ai-muted); font-size: 12px; }

.ai-quick {
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-top: 1px solid var(--ai-line);
    background: #fff;
}
.ai-quick__btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid var(--ai-line);
    border-radius: var(--ai-radius);
    color: var(--ai-navy);
    background: #f8fbfd;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}
.ai-quick__btn:hover { background: #eaf6d9; border-color: #cde9a7; }
.ai-quick__btn i { color: var(--ai-green-dark); }

.ai-typing {
    padding: 0 22px 12px;
    display: flex;
    gap: 6px;
}
.ai-typing[hidden] { display: none; }
.ai-typing span {
    width: 8px;
    height: 8px;
    border-radius: 99px;
    background: var(--ai-green);
    animation: aiTyping 1s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: .14s; }
.ai-typing span:nth-child(3) { animation-delay: .28s; }
@keyframes aiTyping {
    0%, 80%, 100% { transform: translateY(0); opacity: .45; }
    40% { transform: translateY(-5px); opacity: 1; }
}

.ai-composer {
    gap: 10px;
    padding: 16px 18px;
    border-top: 1px solid var(--ai-line);
    background: #fff;
}
.ai-composer input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--ai-line);
    border-radius: var(--ai-radius);
    padding: 11px 13px;
    font: inherit;
    color: var(--ai-ink);
    background: #f8fbfd;
}
.ai-composer input:focus { outline: 3px solid rgba(141,198,63,.2); border-color: var(--ai-green); background: #fff; }
.ai-composer__send {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: var(--ai-radius);
    background: var(--ai-green);
    color: #052f20;
    cursor: pointer;
    font-size: 16px;
    flex: 0 0 auto;
}
.ai-composer__send:disabled { opacity: .55; cursor: wait; }
html[dir="rtl"] .ai-composer__send i { transform: rotate(180deg); }

@media (max-width: 1100px) {
    .ai-shell__inner { grid-template-columns: 1fr; }
    .ai-side { display: none; }
    .ai-chat { min-height: 720px; }
}

@media (max-width: 768px) {
    .ai-shell { padding: 92px 0 24px; }
    .ai-chat { min-height: calc(100vh - 118px); max-height: none; }
    .ai-chat__messages { padding: 16px; }
    .ai-message__content { max-width: 84%; }
    .ai-quick { display: grid; grid-template-columns: repeat(2, 1fr); }
    .ai-quick__btn { justify-content: center; }
}

@media (max-width: 480px) {
    .ai-quick { grid-template-columns: 1fr; }
    .ai-chat__identity h2 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
