/* Iva / Perfecto Brain assistant — ChatGPT-style sidebar */

.iva-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 10003;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    /* Dark disc so the transparent PNG reads vivid, not washed out */
    background:
        radial-gradient(circle at 35% 28%, rgba(56, 189, 248, 0.22) 0%, transparent 45%),
        radial-gradient(circle at 72% 78%, rgba(217, 70, 239, 0.18) 0%, transparent 42%),
        linear-gradient(165deg, #0f172a 0%, #1e293b 48%, #0c4a6e 100%);
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.45),
        0 0 0 2px rgba(34, 211, 238, 0.45),
        0 0 20px rgba(34, 211, 238, 0.35),
        0 0 28px rgba(192, 38, 211, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.iva-fab:hover {
    transform: scale(1.06);
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.5),
        0 0 0 2px rgba(56, 232, 255, 0.65),
        0 0 26px rgba(56, 232, 255, 0.5),
        0 0 36px rgba(217, 70, 239, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    filter: brightness(1.03);
}

.iva-fab:focus-visible {
    outline: 3px solid #00d4ff;
    outline-offset: 2px;
}

.iva-fab img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    pointer-events: none;
    /* Pop the hero asset: contrast + saturation + layered glow */
    filter:
        contrast(1.12)
        saturate(1.2)
        brightness(1.06)
        drop-shadow(0 0 6px rgba(56, 232, 255, 0.75))
        drop-shadow(0 0 14px rgba(34, 211, 238, 0.55))
        drop-shadow(0 2px 10px rgba(192, 38, 211, 0.35));
}

.iva-fab .iva-fab-fallback {
    font-size: 26px;
    color: #22d3ee;
    text-shadow: 0 0 12px rgba(34, 211, 238, 0.9), 0 0 20px rgba(192, 38, 211, 0.5);
    display: none;
}

.iva-fab.iva-fab--fallback .iva-fab-fallback {
    display: block;
}

.iva-fab.iva-fab--fallback img {
    display: none;
}

.iva-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: flex-end;
    animation: iva-fade-in 0.2s ease;
}

.iva-overlay.iva-rtl-panel {
    justify-content: flex-start;
}

@keyframes iva-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.iva-panel {
    width: min(520px, 100vw);
    height: 100%;
    background: #f4f4f5;
    display: flex;
    flex-direction: column;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12);
    animation: iva-slide-in 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.iva-panel--wide {
    width: min(720px, 100vw);
}

.iva-overlay.iva-rtl-panel .iva-panel {
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.12);
    animation-name: iva-slide-in-rtl;
}

