/* ============================================================
   SGE-IA — frontend canônico multi-tenant
   Syne × DM Sans
   ============================================================ */

/* ----------------------------------------------------------
   CSS Custom Properties
   ---------------------------------------------------------- */
:root {
    /* Brand */
    --blue:          #006437;
    --blue-bright:   #2B82C4;
    --blue-dim:      rgba(0, 92, 163, 0.18);
    --blue-glow:     rgba(0, 92, 163, 0.28);
    --green:         #FFDF00;
    --green-bright:  #91D66C;
    --green-dim:     rgba(125, 195, 84, 0.14);
    --green-glow:    rgba(125, 195, 84, 0.22);
    --yellow:        #1B4D9B;
    --yellow-dim:    rgba(252, 209, 5, 0.14);

    /* Backgrounds */
    --bg:       #060d18;
    --bg-2:     #0a1423;
    --bg-glass: rgba(6, 12, 22, 0.82);

    /* Surfaces (glass layers) */
    --s0: rgba(255, 255, 255, 0.02);
    --s1: rgba(255, 255, 255, 0.04);
    --s2: rgba(255, 255, 255, 0.065);
    --s3: rgba(255, 255, 255, 0.09);

    /* Borders */
    --border:        rgba(255, 255, 255, 0.075);
    --border-hi:     rgba(0, 92, 163, 0.32);
    --border-green:  rgba(125, 195, 84, 0.28);

    /* Text */
    --t1: #dce9f8;
    --t2: rgba(220, 233, 248, 0.58);
    --t3: rgba(220, 233, 248, 0.34);
    --t4: rgba(220, 233, 248, 0.18);

    /* Semantic (JS-generated HTML uses these via CSS classes) */
    --color-primary:       var(--blue);
    --color-primary-light: var(--blue-bright);
    --color-primary-dark:  #00497F;
    --color-accent:        var(--green);
    --color-accent-dark:   #4F832F;
    --color-accent-light:  var(--green-bright);
    --color-bg:            var(--bg);
    --color-bg-alt:        var(--s1);
    --color-white:         #e2eaf5;
    --color-border:        var(--border);
    --color-border-focus:  var(--blue-bright);
    --color-text:          var(--t1);
    --color-text-secondary:var(--t2);
    --color-text-muted:    var(--t3);
    --color-text-light:    var(--t4);
    --color-user-bubble-bg:   var(--blue);
    --color-user-bubble-text: #ffffff;
    --color-assistant-bubble-bg:     var(--s1);
    --color-assistant-bubble-border: var(--border);
    --color-assistant-bubble-text:   var(--t1);
    --color-error:        #f87171;
    --color-error-bg:     rgba(248, 113, 113, 0.08);
    --color-error-border: rgba(248, 113, 113, 0.25);
    --color-success:      var(--green-bright);
    --color-source-border: var(--green-bright);
    --color-source-bg:    rgba(125, 195, 84, 0.06);

    /* Typography */
    --font-display: 'Syne', system-ui, sans-serif;
    --font-body:    'DM Sans', system-ui, sans-serif;
    --font-family:  var(--font-body);

    --font-size-xs:   0.68rem;
    --font-size-sm:   0.8rem;
    --font-size-base: 0.92rem;
    --font-size-md:   1rem;
    --font-size-lg:   1.1rem;
    --font-size-xl:   1.25rem;
    --font-size-2xl:  1.5rem;

    --line-height-tight:   1.3;
    --line-height-base:    1.65;
    --line-height-relaxed: 1.82;

    /* Spacing */
    --space-1:  0.25rem;
    --space-2:  0.5rem;
    --space-3:  0.75rem;
    --space-4:  1rem;
    --space-5:  1.25rem;
    --space-6:  1.5rem;
    --space-8:  2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Layout */
    --header-height: 60px;
    --sidebar-width: 300px;

    /* Radii */
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   18px;
    --radius-xl:   22px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:      0 1px 4px rgba(0,0,0,0.35);
    --shadow-md:      0 4px 18px rgba(0,0,0,0.4);
    --shadow-lg:      0 14px 44px rgba(0,0,0,0.5);
    --shadow-sidebar: 4px 0 24px rgba(0,0,0,0.45);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 260ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 420ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--t1);
    background-color: var(--bg);
    height: 100dvh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

a {
    color: var(--blue-bright);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--green-bright);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: var(--font-size-xs);
    font-family: monospace;
    background: var(--s2);
    border: 1px solid var(--border);
    border-radius: 4px;
    line-height: 1.6;
    color: var(--t2);
}

/* ----------------------------------------------------------
   Animated Background
   ---------------------------------------------------------- */
.bg-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--bg);
    pointer-events: none;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    animation: orbFloat 20s ease-in-out infinite;
}

.bg-orb--1 {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle at center, rgba(0, 92, 163, 0.2), transparent 68%);
    top: -260px;
    left: -160px;
    animation-duration: 24s;
}

.bg-orb--2 {
    width: 560px;
    height: 560px;
    background: radial-gradient(circle at center, rgba(125, 195, 84, 0.16), transparent 68%);
    bottom: -180px;
    right: -100px;
    animation-delay: -12s;
    animation-duration: 20s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0,    0)   scale(1);    }
    33%       { transform: translate(28px, -20px) scale(1.05); }
    66%       { transform: translate(-20px, 14px) scale(0.96); }
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,0.028) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: radial-gradient(ellipse 85% 85% at 50% 50%, black 30%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 85% 85% at 50% 50%, black 30%, transparent 100%);
}

/* Content layers sit above canvas */
.header,
.layout {
    position: relative;
    z-index: 1;
}

/* ----------------------------------------------------------
   Header
   ---------------------------------------------------------- */
.header {
    height: var(--header-height);
    background: rgba(5, 11, 20, 0.84);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
    box-shadow: 0 4px 28px rgba(0,0,0,0.4);
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--blue) 30%,
        var(--yellow) 50%,
        var(--green) 68%,
        transparent 100%);
    opacity: 0.38;
}

.header-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 var(--space-5);
    gap: var(--space-4);
}

/* Sidebar toggle (mobile) */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    padding: var(--space-2);
    transition: background var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--s2);
}

