/* ═══════════════════════════════════════════════════════
   CopilotChat — Template 12 Canvas Theme
   Palette: Pearl white + sky blue gradient mesh
   Font: Figtree (loaded via _Layout)
═══════════════════════════════════════════════════════ */

:root {
    --bg-b: #e4f0fb;
    --surface: rgba(255,255,255,0.92);
    --surface-solid: #ffffff;
    --border: rgba(0,0,0,0.06);
    --accent: #2b8fd4;
    --accent-2: #4aaee8;
    --accent-pale: #e4f2fb;
    --accent-glow: rgba(43,143,212,0.18);
    --sky: #74b9ff;
    --text-primary: #0d1b2a;
    --text-secondary: #3d5a6e;
    --text-muted: #8aacbe;
    --user-bg: #1a6fb5;
    --radius-2xl: 28px;
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; }

img { border: 0; display: block; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Figtree', 'Segoe UI', sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ── Animated background ── */
.bg-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: linear-gradient(145deg, #f8fbff 0%, #eaf4fd 35%, #ddeefa 65%, #e8f5ff 100%);
}
.bg-canvas::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 55% at 8% 12%,  rgba(43,143,212,0.13) 0%, transparent 60%),
        radial-gradient(ellipse 55% 65% at 95% 5%,  rgba(100,180,255,0.10) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 50% 110%, rgba(43,143,212,0.09) 0%, transparent 55%),
        radial-gradient(ellipse 45% 45% at 90% 85%,  rgba(180,220,255,0.12) 0%, transparent 55%);
    pointer-events: none;
}
.bg-canvas::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(43,143,212,0.18) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%);
    opacity: 0.35;
    pointer-events: none;
}
.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: blobFloat 26s ease-in-out infinite alternate;
    pointer-events: none;
}
.bg-blob-1 {
    width: 750px; height: 650px;
    background: radial-gradient(circle, rgba(43,143,212,0.38) 0%, rgba(100,180,255,0.22) 50%, transparent 70%);
    top: -220px; left: -180px;
    animation-duration: 28s;
}
.bg-blob-2 {
    width: 580px; height: 520px;
    background: radial-gradient(circle, rgba(74,174,232,0.35) 0%, transparent 65%);
    top: -80px; right: -120px;
    animation-duration: 22s;
    animation-delay: -9s;
    animation-direction: alternate-reverse;
}
.bg-blob-3 {
    width: 520px; height: 480px;
    background: radial-gradient(circle, rgba(147,210,255,0.40) 0%, transparent 65%);
    top: 35%; left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 32s;
    animation-delay: -16s;
}
.bg-blob-4 {
    width: 420px; height: 420px;
    background: radial-gradient(circle, rgba(43,143,212,0.28) 0%, transparent 65%);
    bottom: -80px; right: -60px;
    animation-duration: 24s;
    animation-delay: -5s;
    animation-direction: alternate-reverse;
}
@keyframes blobFloat {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(40px, 28px) scale(1.12); }
}

/* ── App layout ── */
.app-layout {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    animation: appIn 0.6s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes appIn { from{opacity:0} to{opacity:1} }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ── Header ── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px 10px;
    flex-shrink: 0;
    background: transparent;
    border-bottom: none;
    box-shadow: none;
    z-index: 10;
}
.chat-header-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
}
.chat-header-title { display: flex; flex-direction: column; gap: 4px; }
.agent-header-identity { display: flex; align-items: center; gap: 10px; }

.agent-brand-ring {
    width: auto;
    height: auto;
    background: none;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    padding: 0;
}
.agent-brand-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    outline: none;
    -webkit-appearance: none;
    filter: none;
}

.agent-header-text { display: flex; flex-direction: column; gap: 2px; }
.agent-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.agent-quote {
    display: block;
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.chat-header-right { display: flex; align-items: center; gap: 8px; }

.header-btn {
    width: 32px; height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.8);
    background: var(--surface);
    backdrop-filter: blur(12px);
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.header-btn:hover { color: var(--text-secondary); transform: scale(1.05); }
.header-btn svg { width: 13px; height: 13px; }

/* ── Connection status ── */
#connection-status {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.9);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
#connection-status .label { font-size: 0.7rem; }
#connection-status::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #d1d5db;
    flex-shrink: 0;
}
#connection-status.connected {
    color: #16a34a;
    box-shadow: 0 2px 8px rgba(34,197,94,0.15);
}
#connection-status.connected::before {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34,197,94,0.8);
    animation: statusPulse 2s ease-in-out infinite;
}
#connection-status.error { color: #dc2626; }
#connection-status.error::before { background: #ef4444; }
@keyframes statusPulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.8)} }