@keyframes iva-slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes iva-slide-in-rtl {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.iva-panel-header {
    flex-shrink: 0;
    padding: 14px 16px;
    background: linear-gradient(120deg, #0f172a 0%, #1e293b 45%, #0c4a6e 100%);
    color: #f8fafc;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.iva-panel-header__row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
    width: 100%;
}

.iva-panel-header__titles {
    flex: 1 1 160px;
    min-width: 0;
}

.iva-panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.iva-panel-header .iva-sub {
    margin: 4px 0 0;
    font-size: 0.78rem;
    opacity: 0.85;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.iva-mode-switch {
    display: inline-flex;
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(15, 23, 42, 0.45);
}

.iva-mode-switch__btn {
    border: 0;
    margin: 0;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    color: #e2e8f0;
    background: transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.iva-mode-switch__btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
}

.iva-mode-switch__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.iva-mode-switch__btn--active {
    background: rgba(56, 189, 248, 0.35);
    color: #f8fafc;
}

.iva-header-credits {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.iva-credits-value {
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #a5f3fc;
    line-height: 1.2;
}

.iva-credits-topup-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    padding: 0;
    border-radius: 8px;
}

.iva-header-actions {
    margin-inline-start: auto;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.iva-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.iva-icon-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.iva-icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.iva-credits-pill {
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(34, 211, 238, 0.15);
    color: #a5f3fc;
    border: 1px solid rgba(34, 211, 238, 0.35);
    white-space: nowrap;
}

.iva-chat-body {
    flex: 1;
    display: flex;
    min-height: 0;
    min-width: 0;
}

.iva-chats-sidebar {
    width: 132px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 6px;
    background: #e8e8ec;
    border-inline-end: 1px solid #d4d4d8;
}

.iva-chats-sidebar--wide {
    width: 200px;
}

.iva-chats-sidebar-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin: 0 0 8px 2px;
}

.iva-chats-sidebar-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 8px 0;
}

.iva-chats-sidebar-tab {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 6px 4px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #64748b;
    background: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.iva-chats-sidebar-tab:hover {
    background: rgba(255, 255, 255, 0.75);
    color: #0f172a;
}

.iva-chats-sidebar-tab--active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.iva-favorite-row {
    margin-bottom: 8px;
}

.iva-favorite-open-btn {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    border: none;
    border-radius: 8px;
    padding: 8px 6px;
    background: rgba(255, 255, 255, 0.45);
    color: #0f172a;
    text-align: start;
    cursor: pointer;
    transition: background 0.12s ease;
}

.iva-favorite-open-btn:hover:not(:disabled) {
    background: #fff;
}

.iva-favorite-open-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.iva-favorite-open-title {
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 4px;
    word-break: break-word;
}

.iva-favorite-open-preview {
    font-size: 0.65rem;
    color: #475569;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.iva-favorite-open-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.58rem;
    color: #94a3b8;
}

.iva-pinned-strip {
    flex-shrink: 0;
    padding: 8px 10px 6px;
    background: linear-gradient(180deg, rgba(250, 204, 21, 0.12) 0%, transparent 100%);
    border-bottom: 1px solid rgba(202, 138, 4, 0.2);
}

.iva-pinned-strip-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #a16207;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.iva-pinned-strip-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.iva-pinned-chip {
    max-width: 100%;
    border: 1px solid rgba(202, 138, 4, 0.35);
    background: rgba(255, 255, 255, 0.85);
    color: #713f12;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.68rem;
    line-height: 1.25;
    cursor: pointer;
    text-align: start;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.iva-pinned-chip:hover {
    background: #fff;
    border-color: rgba(202, 138, 4, 0.55);
}

.iva-chat-thread-btn {
    display: block;
    width: 100%;
    border: none;
    border-radius: 8px;
    padding: 6px 6px;
    margin-bottom: 6px;
    background: transparent;
    color: #0f172a;
    font-size: 0.72rem;
    line-height: 1.25;
    text-align: start;
    cursor: pointer;
    transition: background 0.12s ease;
}

.iva-chat-thread-btn:hover {
    background: rgba(255, 255, 255, 0.65);
}

.iva-chat-thread-btn--active {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

.iva-chat-thread-row {
    display: flex;
    align-items: stretch;
    gap: 3px;
    margin-bottom: 6px;
}

.iva-chat-thread-row .iva-chat-thread-btn {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.iva-chat-thread-rename-trigger {
    flex-shrink: 0;
    width: 26px;
    border: none;
    border-radius: 8px;
    padding: 0;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    transition: background 0.12s ease, color 0.12s ease;
}

.iva-chat-thread-rename-trigger:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
}

.iva-chat-thread-rename-trigger:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.iva-chat-thread-delete {
    flex-shrink: 0;
    width: 28px;
    border: none;
    border-radius: 8px;
    padding: 0;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    transition: background 0.12s ease, color 0.12s ease;
}

.iva-chat-thread-delete:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.iva-chat-thread-delete:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.iva-chat-thread-row--editing {
    flex-wrap: wrap;
}

.iva-chat-thread-rename {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.iva-chat-rename-input {
    flex: 1;
    min-width: 0;
    font-size: 0.72rem;
    padding: 5px 6px;
    border-radius: 8px;
    border: 1px solid #94a3b8;
    background: #fff;
    color: #0f172a;
    box-sizing: border-box;
}

.iva-chat-rename-iconbtn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    padding: 0;
    background: rgba(255, 255, 255, 0.85);
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
}

.iva-chat-rename-iconbtn:hover {
    background: #fff;
    color: #0f172a;
}

.iva-chat-rename-iconbtn--ok {
    background: rgba(34, 197, 94, 0.2);
    color: #15803d;
}

.iva-chat-rename-iconbtn--ok:hover {
    background: rgba(34, 197, 94, 0.35);
    color: #14532d;
}

.iva-chats-empty-hint {
    font-size: 0.68rem;
    line-height: 1.35;
    color: #64748b;
    margin: 4px 2px 0;
    padding: 0;
}

.iva-messages-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.iva-history-loading {
    flex-shrink: 0;
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid #e4e4e7;
}

.iva-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.iva-row {
    display: flex;
    width: 100%;
}

.iva-row-user {
    justify-content: flex-end;
}

.iva-row-assistant {
    justify-content: flex-start;
}

.iva-bubble {
    position: relative;
    max-width: 88%;
    border-radius: 16px;
    padding: 10px 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

.iva-bubble--with-toolbar {
    padding-top: 28px;
}

.iva-bubble-toolbar {
    position: absolute;
    top: 4px;
    inset-inline-end: 6px;
    display: inline-flex;
    gap: 2px;
    z-index: 1;
}

.iva-bubble-tool {
    border: none;
    background: transparent;
    color: #94a3b8;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    padding: 0;
    transition: background 0.12s ease, color 0.12s ease;
}

.iva-bubble-tool:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.06);
    color: #475569;
}

.iva-bubble-tool--on {
    color: #ca8a04;
}

.iva-bubble-user .iva-bubble-tool--on {
    color: #ca8a04;
}

.iva-bubble-tool:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.iva-bubble-user {
    background: #fff;
    color: #0f172a;
    border: 1px solid #e4e4e7;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.iva-bubble-assistant {
    background: #ececf1;
    color: #111827;
    border-bottom-left-radius: 4px;
}

.iva-bubble-system {
    background: #fef3c7;
    color: #78350f;
    font-size: 0.82rem;
    max-width: 100%;
    text-align: center;
    border-radius: 10px;
}

.iva-attachment-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.iva-attachment-grid img {
    max-width: 160px;
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.iva-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.06);
    font-size: 0.78rem;
}

.iva-voice-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(14, 165, 233, 0.12);
    color: #0369a1;
    font-size: 0.82rem;
    margin-top: 8px;
}

.iva-typing {
    display: inline-flex;
    gap: 4px;
    padding: 8px 4px;
}

.iva-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64748b;
    animation: iva-bounce 1.2s infinite ease-in-out;
}