.hamburger-line {
    display: block;
    width: 18px;
    height: 1.5px;
    background: var(--t1);
    border-radius: 2px;
    transition: transform var(--transition-base), opacity var(--transition-fast);
}

/* Logo */
.header-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
}

.logo-mark {
    flex-shrink: 0;
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tenant-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--green-bright);
    font: 700 0.68rem/1 var(--font-display);
    letter-spacing: 0.04em;
}

.tenant-logo-fallback[hidden] {
    display: none;
}

.agent-avatar {
    display: block;
    object-fit: contain;
    border-radius: 0;
}

.agent-avatar[hidden] {
    display: none;
}

.agent-avatar--header {
    position: relative;
    z-index: 1;
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
}

/* Spinning gradient ring around logo */
.logo-ring {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(
        rgba(0, 92, 163, 0.65) 0deg,
        rgba(252, 209, 5, 0.58) 105deg,
        rgba(125, 195, 84, 0.55) 175deg,
        rgba(0, 92, 163, 0.1) 280deg,
        rgba(0, 92, 163, 0.65) 360deg
    );
    -webkit-mask: radial-gradient(transparent 65%, black 65%);
    mask: radial-gradient(transparent 65%, black 65%);
    animation: ringRotate 7s linear infinite;
}

@keyframes ringRotate {
    to { transform: rotate(360deg); }
}

.header-titles {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.header-brand {
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--blue-bright);
    text-transform: uppercase;
    line-height: 1;
}

.header-title {
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--t1);
    line-height: var(--line-height-tight);
    letter-spacing: 0.04em;
}

/* Status badge */
.header-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--t3);
    font-weight: 500;
    flex-shrink: 0;
    padding: 4px 12px;
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.18);
    animation: pulseDot 2.8s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.18); }
    50%       { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0.06); }
}

/* ----------------------------------------------------------
   Layout
   ---------------------------------------------------------- */
.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ----------------------------------------------------------
   Sidebar
   ---------------------------------------------------------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 49;
    backdrop-filter: blur(4px);
}

.sidebar {
    width: var(--sidebar-width);
    background: rgba(7, 13, 24, 0.78);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: transform var(--transition-base);
}

.sidebar-header {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-family: var(--font-display);
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--t3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Filters */
.sidebar-filters {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.filter-group--half {
    flex: 1;
}

.filter-row {
    display: flex;
    gap: var(--space-2);
}

.filter-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--t3);
    pointer-events: none;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--s2);
    color: var(--t1);
    font-size: var(--font-size-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.filter-search {
    padding-left: 32px;
}

.filter-input::placeholder {
    color: var(--t4);
}

.filter-input:focus,
.filter-select:focus {
    border-color: rgba(0, 92, 163, 0.45);
    box-shadow: 0 0 0 3px rgba(0, 92, 163, 0.1);
}

.filter-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23556677' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

.filter-select option {
    background: #0d1929;
    color: var(--t1);
}

/* Document list */
.document-list-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.document-list-container::-webkit-scrollbar {
    width: 3px;
}

.document-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.document-list-container::-webkit-scrollbar-thumb {
    background: var(--s3);
    border-radius: 2px;
}

.document-list {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.doc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-10) var(--space-4);
    color: var(--t3);
    font-size: var(--font-size-sm);
    flex-direction: column;
}

.doc-loading-spinner {
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--border);
    border-top-color: var(--blue-bright);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.doc-empty {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--t3);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
}

.doc-empty-icon {
    margin-bottom: var(--space-3);
    opacity: 0.25;
    display: flex;
    justify-content: center;
}

/* Document item */
.doc-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-fast);
    text-align: left;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.doc-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--blue-bright), var(--green-bright));
    opacity: 0;
    transition: opacity var(--transition-fast);
    border-radius: 0 2px 2px 0;
}

.doc-item:hover {
    border-color: rgba(0, 92, 163, 0.28);
    background: var(--s2);
    box-shadow: 0 0 0 1px rgba(0,92,163,0.08), 0 4px 18px rgba(0,0,0,0.3);
}

.doc-item:hover::before {
    opacity: 1;
}

.doc-item:focus-visible {
    outline: 2px solid var(--blue-bright);
    outline-offset: 2px;
}

.doc-item-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    justify-content: space-between;
}

.doc-item-title {
    font-size: var(--font-size-sm);
    font-weight: 400;
    color: var(--t1);
    line-height: var(--line-height-tight);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc-pdf-link {
    flex-shrink: 0;
    color: var(--t3);
    transition: color var(--transition-fast), background var(--transition-fast);
    display: flex;
    align-items: center;
    padding: 3px;
    border-radius: 4px;
    text-decoration: none;
}

.doc-pdf-link:hover {
    color: var(--blue-bright);
    background: var(--s3);
}

.doc-pdf-link svg {
    display: block;
}

.doc-item-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.doc-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    font-family: var(--font-display);
}

.doc-badge--area {
    background: var(--blue-dim);
    color: var(--blue-bright);
    border: 1px solid rgba(0, 92, 163, 0.22);
}

.doc-badge--type {
    background: var(--green-dim);
    color: var(--green-bright);
    border: 1px solid rgba(125, 195, 84, 0.22);
}

.doc-date {
    font-size: var(--font-size-xs);
    color: var(--t3);
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ----------------------------------------------------------
   Chat Area
   ---------------------------------------------------------- */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
    min-width: 0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 4px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--s3);
    border-radius: 3px;
}

.messages {
    padding: var(--space-8) var(--space-6) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    min-height: 100%;
}

/* ----------------------------------------------------------
   Message Bubbles
   ---------------------------------------------------------- */