/* ── Messages ── */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: transparent;
    /* No scroll-behavior: smooth — prevents layout bounce */
    /* Firefox scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(43,143,212,0.45) transparent;
}
/* WebKit / Chromium scrollbar */
.messages-container::-webkit-scrollbar {
    width: 10px;
}
.messages-container::-webkit-scrollbar-track {
    background: transparent;
    margin: 6px 0;
}
.messages-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background 0.2s;
}
.messages-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--user-bg) 0%, var(--accent) 100%);
    background-clip: content-box;
}

.messages-inner {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 16px 32px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-wrap: break-word;
    word-break: break-word;
    box-sizing: border-box;
}

/* ── Message rows ── */
.message {
    display: flex;
    gap: 10px;
    padding: 0;
    border-top: none;
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
}
@keyframes msgFloat { from{opacity:0} to{opacity:1} }
.message + .message { border-top: none; }
.message.user { flex-direction: row-reverse; }

/* Hide avatars in conversation — header brand icon remains */
.message .message-avatar { display: none; }

/* ── Message content / bubbles ── */
.message-content {
    width: fit-content;
    max-width: 560px;
    padding: 10px 0;
    font-size: 0.9rem;
    line-height: 1.78;
    color: var(--text-primary);
    /* Agent messages: no bubble — text sits on canvas */
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
/* User messages keep their bubble, right-aligned */
.message.user .message-content {
    width: fit-content;
    max-width: 480px;
    padding: 11px 16px;
    background: var(--user-bg);
    color: white;
    border: none;
    border-radius: var(--radius-xl);
    border-bottom-right-radius: 5px;
    box-shadow: 0 6px 20px rgba(26,111,181,0.3);
    text-align: left;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.message-content p { margin: 0 0 6px; }
.message-content p:last-child { margin-bottom: 0; }

/* Key: Value rows — for structured bot responses like ticket details */
.msg-kv-row {
    display: flex;
    gap: 8px;
    padding: 3px 0;
    line-height: 1.55;
    align-items: baseline;
}
.msg-kv-label {
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.82rem;
    min-width: 110px;
}
.msg-kv-value {
    color: var(--text-primary);
    font-size: 0.875rem;
    word-break: break-word;
}
.message.user .msg-kv-label { color: rgba(255,255,255,0.75); }
.message.user .msg-kv-value { color: white; }

/* Spacer between sections */
.msg-spacer { height: 6px; }
.message-content a,
.msg-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(43,143,212,0.35);
    transition: border-color 0.15s, color 0.15s;
    word-break: break-all;
}
.message-content a:hover,
.msg-link:hover {
    color: var(--accent-2);
    border-bottom-color: var(--accent);
}
.message.user .message-content a,
.message.user .msg-link {
    color: rgba(255,255,255,0.9);
    border-bottom-color: rgba(255,255,255,0.4);
}
.message-content h1, .message-content h2, .message-content h3 {
    color: var(--text-primary); font-weight: 700; margin: 14px 0 6px; line-height: 1.3;
}
.message-content h1 { font-size: 1.05rem; }
.message-content h2 { font-size: 0.97rem; }
.message-content h3 { font-size: 0.9rem; }
.message-content hr { border: none; border-top: 1px solid rgba(43,143,212,0.15); margin: 12px 0; }
.message-content ul, .message-content ol { margin: 4px 0 8px; padding-left: 20px; }
.message-content li { margin-bottom: 2px; line-height: 1.6; }
.message-content li p { margin: 0; }
.message-content code {
    background: rgba(43,143,212,0.08);
    border: 1px solid rgba(43,143,212,0.15);
    padding: 2px 6px; border-radius: 4px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.85em;
}
.message-content pre {
    background: rgba(43,143,212,0.06);
    border: 1px solid rgba(43,143,212,0.12);
    border-radius: 10px; padding: 14px; overflow-x: auto; margin: 10px 0;
}
.message-content pre code { background: none; border: none; padding: 0; }

/* ── Typing indicator — shimmer wave bar ── */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 6px 0;
    height: 32px;
}
/* Single pill with a travelling light sweep */
.typing-indicator::after {
    content: '';
    display: block;
    width: 80px;
    height: 10px;
    border-radius: 99px;
    background: linear-gradient(
        90deg,
        rgba(43,143,212,0.12) 0%,
        rgba(43,143,212,0.12) 20%,
        rgba(147,210,255,0.7) 40%,
        rgba(255,255,255,0.9) 50%,
        rgba(147,210,255,0.7) 60%,
        rgba(43,143,212,0.12) 80%,
        rgba(43,143,212,0.12) 100%
    );
    background-size: 200% 100%;
    animation: shimmerSweep 1.6s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(43,143,212,0.2);
}
/* Hide the old span dots */
.typing-indicator span { display: none; }