.iva-typing span:nth-child(2) { animation-delay: 0.15s; }
.iva-typing span:nth-child(3) { animation-delay: 0.3s; }

.iva-typing--inline {
    display: inline-flex;
    padding: 0 0 0 6px;
    vertical-align: middle;
}

.iva-bubble-working {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 2px 4px;
    color: #64748b;
    font-size: 0.9rem;
}

.iva-bubble-working-label {
    font-weight: 500;
}

@keyframes iva-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-5px); opacity: 1; }
}

.iva-composer-wrap {
    flex-shrink: 0;
    padding: 10px 12px 14px;
    background: #f4f4f5;
    border-top: 1px solid #e4e4e7;
}

.iva-spoken-replies-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #52525b;
    cursor: pointer;
    user-select: none;
}

.iva-spoken-replies-row input {
    margin: 0;
    flex-shrink: 0;
}

.iva-spoken-replies-row:has(input:disabled) {
    opacity: 0.55;
    cursor: default;
}

.iva-retry-strip {
    flex-shrink: 0;
    padding: 8px 12px 0;
    background: #f4f4f5;
}

.iva-pending-reply-strip {
    flex-shrink: 0;
    padding: 8px 12px 0;
    background: #f4f4f5;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.iva-pending-reply-text {
    margin: 0;
    font-size: 0.82rem;
    color: #52525b;
    line-height: 1.35;
}

.iva-retry-btn {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.iva-retry-btn:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #94a3b8;
}

.iva-retry-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.iva-pending-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.iva-pending-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #d4d4d8;
    background: #fff;
}

.iva-pending-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.iva-pending-file-chip-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.35rem;
    color: #64748b;
}

.iva-pending-voice {
    position: relative;
}

.iva-pending-voice .iva-pending-voice-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 9px;
    line-height: 1.1;
    text-align: center;
    background: rgba(255, 255, 255, 0.92);
    color: #475569;
    padding: 2px 0;
    border-top: 1px solid #e2e8f0;
}