.message {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 78%;
    animation: slideUp 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Legacy alias used by old CSS references */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* User message */
.message--user {
    align-self: flex-end;
    align-items: flex-end;
}

.message--user .message-bubble {
    background: linear-gradient(145deg, #00497F, var(--blue) 55%, #1476BA);
    color: #ffffff;
    border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl);
    padding: var(--space-3) var(--space-5);
    box-shadow:
        0 4px 22px rgba(0, 92, 163, 0.38),
        0 1px 4px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(43, 130, 196, 0.3);
}

/* Assistant message */
.message--assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.message--assistant .message-bubble {
    background: rgba(10, 18, 34, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--t1);
    border: 1px solid var(--border);
    border-left: 2px solid var(--blue);
    border-radius: var(--radius-xl) var(--radius-xl) var(--radius-xl) var(--radius-sm);
    padding: var(--space-4) var(--space-5);
    box-shadow: 0 4px 22px rgba(0, 0, 0, 0.3);
}

/* Welcome / system message */
.message--welcome {
    align-self: center;
    max-width: 580px;
    width: 100%;
}

.message--welcome .message-bubble {
    background: rgba(8, 16, 30, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 92, 163, 0.22);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
    text-align: center;
    box-shadow:
        0 0 48px rgba(0, 92, 163, 0.07),
        0 8px 36px rgba(0, 0, 0, 0.35);
}

.message--welcome .welcome-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
    animation: welcomeGlow 3.5s ease-in-out infinite;
}

.message--welcome .agent-avatar--welcome {
    width: 72px;
    height: 72px;
    border: 2px solid rgba(43, 130, 196, 0.42);
    background: var(--s2);
    box-shadow: 0 0 26px rgba(0, 92, 163, 0.18);
}

@keyframes welcomeGlow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(0, 92, 163, 0.45)); }
    50%       { filter: drop-shadow(0 0 18px rgba(125, 195, 84, 0.52)); }
}

.message--welcome .welcome-title {
    font-family: var(--font-display);
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--t1);
    margin-bottom: var(--space-1);
    letter-spacing: 0.04em;
}

.message--welcome .welcome-role {
    margin: 0 0 var(--space-3);
    color: var(--blue-bright);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    line-height: 1.45;
    text-transform: uppercase;
}

.message--welcome .welcome-bio {
    max-width: 470px;
    margin: 0 auto var(--space-3);
    color: var(--t3);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
}

.message--welcome .welcome-label {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: var(--blue-bright);
    text-transform: uppercase;
    margin-bottom: var(--space-1);
}

.message--welcome .welcome-text {
    font-size: var(--font-size-base);
    color: var(--t2);
    line-height: var(--line-height-relaxed);
    margin-bottom: var(--space-5);
}

/* Suggestion chips */
.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: center;
    margin-top: var(--space-2);
}

.area-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    text-align: left;
}

.area-options--attention {
    animation: shake 0.42s ease;
}

.welcome-capabilities {
    display: grid;
    gap: var(--space-3);
}

.capabilities-state {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-4);
    color: var(--t2);
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    line-height: 1.55;
    text-align: left;
}

.capabilities-state strong {
    color: var(--t1);
}

.capabilities-state--unavailable {
    border-color: var(--color-error-border);
}

.capabilities-retry {
    justify-self: start;
    padding: 7px 12px;
    color: var(--t1);
    background: var(--s2);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 700;
}

.capabilities-retry:hover,
.capabilities-retry:focus-visible {
    color: #fff;
    background: var(--blue);
    outline: 2px solid var(--blue-bright);
    outline-offset: 2px;
}

.capabilities-retry:disabled {
    cursor: wait;
    opacity: 0.65;
}

.capability-freshness {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    color: var(--t3);
    font-size: var(--font-size-xs);
    text-align: left;
}

.capability-freshness span,
.capability-freshness time {
    padding: 4px 8px;
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
}

.area-option {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: var(--space-3) var(--space-4);
    color: var(--t1);
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: left;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.area-option:hover,
.area-option:focus-visible {
    border-color: var(--border-hi);
    background: var(--s2);
    transform: translateY(-1px);
    outline: none;
}

.area-option--selected {
    border-color: var(--green-bright);
    background: var(--green-dim);
    box-shadow: 0 0 0 2px rgba(125, 195, 84, 0.08);
}

.area-option strong {
    font-family: var(--font-display);
    font-size: var(--font-size-sm);
}

.area-option span {
    color: var(--t3);
    font-size: var(--font-size-xs);
    line-height: 1.35;
}

.area-option .area-option-status {
    align-self: flex-start;
    padding: 2px 7px;
    color: var(--green-bright);
    background: var(--green-dim);
    border: 1px solid var(--border-green);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
}

.area-option .area-option-status--partial {
    color: var(--blue-bright);
    background: var(--blue-dim);
    border-color: rgba(142, 194, 255, 0.38);
}

.area-context-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-self: flex-start;
}

.detected-area[hidden] {
    display: none;
}

.detected-area-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px 10px;
    color: var(--blue-bright);
    background: var(--blue-dim);
    border: 1px solid rgba(142, 194, 255, 0.38);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.detected-area-badge span {
    color: var(--t3);
}

.detected-area-badge:hover,
.detected-area-badge:focus-visible {
    background: rgba(0, 92, 163, 0.24);
    border-color: var(--blue-bright);
    box-shadow: 0 0 0 3px rgba(0, 92, 163, 0.1);
    outline: none;
}

.area-control {
    position: relative;
    align-self: flex-start;
}

.area-control[hidden],
.area-selector-menu[hidden] {
    display: none;
}

.selected-area {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px 10px;
    border: 1px solid var(--border-green);
    border-radius: var(--radius-full);
    background: var(--green-dim);
    color: var(--green-bright);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.selected-area:hover,
.selected-area:focus-visible,
.selected-area[aria-expanded="true"] {
    border-color: var(--green-bright);
    background: rgba(125, 195, 84, 0.22);
    box-shadow: 0 0 0 3px rgba(125, 195, 84, 0.08);
    outline: none;
}

.selected-area-label {
    color: var(--t3);
}

.selected-area-chevron {
    transition: transform var(--transition-fast);
}

.selected-area[aria-expanded="true"] .selected-area-chevron {
    transform: rotate(180deg);
}

.area-selector-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 30;
    width: min(390px, calc(100vw - 40px));
    padding: var(--space-2);
    background: rgba(8, 16, 30, 0.98);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
}

.area-menu-option {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2) var(--space-3);
    color: var(--t1);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    text-align: left;
}