@keyframes shimmerSweep {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

/* ── Input area ── */
.input-area {
    padding: 0;
    background: transparent;
    border-top: none;
    flex-shrink: 0;
}
.input-wrapper {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 0 32px 20px;
    position: relative;
    margin-top: 4px;
}

/* Circulating light ring */
@property --angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}
.input-glow-ring {
    position: relative;
    border-radius: var(--radius-2xl);
    padding: 2px;
    background: conic-gradient(
        from var(--angle, 0deg),
        rgba(43,143,212,0)     0%,
        rgba(43,143,212,0)    30%,
        rgba(147,210,255,0.9) 45%,
        rgba(255,255,255,1)   50%,
        rgba(147,210,255,0.9) 55%,
        rgba(43,143,212,0)    70%,
        rgba(43,143,212,0)   100%
    );
    animation: rotateBorder 3s linear infinite;
    box-shadow: 0 0 18px rgba(43,143,212,0.25);
}
@keyframes rotateBorder { to { --angle: 360deg; } }

/* The pill itself */
#input-box {
    background: var(--surface);
    backdrop-filter: blur(28px) saturate(1.8);
    -webkit-backdrop-filter: blur(28px) saturate(1.8);
    border-radius: calc(var(--radius-2xl) - 2px);
    padding: 14px 16px 12px;
    box-shadow:
        0 8px 40px rgba(0,0,0,0.07),
        0 2px 8px rgba(0,0,0,0.04),
        0 0 0 1px rgba(255,255,255,0.5) inset;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border: none;
    transition: box-shadow 0.2s;
}
#input-box:focus-within {
    box-shadow:
        0 8px 40px rgba(0,0,0,0.07),
        0 0 0 1px rgba(255,255,255,0.5) inset;
}

#user-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: 'Figtree', 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    color: var(--text-primary);
    resize: none;
    max-height: 200px;
    line-height: 1.6;
    padding: 0;
    align-self: center;
}
#user-input::placeholder { color: var(--text-muted); }
#user-input {
    scrollbar-width: thin;
    scrollbar-color: rgba(43,143,212,0.4) transparent;
}
#user-input::-webkit-scrollbar { width: 8px; }
#user-input::-webkit-scrollbar-track { background: transparent; }
#user-input::-webkit-scrollbar-thumb {
    background: rgba(43,143,212,0.35);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: content-box;
}
#user-input::-webkit-scrollbar-thumb:hover { background: rgba(43,143,212,0.6); background-clip: content-box; }

.input-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
}

/* Attach button */
.input-btn {
    width: 36px; height: 36px;
    border-radius: 11px;
    border: 1.5px solid rgba(43,143,212,0.15);
    background: rgba(43,143,212,0.05);
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.input-btn:hover { background: rgba(43,143,212,0.1); color: var(--accent); border-color: rgba(43,143,212,0.3); }
.input-btn svg { width: 15px; height: 15px; }

/* Send button */
.input-btn.send-btn {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
}
.input-btn.send-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px var(--accent-glow); }
.input-btn.send-btn:disabled {
    background: rgba(43,143,212,0.2);
    box-shadow: none;
    color: rgba(255,255,255,0.5);
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    text-align: center;
    margin-top: 8px;
    font-size: 0.67rem;
    color: var(--text-muted);
}