.iva-composer-btn--disabled {
    opacity: 0.45;
    pointer-events: none;
}

.iva-bubble-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.iva-bubble-img {
    max-width: min(280px, 100%);
    max-height: 220px;
    border-radius: 10px;
    display: block;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.04);
}

.iva-bubble-audio {
    width: 100%;
    max-width: 280px;
    height: 36px;
}

.iva-bubble-file {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: inherit;
    opacity: 0.95;
}

.iva-voice-notes-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

.iva-voice-note-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.06);
    min-width: 0;
}

.iva-voice-note-row--user {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(139, 92, 246, 0.15));
    border: 1px solid rgba(6, 182, 212, 0.35);
}

.iva-voice-note-row--assistant {
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid #e4e4e7;
}

.iva-voice-note-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.08);
    color: #0f172a;
    font-size: 0.85rem;
}

.iva-voice-note-row--user .iva-voice-note-icon {
    background: rgba(255, 255, 255, 0.55);
    color: #0c4a6e;
}

.iva-voice-note-audio {
    flex: 1;
    min-width: 0;
    height: 36px;
    max-width: 220px;
}

.iva-voice-text-toggle-row {
    margin-top: 6px;
}

.iva-voice-text-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.iva-voice-text-toggle:hover {
    color: #0f172a;
}

.iva-bubble-user .iva-voice-text-toggle {
    color: rgba(255, 255, 255, 0.85);
}

.iva-bubble-user .iva-voice-text-toggle:hover {
    color: #fff;
}

.iva-voice-note-duration {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: #475569;
    min-width: 2.5rem;
    text-align: end;
}

.iva-bubble-text--after-voice {
    margin-top: 8px;
}

.iva-voice-recording-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #fecaca;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.iva-voice-rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    flex-shrink: 0;
    animation: iva-rec-dot-pulse 1.1s ease-in-out infinite;
}

@keyframes iva-rec-dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.65; transform: scale(0.92); }
}

.iva-voice-rec-time {
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #b91c1c;
    min-width: 2.75rem;
}

.iva-voice-rec-hint {
    font-size: 0.8rem;
    color: #64748b;
    flex: 1;
    min-width: 0;
}

.iva-voice-draft-card {
    position: relative;
    flex: 1 1 100%;
    min-width: min(100%, 280px);
    padding: 10px 36px 10px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #d4d4d8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.iva-voice-draft-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.iva-voice-draft-head i {
    color: #0ea5e9;
}

.iva-voice-draft-dur {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #64748b;
}

.iva-voice-draft-player {
    width: 100%;
    height: 40px;
    display: block;
}

.iva-voice-draft-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: #334155;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.iva-voice-draft-remove:hover {
    background: rgba(0, 0, 0, 0.14);
}

.iva-pending-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.iva-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fff;
    border: 1px solid #d4d4d8;
    border-radius: 14px;
    padding: 8px 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.iva-composer textarea {
    flex: 1;
    border: none;
    resize: none;
    min-height: 44px;
    max-height: 160px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    padding: 6px 4px;
    background: transparent;
    outline: none;
}

.iva-composer-tools {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 2px;
}

.iva-composer-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: #f4f4f5;
    color: #52525b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.iva-composer-btn:hover {
    background: #e4e4e7;
    color: #18181b;
}

.iva-composer-btn.iva-recording {
    background: #fee2e2;
    color: #b91c1c;
    animation: iva-pulse-rec 1s ease-in-out infinite;
}

@keyframes iva-pulse-rec {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.iva-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #06b6d4, #8b5cf6);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.iva-send-btn:hover:not(:disabled) {
    transform: scale(1.04);
}

.iva-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

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

.iva-setup {
    padding: 20px 18px;
    flex: 1;
    overflow-y: auto;
}

.iva-setup h3 {
    margin: 0 0 10px;
    font-size: 1.1rem;
    color: #0f172a;
}

.iva-setup p {
    margin: 0 0 16px;
    color: #475569;
    font-size: 0.9rem;
    line-height: 1.5;
}

.iva-field {
    margin-bottom: 14px;
}

.iva-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.iva-field input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #d4d4d8;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.iva-primary-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #06b6d4, #8b5cf6);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    margin-top: 8px;
}