.area-menu-option:hover,
.area-menu-option:focus-visible {
    background: var(--s2);
    outline: none;
}

.area-menu-option--selected {
    color: var(--green-bright);
    background: var(--green-dim);
    border-color: var(--border-green);
}

.area-menu-option strong {
    font-size: var(--font-size-sm);
}

.area-menu-option span {
    color: var(--t3);
    font-size: var(--font-size-xs);
}

.suggestion-chip {
    padding: var(--space-2) var(--space-4);
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: var(--font-size-sm);
    color: var(--t2);
    cursor: pointer;
    transition:
        background var(--transition-fast),
        border-color var(--transition-fast),
        color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
    opacity: 0;
    animation: chipIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    white-space: nowrap;
}

.suggestion-chip:nth-child(1) { animation-delay: 0.35s; }
.suggestion-chip:nth-child(2) { animation-delay: 0.48s; }
.suggestion-chip:nth-child(3) { animation-delay: 0.61s; }
.suggestion-chip:nth-child(4) { animation-delay: 0.74s; }

@keyframes chipIn {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.suggestion-chip:hover {
    background: var(--s2);
    border-color: rgba(0, 92, 163, 0.38);
    color: var(--t1);
    box-shadow: 0 0 14px rgba(0, 92, 163, 0.14);
    transform: translateY(-1px);
}

.suggestion-chip:active {
    transform: translateY(0) scale(0.97);
}

.composer-suggestions {
    display: flex;
    gap: var(--space-2);
    width: 100%;
    overflow-x: auto;
    padding: 1px 1px 3px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hi) transparent;
}

.composer-suggestions[hidden] {
    display: none;
}

.composer-suggestions .suggestion-chip {
    flex: 0 0 auto;
    padding: 6px 12px;
    font-size: var(--font-size-xs);
    animation-delay: 0s;
}

.capability-update-notice {
    width: 100%;
    padding: 7px 10px;
    color: var(--t2);
    background: var(--s1);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    line-height: 1.45;
}

.capability-update-notice[hidden] {
    display: none;
}

/* Base bubble */
.message-bubble {
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    white-space: pre-wrap;
    word-break: break-word;
}

.assistant-citation {
    display: block;
    margin-top: 0.9em;
    color: rgba(220, 233, 248, 0.68);
    font-size: 0.8em;
    font-weight: 400;
    line-height: 1.55;
}

/* Error */
.message--error .message-bubble {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error-border);
    border-radius: var(--radius-md);
}

/* Role label */
.message-role {
    font-family: var(--font-display);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--t3);
    padding: 0 var(--space-2);
}

/* ----------------------------------------------------------
   Source Citations
   ---------------------------------------------------------- */
.sources-section {
    margin-top: var(--space-2);
    width: 100%;
    max-width: 640px;
}

.sources-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-display);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-1) 0;
    transition: color var(--transition-fast);
}

.sources-toggle:hover {
    color: var(--blue-bright);
}

.sources-toggle-icon {
    transition: transform var(--transition-fast);
    display: inline-flex;
}

.sources-toggle[aria-expanded="true"] .sources-toggle-icon {
    transform: rotate(180deg);
}

.sources-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    background: var(--green);
    color: white;
    border-radius: var(--radius-full);
    font-size: 9px;
    font-weight: 700;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-2);
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.sources-list[hidden] {
    display: none;
}

/* Source card */
.source-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: rgba(125, 195, 84, 0.07);
    border: 1px solid rgba(125, 195, 84, 0.18);
    border-left: 2px solid var(--green-bright);
    border-radius: var(--radius-sm);
    transition:
        box-shadow var(--transition-fast),
        background var(--transition-fast);
}

.source-card:hover {
    background: rgba(125, 195, 84, 0.11);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
}

.source-card-title {
    font-size: var(--font-size-sm);
    font-weight: 400;
    color: var(--t1);
    text-decoration: none;
    line-height: var(--line-height-tight);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--transition-fast);
}

.source-card-title:hover {
    color: var(--green-bright);
    text-decoration: underline;
}

.source-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.source-section-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: var(--blue-dim);
    color: var(--blue-bright);
    border-radius: var(--radius-full);
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.source-date {
    font-size: var(--font-size-xs);
    color: var(--t3);
}

.source-relevance {
    font-size: var(--font-size-xs);
    color: var(--t3);
    margin-left: auto;
    white-space: nowrap;
}

.source-relevance-bar {
    display: inline-block;
    width: 28px;
    height: 3px;
    background: var(--s3);
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 4px;
    position: relative;
    overflow: hidden;
}

.source-relevance-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--green-bright);
    border-radius: 2px;
}

/* ----------------------------------------------------------
   Loading Indicator — Wave bars
   ---------------------------------------------------------- */
.loading-indicator {
    padding: 0 var(--space-6) var(--space-4);
    display: flex;
}

.loading-bubble {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    background: rgba(10, 18, 34, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-left: 2px solid var(--blue);
    border-radius: var(--radius-xl) var(--radius-xl) var(--radius-xl) var(--radius-sm);
    padding: var(--space-3) var(--space-5);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.loading-agent-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    flex: 0 0 40px !important;
    object-fit: cover;
    border: 1px solid rgba(142, 194, 255, 0.24);
    border-radius: 50%;
}

.loading-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.loading-wave span {
    display: inline-block;
    width: 3px;
    border-radius: 2px;
    background: var(--blue-bright);
    animation: waveBar 1.15s ease-in-out infinite;
}

.loading-wave span:nth-child(1) { animation-delay: 0s; }
.loading-wave span:nth-child(2) { animation-delay: 0.1s; }
.loading-wave span:nth-child(3) { animation-delay: 0.2s; }
.loading-wave span:nth-child(4) { animation-delay: 0.3s; }
.loading-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes waveBar {
    0%, 100% {
        height: 5px;
        opacity: 0.35;
    }
    50% {
        height: 18px;
        opacity: 1;
    }
}

/* Legacy dot support (in case JS renders old structure) */
.loading-dots {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--blue-bright);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 60%, 100% { transform: scale(0.7); opacity: 0.45; }
    30%            { transform: scale(1);   opacity: 1; }
}