/* ── Loading splash ── */
#loading-splash {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #f8fbff 0%, #eaf4fd 50%, #ddeefa 100%);
    z-index: 1000;
    transition: opacity 0.3s;
}
#loading-splash.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(43,143,212,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ── Error overlay ── */
#webchat-error {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(13,27,42,0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
}
.error-box {
    background: var(--surface-solid);
    border: 1px solid rgba(43,143,212,0.15);
    border-radius: var(--radius-lg);
    padding: 36px 44px;
    max-width: 480px; width: 90%;
    text-align: center;
    box-shadow: 0 8px 40px rgba(43,143,212,0.15);
}
.error-box h3 { margin: 0 0 12px; font-size: 1.05rem; color: var(--text-primary); font-weight: 700; }
.error-box p { margin: 0 0 24px; font-size: 0.875rem; color: var(--text-secondary); word-break: break-word; }
.error-box button {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: white; border: none; border-radius: var(--radius-sm);
    padding: 10px 32px; font-size: 0.875rem; cursor: pointer;
    box-shadow: 0 4px 14px var(--accent-glow); transition: opacity 0.15s;
}
.error-box button:hover { opacity: 0.9; }

/* ── Setup warning ── */
#setup-warning {
    max-width: 680px; margin: 60px auto; padding: 32px;
    background: var(--surface-solid);
    border: 1px solid rgba(43,143,212,0.15);
    border-radius: var(--radius-lg);
    font-size: 0.9rem; color: var(--text-primary);
    box-shadow: 0 4px 24px rgba(43,143,212,0.1);
}
#setup-warning h2 { margin: 0 0 16px; font-size: 1.1rem; }
#setup-warning table { border-collapse: collapse; width: 100%; margin-top: 16px; }
#setup-warning td { padding: 8px 12px; border-bottom: 1px solid rgba(43,143,212,0.1); color: var(--text-secondary); }
#setup-warning code {
    background: var(--accent-pale); padding: 2px 6px; border-radius: 4px;
    font-family: 'Cascadia Code', 'Consolas', monospace; color: var(--accent);
}

/* ── Adaptive cards ── */
.adaptive-card-wrapper {
    margin-top: 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(43,143,212,0.15);
    box-shadow: 0 4px 20px rgba(43,143,212,0.1);
    width: min(520px, 80vw);
}
.adaptive-card-wrapper .ac-container { background: var(--surface-solid) !important; padding: 18px !important; }
.adaptive-card-wrapper .ac-textBlock { color: var(--text-primary) !important; }
.adaptive-card-wrapper * { color: var(--text-primary); }
.adaptive-card-wrapper .ac-input {
    background: var(--bg-b) !important;
    border: 1.5px solid rgba(43,143,212,0.15) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-primary) !important;
    padding: 9px 12px !important;
    font-size: 0.875rem !important;
}
.adaptive-card-wrapper .ac-input:focus {
    border-color: var(--accent) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px var(--accent-glow) !important;
}
.adaptive-card-wrapper .ac-pushButton {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
    padding: 10px 22px !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 14px var(--accent-glow) !important;
    transition: opacity 0.15s !important;
}
.adaptive-card-wrapper .ac-pushButton:hover { opacity: 0.9 !important; }
.adaptive-card-wrapper .ac-input-label,
.adaptive-card-wrapper .ac-input-label span,
.adaptive-card-wrapper label,
.adaptive-card-wrapper .ac-label {
    color: var(--text-secondary) !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    margin-bottom: 4px !important;
}
.adaptive-card-wrapper .ac-input-label .ac-input-label-required { color: #ef4444 !important; }

/* Hero card buttons */
.hero-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hero-btn {
    background: var(--accent-pale);
    border: 1px solid rgba(43,143,212,0.2);
    color: var(--accent);
    border-radius: 20px; padding: 7px 16px;
    font-size: 0.85rem; cursor: pointer; transition: all 0.15s;
}
.hero-btn:hover { background: rgba(43,143,212,0.15); border-color: rgba(43,143,212,0.35); }

/* ── Chat images ── */
.image-gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-image {
    max-width: 320px; max-height: 260px;
    border-radius: var(--radius-md); object-fit: cover;
    border: 1px solid rgba(43,143,212,0.15);
    box-shadow: 0 4px 16px rgba(43,143,212,0.1);
}

/* ── Drop overlay ── */
#drop-overlay {
    position: absolute; inset: 0;
    background: rgba(43,143,212,0.05);
    border: 2px dashed rgba(43,143,212,0.4);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s; z-index: 50;
}
#drop-overlay.visible { opacity: 1; pointer-events: auto; }
.drop-content { text-align: center; color: var(--accent); }
.drop-content .drop-icon { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.drop-content p { margin: 0; font-size: 0.9rem; font-weight: 500; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .messages-inner { padding: 12px 16px; }
    .input-wrapper { padding: 0 12px 16px; }
    .chat-header { padding: 12px 16px 8px; }
    .message-content { max-width: 85%; }
}