.iva-primary-btn:hover {
    filter: brightness(1.05);
}

.iva-banner-error {
    margin: 0 12px 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
    font-size: 0.82rem;
    border: 1px solid #fecaca;
}

.iva-bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Markdown-rendered chat (Markdig); outer pre-wrap disabled so block elements stack correctly */
.iva-bubble-text.iva-md-content {
    white-space: normal;
}

.iva-md-content :first-child {
    margin-top: 0;
}

.iva-md-content :last-child {
    margin-bottom: 0;
}

.iva-md-content p {
    margin: 0.4em 0;
}

.iva-md-content h1,
.iva-md-content h2,
.iva-md-content h3,
.iva-md-content h4 {
    margin: 0.55em 0 0.35em;
    line-height: 1.25;
    font-weight: 700;
}

.iva-md-content h1 {
    font-size: 1.15em;
}

.iva-md-content h2 {
    font-size: 1.08em;
}

.iva-md-content h3,
.iva-md-content h4 {
    font-size: 1.02em;
}

.iva-md-content ul,
.iva-md-content ol {
    margin: 0.4em 0;
    padding-inline-start: 1.35em;
}

.iva-md-content li {
    margin: 0.15em 0;
}

.iva-md-content blockquote {
    margin: 0.45em 0;
    padding: 0.2em 0 0.2em 0.75em;
    border-inline-start: 3px solid rgba(100, 116, 139, 0.45);
    color: #475569;
}

.iva-md-content hr {
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.55);
    margin: 0.65em 0;
}

.iva-md-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.88em;
    padding: 0.12em 0.35em;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.06);
}

.iva-md-content pre {
    margin: 0.5em 0;
    padding: 10px 12px;
    border-radius: 8px;
    overflow-x: auto;
    background: rgba(15, 23, 42, 0.06);
    font-size: 0.82em;
    line-height: 1.45;
}

.iva-md-content pre code {
    padding: 0;
    background: transparent;
    font-size: inherit;
}

.iva-md-content table {
    border-collapse: collapse;
    margin: 0.5em 0;
    font-size: 0.88em;
    max-width: 100%;
}

.iva-md-content th,
.iva-md-content td {
    border: 1px solid rgba(148, 163, 184, 0.55);
    padding: 4px 8px;
}

.iva-md-content th {
    background: rgba(148, 163, 184, 0.15);
    font-weight: 600;
}

.iva-md-content a {
    word-break: break-all;
    text-decoration: underline;
    font-weight: 600;
}

.iva-bubble-user .iva-md-content a {
    color: #0369a1;
}

.iva-bubble-assistant .iva-md-content a {
    color: #1d4ed8;
}

.iva-md-content input[type="checkbox"] {
    margin-inline-end: 0.35em;
    vertical-align: middle;
}

.iva-chat-text-chunk {
    white-space: pre-wrap;
}

.iva-chat-link {
    word-break: break-all;
    text-decoration: underline;
    font-weight: 600;
}

.iva-bubble-user .iva-chat-link {
    color: inherit;
}

.iva-bubble-assistant .iva-chat-link {
    color: #1d4ed8;
}

.iva-telegram-header-btn {
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
}

.iva-telegram-header-btn-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.iva-telegram-svg {
    width: 1.2rem;
    height: 1.2rem;
    flex-shrink: 0;
    color: #38bdf8;
    filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.55));
}

/* Admin wizard */
.iva-wizard {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.iva-wizard-steps {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #e4e4e7;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
}

.iva-wizard-steps .iva-step-active {
    color: #0f172a;
}

.iva-wizard-sep {
    opacity: 0.5;
}

.iva-wizard-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
}

.iva-wizard-actions-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    align-items: center;
}

.iva-secondary-btn {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #d4d4d8;
    background: #fff;
    color: #334155;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
}

.iva-secondary-btn:hover:not(:disabled) {
    background: #f4f4f5;
}

.iva-secondary-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.iva-badge-verified {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: 0.82rem;
    font-weight: 600;
}

.iva-license-card {
    margin: 14px 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f0fdfa;
    border: 1px solid #99f6e4;
}

.iva-license-card h4 {
    margin: 0 0 8px;
    font-size: 0.88rem;
    color: #0f766e;
}