.loading-text {
    font-size: var(--font-size-sm);
    color: var(--t3);
    font-style: italic;
    min-width: min(260px, 55vw);
    transition: opacity 160ms ease, transform 160ms ease;
}

.loading-text.is-changing {
    opacity: 0.25;
    transform: translateY(2px);
}

/* ----------------------------------------------------------
   Input Area
   ---------------------------------------------------------- */
.input-area {
    flex-shrink: 0;
    background: rgba(5, 11, 20, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: var(--space-4) var(--space-6);
    box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.4);
    position: relative;
}

.input-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 92, 163, 0.3) 30%,
        rgba(125, 195, 84, 0.25) 70%,
        transparent 100%);
}

.input-form {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: rgba(0, 92, 163, 0.45);
    background: var(--s2);
    box-shadow:
        0 0 0 3px rgba(0, 92, 163, 0.1),
        0 0 22px rgba(0, 92, 163, 0.08);
}

/* Shake on empty send */
.input-wrapper--shake {
    animation: shake 0.42s ease;
    border-color: var(--color-error) !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-5px); }
    40%       { transform: translateX(5px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

.question-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--t1);
    max-height: 140px;
    overflow-y: auto;
    padding: 2px 0;
    caret-color: var(--blue-bright);
}

.question-input::placeholder {
    color: var(--t4);
}

.question-input::-webkit-scrollbar {
    width: 3px;
}

.question-input::-webkit-scrollbar-thumb {
    background: var(--s3);
    border-radius: 2px;
}

.send-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--blue), var(--green));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        opacity var(--transition-fast),
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
    box-shadow: 0 2px 14px rgba(0, 92, 163, 0.42);
}

.send-btn:hover:not(:disabled) {
    opacity: 0.92;
    transform: scale(1.06);
    box-shadow:
        0 4px 22px rgba(0, 92, 163, 0.55),
        0 0 14px rgba(125, 195, 84, 0.28);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.94);
}

.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    box-shadow: none;
}

.send-btn:focus-visible {
    outline: 2px solid var(--blue-bright);
    outline-offset: 2px;
}

.input-disclaimer {
    font-size: var(--font-size-xs);
    color: var(--t4);
    line-height: var(--line-height-base);
    text-align: center;
}

/* ----------------------------------------------------------
   Utility
   ---------------------------------------------------------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ----------------------------------------------------------
   Responsive — Tablet / Mobile
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    :root {
        --header-height: 54px;
    }

    .sidebar-toggle {
        display: flex;
    }

    .header-badge {
        display: none;
    }

    .header-title {
        font-size: var(--font-size-md);
    }

    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 88vw);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-overlay.is-visible {
        display: block;
    }

    .messages {
        padding: var(--space-4) var(--space-4) var(--space-3);
    }

    .message {
        max-width: 90%;
    }

    .input-area {
        padding: var(--space-3) var(--space-4);
    }

    .loading-indicator {
        padding: 0 var(--space-4) var(--space-3);
    }
}

@media (max-width: 480px) {
    .area-context-row {
        width: 100%;
    }

    .detected-area-badge,
    .selected-area {
        max-width: calc(100vw - 32px);
    }

    .detected-area-badge strong,
    .selected-area strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .area-options {
        grid-template-columns: 1fr;
    }

    .message--welcome .message-bubble {
        padding: var(--space-6) var(--space-4);
    }

    .message--welcome .welcome-title {
        font-size: var(--font-size-lg);
    }

    .input-disclaimer {
        display: none;
    }
}

/* ============================================================
   Feedback Buttons (Thumbs Up/Down)
   ============================================================ */
.feedback-buttons {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding: 0 var(--space-2);
}


/* ----------------------------------------------------------
   Embedded atendimento widget
   ---------------------------------------------------------- */
.widget-close {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--t2);
    background: var(--s1);
    border: 1px solid var(--border);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.widget-close:not([hidden]) {
    display: flex;
}

.widget-close:hover {
    color: var(--t1);
    background: var(--s2);
}

.widget-close:focus-visible {
    outline: 2px solid var(--blue-bright);
    outline-offset: 2px;
}

html.widget-mode {
    color-scheme: dark;
}

html.widget-mode body {
    min-width: 0;
}

html.widget-mode .sidebar,
html.widget-mode .sidebar-overlay,
html.widget-mode .sidebar-toggle,
html.widget-mode .header-badge {
    display: none !important;
}

html.widget-mode .header {
    --header-height: 58px;
    height: var(--header-height);
}

html.widget-mode .header-inner {
    padding: 0 var(--space-4);
    gap: var(--space-3);
}

html.widget-mode .logo-mark {
    width: 38px;
    height: 38px;
}

html.widget-mode .agent-avatar--header {
    width: 34px;
    height: 34px;
}

html.widget-mode .header-logo {
    min-width: 0;
}

html.widget-mode .header-title {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html.widget-mode .messages {
    padding: var(--space-4) var(--space-4) var(--space-3);
    gap: var(--space-4);
}

html.widget-mode .message {
    max-width: 94%;
}

html.widget-mode .message--welcome {
    max-width: 100%;
}

html.widget-mode .message--welcome .message-bubble {
    padding: var(--space-5) var(--space-4);
}

html.widget-mode .message--welcome .agent-avatar--welcome {
    width: 56px;
    height: 56px;
}

html.widget-mode .message--welcome .welcome-bio {
    display: none;
}

html.widget-mode .area-options {
    grid-template-columns: 1fr;
}

html.widget-mode .input-area {
    padding: var(--space-3);
}

html.widget-mode .input-wrapper {
    padding: 10px 11px;
}

html.widget-mode .input-disclaimer {
    display: none;
}

html.widget-mode .loading-indicator {
    padding: 0 var(--space-3) var(--space-3);
}

html.widget-mode .loading-text {
    min-width: 0;
}

@media (max-height: 560px) {
    html.widget-mode .message--welcome .welcome-icon,
    html.widget-mode .message--welcome .welcome-role {
        display: none;
    }

    html.widget-mode .message--welcome .message-bubble {
        padding: var(--space-3);
    }
}

/* Embedded assistant: light, branded support experience from the approved handoff. */
html.widget-mode {
    color-scheme: light;
    --widget-radius: 26px;
    --widget-ink: #17191d;
    --widget-muted: #737985;
    --widget-line: #e7e8ec;
    --widget-paper: #ffffff;
    --widget-canvas: #f5f6f8;
    --t1: #1d2026;
    --t2: #626976;
    --t3: #818793;
    --t4: #a6abb4;
    --border: #e7e8ec;
    --border-hi: color-mix(in srgb, var(--blue) 38%, #e7e8ec);
    --s0: #ffffff;
    --s1: #f7f8fa;
    --s2: #f0f2f5;
    --s3: #e7e9ed;
}

html.widget-mode body { color: var(--widget-ink); background: var(--widget-canvas); font-family: "Plus Jakarta Sans", var(--font-body); }
html.widget-mode .bg-canvas { display: none; }
html.widget-mode .header { --header-height: 92px; height: var(--header-height); color: #fff; background: radial-gradient(circle at 78% 0%, rgba(255,255,255,.22), transparent 42%), linear-gradient(135deg, var(--blue), var(--green)); border-bottom: 0; box-shadow: none; }
html.widget-mode .header-inner { padding: 0 18px; gap: 10px; }
html.widget-mode .header-logo { align-items: center; gap: 12px; }
html.widget-mode .logo-mark { width: 62px; height: 70px; overflow: visible; }
html.widget-mode .logo-ring { display: none; }
html.widget-mode .agent-avatar--header { width: 72px; height: 72px; max-width: none; object-fit: contain; border: 0; border-radius: 0; background: transparent; filter: drop-shadow(0 8px 9px rgba(42,31,38,.18)); }
html.widget-mode .header-brand { color: rgba(255,255,255,.76); font: 700 9px/1 "Plus Jakarta Sans", sans-serif; letter-spacing: .16em; }
html.widget-mode .header-title { max-width: 230px; color: #fff; font: 750 1.02rem/1.25 "Plus Jakarta Sans", sans-serif; letter-spacing: 0; }
html.widget-mode .widget-close { color: #fff; background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.2); border-radius: 11px; }
html.widget-mode .widget-close:hover { color: #fff; background: rgba(255,255,255,.26); }
html.widget-mode .chat-area { background: var(--widget-canvas); }
html.widget-mode .messages { padding: 20px 16px 14px; gap: 18px; }
html.widget-mode .message { max-width: 92%; gap: 5px; }
html.widget-mode .message-role { color: #969ba5; font: 700 9px/1.25 "Plus Jakarta Sans", sans-serif; letter-spacing: .12em; }
html.widget-mode .message--welcome { max-width: 100%; align-items: stretch; }
html.widget-mode .message--welcome .message-bubble { padding: 18px; color: var(--widget-ink); background: var(--widget-paper); border: 1px solid var(--widget-line); border-radius: calc(var(--widget-radius) * .72); box-shadow: 0 12px 32px rgba(28,35,47,.08); text-align: left; }
html.widget-mode .message--welcome .welcome-icon { justify-content: flex-start; margin: -8px 0 2px; animation: none; }
html.widget-mode .message--welcome .agent-avatar--welcome { width: 78px; height: 68px; object-fit: contain; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
html.widget-mode .message--welcome .welcome-label { color: var(--blue); font-family: "Plus Jakarta Sans", sans-serif; }
html.widget-mode .message--welcome .welcome-title { color: var(--widget-ink); font: 750 1.14rem/1.25 "Plus Jakarta Sans", sans-serif; letter-spacing: 0; }
html.widget-mode .message--welcome .welcome-role { color: var(--blue); margin-bottom: 7px; font-size: .64rem; }
html.widget-mode .message--welcome .welcome-bio { display: none; }
html.widget-mode .message--welcome .welcome-text { margin-bottom: 15px; color: var(--widget-muted); font-size: .82rem; line-height: 1.55; }
html.widget-mode .area-options { grid-template-columns: 1fr; gap: 7px; }
html.widget-mode .area-option { min-height: 48px; padding: 10px 13px; color: var(--widget-ink); background: #fff; border-color: var(--widget-line); border-radius: 13px; box-shadow: 0 4px 12px rgba(28,35,47,.035); }
html.widget-mode .area-option strong { font-size: .78rem; }
html.widget-mode .area-option span { color: var(--widget-muted); font-size: .68rem; }
html.widget-mode .area-option:hover, html.widget-mode .area-option:focus-visible { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 4%, #fff); }
html.widget-mode .area-option--selected { border-color: var(--blue); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 12%, transparent); }
html.widget-mode .message--user .message-bubble { padding: 11px 14px; color: #fff; background: #17191d; border: 0; border-radius: 17px 17px 5px 17px; box-shadow: 0 7px 18px rgba(24,26,31,.14); }
html.widget-mode .message--assistant .message-bubble { padding: 14px 15px; color: var(--widget-ink); background: #fff; border: 1px solid var(--widget-line); border-left: 2px solid var(--blue); border-radius: 17px 17px 17px 5px; box-shadow: 0 7px 20px rgba(28,35,47,.07); }
html.widget-mode .message-bubble { font-size: .82rem; line-height: 1.62; }
html.widget-mode .assistant-citation { color: #626a75; font-size: .8em; font-weight: 400; }
html.widget-mode .capabilities-state { color: #5f6670; background: #fff; border-color: var(--widget-line); }
html.widget-mode .capabilities-state strong { color: var(--widget-ink); }
html.widget-mode .capabilities-state--unavailable { border-color: #c88b91; }
html.widget-mode .capabilities-retry { color: var(--widget-ink); background: #fff; border-color: var(--blue); }
html.widget-mode .capability-freshness { color: #626a75; }
html.widget-mode .capability-freshness span,
html.widget-mode .capability-freshness time { background: #fff; border-color: var(--widget-line); }
html.widget-mode .sources-toggle { color: #828894; font-family: "Plus Jakarta Sans", sans-serif; }
html.widget-mode .sources-count-badge { background: var(--blue); }
html.widget-mode .source-card { background: #fff; border-color: var(--widget-line); border-left-color: var(--green); }
html.widget-mode .source-card-title { color: var(--widget-ink); }
html.widget-mode .source-date, html.widget-mode .source-relevance { color: #8a909a; }
html.widget-mode .loading-indicator { padding: 0 16px 13px; }
html.widget-mode .loading-bubble { gap: 10px; min-height: 58px; padding: 10px 14px; color: var(--widget-ink); background: #fff; border: 1px solid var(--widget-line); border-left: 2px solid var(--blue); border-radius: 17px 17px 17px 5px; box-shadow: 0 7px 20px rgba(28,35,47,.07); }
html.widget-mode .loading-agent-avatar { width: 38px !important; height: 38px !important; min-width: 38px !important; min-height: 38px !important; max-width: 38px !important; max-height: 38px !important; object-fit: contain; border-radius: 0; flex: 0 0 38px !important; }
html.widget-mode .loading-wave { gap: 3px; }
html.widget-mode .loading-wave span { width: 5px; border-radius: 50%; background: var(--blue); }
html.widget-mode .loading-text { min-width: 0; color: var(--widget-muted); font-size: .75rem; font-style: normal; line-height: 1.4; }
html.widget-mode .input-area { padding: 12px; background: #fff; border-top-color: var(--widget-line); box-shadow: 0 -10px 24px rgba(28,35,47,.05); }
html.widget-mode .input-area::before { display: none; }
html.widget-mode .input-wrapper { padding: 8px 9px 8px 13px; background: #fff; border-color: #dfe2e7; border-radius: 16px; }
html.widget-mode .input-wrapper:focus-within { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 11%, transparent); }
html.widget-mode .question-input { color: var(--widget-ink); font-size: .82rem; caret-color: var(--blue); }
html.widget-mode .question-input::placeholder { color: #a1a6af; }
html.widget-mode .send-btn { width: 38px; height: 38px; background: linear-gradient(135deg, var(--blue), var(--green)); box-shadow: 0 6px 16px color-mix(in srgb, var(--blue) 24%, transparent); }
html.widget-mode .selected-area { color: var(--widget-ink); background: #fff; border-color: var(--widget-line); }
html.widget-mode .selected-area-label { color: #8d929c; }
html.widget-mode .detected-area-badge { color: var(--blue); background: color-mix(in srgb, var(--blue) 6%, #fff); border-color: color-mix(in srgb, var(--blue) 30%, var(--widget-line)); }
html.widget-mode .detected-area-badge span { color: #8d929c; }
html.widget-mode .capability-update-notice { color: #626a75; background: #fff; border-color: var(--widget-line); }
html.widget-mode .area-selector-menu { color: var(--widget-ink); background: #fff; border-color: var(--widget-line); box-shadow: 0 12px 30px rgba(28,35,47,.12); }
html.widget-mode[data-widget-density="compact"] .header { --header-height: 76px; }
html.widget-mode[data-widget-density="compact"] .logo-mark { width: 54px; height: 58px; }
html.widget-mode[data-widget-density="compact"] .agent-avatar--header { width: 62px; height: 62px; }
html.widget-mode[data-widget-density="compact"] .messages { padding: 13px 12px 10px; gap: 12px; }
html.widget-mode[data-widget-density="compact"] .message--welcome .message-bubble { padding: 13px; }
html.widget-mode[data-widget-density="compact"] .message--welcome .welcome-icon { display: none; }
html.widget-mode[data-widget-density="compact"] .area-option { min-height: 42px; padding: 8px 11px; }
@media (max-height: 560px) {
    html.widget-mode .message--welcome .welcome-icon,
    html.widget-mode .message--welcome .welcome-role { display: none; }
    html.widget-mode .message--welcome .message-bubble { padding: 12px; }
}


.feedback-btn {
    background: var(--s1);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 3px 10px;
    font-size: var(--font-size-xs);
    cursor: pointer;
    opacity: 0.55;
    color: var(--t1);
    transition:
        opacity var(--transition-fast),
        border-color var(--transition-fast),
        background var(--transition-fast);
}

.feedback-btn:hover:not(:disabled) {
    opacity: 1;
    border-color: var(--border-hi);
    background: var(--s2);
}

.feedback-btn--selected {
    opacity: 1;
    border-color: var(--border-green);
    background: var(--green-dim);
}

.feedback-btn:disabled { cursor: default; }

/* ============================================================
   Session Feedback Modal
   ============================================================ */
.feedback-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideUp 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.feedback-modal {
    background: rgba(10, 18, 34, 0.92);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--border);
    border-top: 1px solid rgba(0, 92, 163, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-8);
    box-shadow:
        0 0 40px rgba(0, 92, 163, 0.1),
        var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-width: 380px;
    width: 90vw;
    text-align: center;
}

.feedback-modal-title {
    font-family: var(--font-display);
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--t1);
    letter-spacing: 0.02em;
}

.feedback-stars {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
}

.star-btn {
    font-size: 2rem;
    color: var(--t3);
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast), transform var(--transition-fast);
    line-height: 1;
}

.star-btn:hover,
.star-btn--selected {
    color: var(--green-bright);
    transform: scale(1.18);
}

.feedback-comment {
    width: 100%;
    background: var(--s2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--t1);
    resize: none;
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.feedback-comment::placeholder { color: var(--t4); }

.feedback-comment:focus {
    border-color: rgba(0, 92, 163, 0.45);
    box-shadow: 0 0 0 3px rgba(0, 92, 163, 0.1);
}

.feedback-modal-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
}

.feedback-skip-btn {
    padding: var(--space-2) var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: none;
    font-size: var(--font-size-sm);
    color: var(--t3);
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}

.feedback-skip-btn:hover {
    border-color: var(--t3);
    color: var(--t2);
}

.feedback-submit-btn {
    padding: var(--space-2) var(--space-5);
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--blue), var(--green));
    color: white;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: 0 2px 12px rgba(0, 92, 163, 0.35);
}

.feedback-submit-btn:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 18px rgba(0, 92, 163, 0.48);
}

.feedback-submit-btn:disabled {
    opacity: 0.3;
    cursor: default;
    box-shadow: none;
}
/* ============================================================
   Embedded widget — optional visitor identification
   ============================================================ */
.widget-identification[hidden],
.widget-contact-consent[hidden] { display: none; }

.widget-identification {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: grid;
    place-items: center;
    padding: 12px;
    overflow: auto;
    background: rgba(4, 10, 20, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.widget-identification-card {
    width: min(100%, 376px);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 20px;
    color: #172132;
    background: #fff;
    box-shadow: 0 22px 60px rgba(0,0,0,.42);
}

.widget-identification-hero {
    position: relative;
    min-height: 126px;
    display: grid;
    place-items: end center;
    padding-top: 24px;
    color: #fff;
    background: radial-gradient(circle at 70% 10%, rgba(255,255,255,.22), transparent 38%), linear-gradient(135deg, var(--blue), var(--green));
}

.widget-identification-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 10px;
    color: #fff;
    background: rgba(255,255,255,.16);
    font: 400 24px/1 var(--font-body);
    cursor: pointer;
}

.widget-identification-avatar {
    width: 104px;
    height: 104px;
    display: grid;
    place-items: center;
    margin-bottom: -24px;
    overflow: hidden;
    border: 4px solid #fff;
    border-radius: 50%;
    color: #fff;
    background: rgba(9,20,36,.28);
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

.widget-identification-avatar .agent-avatar { width: 100%; height: 100%; object-fit: cover; }

.widget-identification-body { padding: 34px 24px 22px; text-align: center; }
.widget-identification-body h2 { margin: 0; color: #111827; font: 700 1.45rem/1.2 var(--font-display); }
.widget-identification-body > p { margin: 6px 0 18px; color: #697386; font-size: .88rem; }

#widget-identification-form { display: grid; gap: 11px; text-align: left; }
.widget-contact-field { min-width: 0; display: grid; gap: 5px; }
.widget-contact-field > span { color: #374151; font-size: .71rem; font-weight: 600; }
.widget-contact-field small { color: #8a94a5; font-weight: 400; }

.widget-contact-field input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid #d9dee7;
    border-radius: 10px;
    outline: none;
    color: #172132;
    background: #fff;
    font: 400 .9rem/1.2 var(--font-body);
}

.widget-contact-field input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 14%, transparent);
}

.widget-phone-row { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 9px; align-items: end; }

.widget-country-code {
    min-height: 40px;
    display: grid;
    place-items: center;
    padding: 0 8px;
    border: 1px solid #d9dee7;
    border-radius: 10px;
    color: #374151;
    background: #f8fafc;
    font-size: .82rem;
    font-weight: 600;
}

.widget-contact-consent {
    display: grid;
    grid-template-columns: 17px 1fr;
    gap: 8px;
    align-items: start;
    padding: 9px 10px;
    border-radius: 9px;
    color: #596477;
    background: #f3f6fa;
    font-size: .69rem;
    line-height: 1.4;
}

.widget-contact-consent input { width: 15px; height: 15px; margin: 1px 0 0; accent-color: var(--blue); }
.widget-contact-error { margin: 0; color: #b4233d; font-size: .72rem; line-height: 1.35; }

.widget-identification-start,
.widget-identification-skip { border: 0; font-family: var(--font-body); cursor: pointer; }

.widget-identification-start {
    min-height: 46px;
    margin-top: 2px;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--green));
    box-shadow: 0 9px 24px color-mix(in srgb, var(--blue) 26%, transparent);
    font-size: .88rem;
    font-weight: 700;
}

.widget-identification-start:disabled { opacity: .62; cursor: wait; }

.widget-identification-skip {
    justify-self: center;
    padding: 4px 6px;
    color: #788397;
    background: transparent;
    text-decoration: underline;
    font-size: .72rem;
}

html.widget-mode .widget-identification {
    padding: 0;
    align-items: stretch;
    background: #f5f6f8;
    backdrop-filter: none;
}
html.widget-mode .widget-identification-card { width: 100%; max-width: none; min-height: 100%; border: 0; border-radius: 0; box-shadow: none; font-family: "Plus Jakarta Sans", var(--font-body); }
html.widget-mode .widget-identification-hero { min-height: 182px; padding: 0; overflow: hidden; background: radial-gradient(circle at 75% 0%, rgba(255,255,255,.24), transparent 40%), linear-gradient(135deg, var(--blue), var(--green)); }
html.widget-mode .widget-identification-close { top: 14px; right: 14px; border-radius: 11px; }
html.widget-mode .widget-identification-avatar { width: 205px; height: 166px; margin: 0; overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
html.widget-mode .widget-identification-avatar .agent-avatar { width: 100%; height: 100%; object-fit: contain; border-radius: 0; filter: drop-shadow(0 12px 12px rgba(40,29,35,.16)); }
html.widget-mode .widget-identification-body { padding: 24px 24px 22px; }
html.widget-mode .widget-identification-body h2 { font: 800 1.38rem/1.2 "Plus Jakarta Sans", sans-serif; }
html.widget-mode .widget-identification-body > p { margin: 6px 0 18px; font-size: .82rem; }
html.widget-mode #widget-identification-form { gap: 10px; }
html.widget-mode .widget-contact-field > span { color: #555d69; font-size: .68rem; }
html.widget-mode .widget-contact-field input { min-height: 47px; border-radius: 13px; font-family: "Plus Jakarta Sans", sans-serif; }
html.widget-mode .widget-country-code { min-height: 47px; border-radius: 13px; }
html.widget-mode .widget-identification-start { min-height: 50px; border-radius: 13px; background: linear-gradient(135deg, var(--blue), var(--green)); font-size: .86rem; }
html.widget-mode .widget-identification-skip { font-size: .7rem; }

@media (max-height: 620px) {
    .widget-identification { place-items: start center; }
    .widget-identification-hero { min-height: 92px; }
    .widget-identification-avatar { width: 76px; height: 76px; }
    .widget-identification-body { padding-top: 28px; }
    html.widget-mode .widget-identification-hero { min-height: 128px; }
    html.widget-mode .widget-identification-avatar { width: 150px; height: 118px; }
    html.widget-mode .widget-identification-body { padding-top: 18px; }
}