.iva-license-card p {
    margin: 4px 0;
    font-size: 0.85rem;
    color: #134e4a;
}

.iva-cap-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0;
}

.iva-cap-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.88rem;
    color: #1e293b;
    cursor: pointer;
}

.iva-cap-row input {
    margin-top: 3px;
}

.iva-hint {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.45;
}

.iva-code-inline {
    font-size: 0.85em;
    word-break: break-all;
    color: #0f172a;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

.iva-voice-inline {
    display: block;
    width: 100%;
    max-width: 320px;
    margin-top: 8px;
}

.iva-primary-btn--inline {
    flex: 1;
    margin-top: 0;
}

.iva-primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Iva dev-only: Iva:ShowDebugChatDiagnostics — safe to delete with the feature flag */
.iva-chat-debug-footer {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px dashed rgba(148, 163, 184, 0.45);
}

.iva-chat-debug-meta {
    font-size: 10px;
    line-height: 1.3;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
}

.iva-chat-debug-sep {
    margin: 0 4px;
    opacity: 0.7;
}

.iva-chat-debug-prompt-btn {
    border: none;
    background: transparent;
    color: #64748b;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1;
}

.iva-chat-debug-prompt-btn:hover {
    color: #0ea5e9;
    background: rgba(14, 165, 233, 0.08);
}

.iva-debug-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10005;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.iva-debug-modal {
    width: min(96vw, 640px);
    max-height: min(85vh, 720px);
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.iva-debug-modal--wide {
    width: min(96vw, 900px);
}

.iva-debug-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    font-size: 0.85rem;
    font-weight: 600;
}

.iva-debug-modal-title {
    flex: 1;
    min-width: 0;
}

.iva-debug-modal-close {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.iva-debug-modal-close:hover {
    color: #f8fafc;
}

.iva-debug-modal-pre {
    margin: 0;
    padding: 12px;
    overflow: auto;
    flex: 1;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Structured assistant UI: navigate chips + approval cards (perfecto-iva JSON) */
.iva-assistant-ui-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.iva-quick-reply-hint {
    font-size: 0.78rem;
    color: rgba(226, 232, 240, 0.75);
    margin: 0 0 2px 0;
}

.iva-assistant-ui-row .iva-quick-reply-chip {
    flex-wrap: wrap;
    max-width: 100%;
    text-align: start;
}

.iva-ui-chip {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.45);
    background: linear-gradient(165deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.92));
    color: #e0f2fe;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.iva-ui-chip:hover:not(:disabled) {
    border-color: rgba(56, 232, 255, 0.75);
    color: #f8fafc;
}

.iva-ui-chip:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.iva-ui-chip--warn {
    border-color: rgba(251, 191, 36, 0.55);
    color: #fef3c7;
}

.iva-approval-card {
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.88);
    padding: 12px 14px;
    max-width: 100%;
}

.iva-approval-card--settled {
    opacity: 0.92;
}

.iva-approval-card__head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 8px;
}

.iva-approval-card__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 6px;
}

.iva-approval-card__summary {
    font-size: 0.82rem;
    color: #cbd5e1;
    line-height: 1.45;
    margin-bottom: 8px;
}

.iva-approval-card__risk {
    font-size: 0.78rem;
    color: #fde68a;
    line-height: 1.4;
    margin-bottom: 10px;
}

.iva-approval-card__risk--default {
    color: #fcd34d;
}

.iva-approval-card__risk-label {
    font-weight: 700;
    margin-inline-end: 4px;
}

.iva-approval-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.iva-approval-btn {
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

.iva-approval-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.iva-approval-btn--reject {
    background: rgba(71, 85, 105, 0.55);
    color: #e2e8f0;
}

.iva-approval-btn--reject:hover:not(:disabled) {
    background: rgba(100, 116, 139, 0.75);
}

.iva-approval-btn--approve {
    background: linear-gradient(165deg, #0d9488, #0f766e);
    color: #ecfdf5;
}

.iva-approval-btn--approve:hover:not(:disabled) {
    filter: brightness(1.06);
}

.iva-approval-card__settled {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 4px;
}

.iva-approval-card__settled--ok {
    color: #6ee7b7;
}
