/* Isolated widget frame. Orange surfaces that carry white text use #9E4300
   (design secondary) so contrast stays at WCAG AA. #FE8033 is reserved for
   borders and soft chips, where the label is dark. */
.chatbot-widget {
    --cb-navy: #002D71;
    --cb-navy-deep: #001947;
    --cb-orange: #9E4300;
    --cb-orange-bright: #FE8033;
    --cb-orange-soft: #FFDBCB;
    --cb-on-orange-soft: #341100;
    --cb-surface: #F9F9FF;
    --cb-surface-low: #F0F3FF;
    --cb-surface-high: #DEE9FF;
    --cb-card: #ffffff;
    --cb-text: #0D1C30;
    --cb-muted: #444650;
    --cb-outline: #747782;
    --cb-line: #C4C6D2;
    --cb-emerald: #047857;
    box-sizing: border-box;
    font-family: "Vazirmatn", "vazir", Tahoma, sans-serif;
    color: var(--cb-text);
    line-height: 1.5;
}

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

.chatbot-widget button,
.chatbot-widget input,
.chatbot-widget textarea {
    font-family: inherit;
}

.chatbot-widget p,
.chatbot-widget h2,
.chatbot-widget h3 {
    margin: 0;
}

.chatbot-panel {
    position: fixed;
    bottom: 24px;
    left: 20px;
    z-index: 10051;
    display: flex;
    flex-direction: column;
    width: min(420px, calc(100vw - 24px));
    height: min(720px, calc(100vh - 120px));
    background: var(--cb-surface);
    border: 1px solid rgba(196, 198, 210, 0.85);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 45, 113, 0.22);
    overflow: hidden;
    color: var(--cb-text);
}

[dir="ltr"] .chatbot-panel {
    left: auto;
    right: 20px;
}

@media (max-width: 768px) {
    .chatbot-panel {
        bottom: 70px;
        height: min(78vh, calc(100vh - 100px));
    }
}

.chatbot-panel[hidden] {
    display: none !important;
}

.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 10px 12px 14px;
    background: var(--cb-navy);
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 25, 71, 0.25);
}

.chatbot-header-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chatbot-avatar {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(222, 233, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-avatar svg,
.chatbot-header-btn svg,
.chatbot-icon-btn svg,
.chatbot-send svg,
.chatbot-date-toggle svg,
.chatbot-trust svg,
.chatbot-msg-avatar svg,
.chatbot-match-glyph svg,
.chatbot-icon {
    width: 22px;
    height: 22px;
    display: block;
}

.chatbot-online-dot {
    position: absolute;
    bottom: 0;
    inset-inline-end: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid var(--cb-navy);
}

.chatbot-header-text {
    min-width: 0;
}

.chatbot-header-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.chatbot-title {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.35;
    color: #fff;
}

.chatbot-online-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    border: 1px solid rgba(110, 231, 183, 0.35);
    background: rgba(16, 185, 129, 0.18);
    color: #a7f3d0;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.5;
}

.chatbot-online-pill span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6ee7b7;
}

.chatbot-subtitle {
    margin-top: 2px;
    color: rgba(213, 227, 255, 0.86);
    font-size: 0.72rem;
    line-height: 1.45;
}

.chatbot-header-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-header-btn {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.88);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chatbot-header-btn:hover,
.chatbot-header-btn:focus,
.chatbot-header-btn[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.chatbot-header-btn[hidden] {
    display: none !important;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(180deg, rgba(240, 243, 255, 0.7), var(--cb-surface) 28%);
    scrollbar-width: none;
}

.chatbot-messages::-webkit-scrollbar {
    display: none;
}

.chatbot-day {
    display: flex;
    justify-content: center;
}

.chatbot-day span {
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid rgba(196, 198, 210, 0.7);
    background: rgba(213, 227, 255, 0.55);
    color: var(--cb-muted);
    font-size: 0.68rem;
    font-weight: 600;
}

.chatbot-msg {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 92%;
}

.chatbot-msg-assistant {
    align-self: flex-start;
}

.chatbot-msg-user {
    align-self: flex-end;
    flex-direction: column;
    align-items: flex-end;
    max-width: 88%;
}

/* RTL (Persian and other right-to-left languages) swaps the two sides:
   the bot sits on the left, the user on the right. */
.chatbot-widget:dir(rtl) .chatbot-msg-assistant {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-widget:dir(rtl) .chatbot-msg-user {
    align-self: flex-start;
    align-items: flex-start;
}

.chatbot-msg-avatar {
    width: 28px;
    height: 28px;
    margin-top: 2px;
    border-radius: 50%;
    background: var(--cb-navy);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 45, 113, 0.25);
}

.chatbot-msg-avatar svg,
.chatbot-match-glyph svg,
.chatbot-match-badge svg,
.chatbot-match-copy svg,
.chatbot-match-cta svg,
.chatbot-btn svg,
.chatbot-chip svg,
.chatbot-status svg {
    width: 16px;
    height: 16px;
}

.chatbot-msg-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.chatbot-bubble {
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.chatbot-bubble-assistant,
.chatbot-bubble-welcome {
    background: var(--cb-card);
    color: var(--cb-text);
    border: 1px solid rgba(196, 198, 210, 0.7);
    border-start-start-radius: 4px;
    box-shadow: 0 1px 2px rgba(13, 28, 48, 0.05);
}

.chatbot-bubble-user {
    background: var(--cb-orange);
    color: #fff;
    font-weight: 500;
    border-start-end-radius: 4px;
    box-shadow: 0 2px 8px rgba(158, 67, 0, 0.22);
}

.chatbot-widget:dir(rtl) .chatbot-bubble-assistant,
.chatbot-widget:dir(rtl) .chatbot-bubble-welcome {
    border-start-start-radius: 16px;
    border-start-end-radius: 4px;
}

.chatbot-widget:dir(rtl) .chatbot-bubble-user {
    border-start-end-radius: 16px;
    border-start-start-radius: 4px;
}

.chatbot-msg-time,
.chatbot-msg-meta {
    padding-inline: 4px;
    color: var(--cb-outline);
    font-size: 0.68rem;
    font-weight: 600;
}

.chatbot-msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-msg-meta svg {
    width: 14px;
    height: 14px;
    color: var(--cb-orange-bright);
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--cb-navy);
    font-weight: 500;
}

.chatbot-spinner {
    animation: chatbot-spin 0.9s linear infinite;
    transform-origin: center;
}

@keyframes chatbot-spin {
    to { transform: rotate(360deg); }
}

.chatbot-typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-inline-start: 2px;
    border-radius: 50%;
    background: #8894a8;
    animation: chatbot-typing 1.2s infinite ease-in-out;
}

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

@keyframes chatbot-typing {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

.chatbot-question-widget {
    align-self: stretch;
    max-width: 100%;
    width: 100%;
}

.chatbot-date-row {
    align-self: stretch;
    max-width: 100%;
    width: 100%;
}

.chatbot-date-inline {
    background: #fff;
    border: 1px solid var(--cb-line);
    border-radius: 14px;
    overflow: visible;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.chatbot-date-inline .mds-bs-dtp-container {
    min-width: 0;
    width: 100%;
}

.chatbot-date-inline[disabled] {
    opacity: 0.55;
    pointer-events: none;
}

.chatbot-yesno-row,
.chatbot-found-match-choice {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.chatbot-yesno-row .chatbot-btn,
.chatbot-found-match-choice .chatbot-btn {
    width: 100%;
    min-height: 44px;
    white-space: normal;
    line-height: 1.35;
    border-radius: 12px;
    gap: 6px;
}

.chatbot-match-prompt {
    margin: 4px 0 0;
    text-align: center;
    color: var(--cb-outline);
    font-size: 0.78rem;
}

.chatbot-found-match {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatbot-found-match-list,
.chatbot-found-match-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-match-card {
    position: relative;
    overflow: hidden;
    background: var(--cb-card);
    border: 1px solid rgba(196, 198, 210, 0.85);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(13, 28, 48, 0.05);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatbot-match-card--verified {
    border: 2px solid rgba(4, 120, 87, 0.4);
    box-shadow: 0 4px 14px rgba(4, 120, 87, 0.08);
}

.chatbot-match-card--verified::after {
    content: "";
    position: absolute;
    inset-inline-start: -24px;
    bottom: -24px;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: #ecfdf5;
    opacity: 0.7;
    pointer-events: none;
}

.chatbot-match-top,
.chatbot-match-heading,
.chatbot-match-id,
.chatbot-match-badge,
.chatbot-match-cta,
.chatbot-btn,
.chatbot-chip {
    position: relative;
    z-index: 1;
}

.chatbot-match-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(196, 198, 210, 0.55);
}

.chatbot-match-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--cb-surface-low);
    color: var(--cb-navy);
    font-size: 0.68rem;
    font-weight: 700;
}

.chatbot-match-card--verified .chatbot-match-badge {
    background: var(--cb-emerald);
    color: #fff;
}

.chatbot-match-id {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid rgba(196, 198, 210, 0.7);
    background: var(--cb-surface-low);
    font-size: 0.68rem;
    color: var(--cb-outline);
}

.chatbot-bidi {
    direction: ltr;
    unicode-bidi: isolate;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--cb-navy);
}

.chatbot-match-copy {
    border: 0;
    background: transparent;
    color: var(--cb-outline);
    padding: 0;
    display: inline-flex;
    cursor: pointer;
}

.chatbot-match-copy:hover,
.chatbot-match-copy.is-copied {
    color: var(--cb-navy);
}

.chatbot-match-heading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-match-glyph {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--cb-surface-low);
    color: var(--cb-navy);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-match-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--cb-navy);
}

.chatbot-match-subtitle {
    color: var(--cb-outline);
    font-size: 0.75rem;
}

.chatbot-match-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(196, 198, 210, 0.35);
    background: rgba(240, 243, 255, 0.65);
}

.chatbot-match-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.chatbot-match-label,
.chatbot-match-note {
    color: var(--cb-outline);
    font-size: 0.68rem;
    font-weight: 600;
}

.chatbot-match-value,
.chatbot-match-note {
    color: var(--cb-text);
    font-size: 0.8rem;
    font-weight: 600;
    word-break: break-word;
}

.chatbot-match-note {
    font-weight: 400;
    line-height: 1.55;
}

.chatbot-match-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.chatbot-match-pill {
    display: inline-flex;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--cb-surface-high);
    color: var(--cb-text);
    font-size: 0.72rem;
    font-weight: 600;
}

.chatbot-match-pill-name {
    color: var(--cb-muted);
    font-weight: 500;
}

.chatbot-match-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--cb-orange);
    color: #fff !important;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
}

.chatbot-match-card--post .chatbot-match-cta {
    background: var(--cb-card);
    color: var(--cb-navy) !important;
    border: 1px solid var(--cb-line);
    font-weight: 600;
}

.chatbot-match-cta:hover,
.chatbot-match-cta:focus {
    filter: brightness(0.95);
}

.popover.mds-bs-persian-datetime-picker-popover {
    z-index: 10100;
}

.chatbot-error {
    margin: 0 14px 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #ffdad6;
    color: #93000a;
    font-size: 0.85rem;
}

.chatbot-error[hidden],
.chatbot-confirm[hidden],
.chatbot-created[hidden],
.chatbot-composer[hidden],
.chatbot-input[hidden],
.chatbot-date-composer[hidden],
.chatbot-send[hidden],
.chatbot-chips[hidden],
.chatbot-icon-btn[hidden] {
    display: none !important;
}

.chatbot-confirm,
.chatbot-created {
    margin: 0 14px 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--cb-card);
    border: 1px solid var(--cb-line);
    font-size: 0.85rem;
}

.chatbot-confirm-hint,
.chatbot-confirm-summary,
.chatbot-created p {
    margin: 0 0 8px;
}

.chatbot-confirm-summary {
    white-space: pre-wrap;
    color: var(--cb-text);
}

.chatbot-confirm-actions,
.chatbot-created {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.chatbot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}

.chatbot-btn-primary {
    background: var(--cb-orange);
    color: #fff !important;
}

.chatbot-btn-primary:hover,
.chatbot-btn-primary:focus {
    background: #783100;
    color: #fff !important;
}

.chatbot-btn-navy {
    background: var(--cb-navy);
    color: #fff !important;
}

.chatbot-btn-navy:hover,
.chatbot-btn-navy:focus {
    background: var(--cb-navy-deep);
    color: #fff !important;
}

.chatbot-btn-secondary {
    background: var(--cb-card);
    color: var(--cb-muted) !important;
    border-color: rgba(196, 198, 210, 0.9);
    font-weight: 600;
}

.chatbot-btn-secondary:hover,
.chatbot-btn-secondary:focus {
    background: var(--cb-surface-low);
}

.chatbot-btn:disabled,
.chatbot-input:disabled,
.chatbot-icon-btn:disabled,
.chatbot-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chatbot-footer {
    flex-shrink: 0;
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(196, 198, 210, 0.55);
    background: var(--cb-card);
    box-shadow: 0 -8px 24px rgba(13, 28, 48, 0.04);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.chatbot-chips::-webkit-scrollbar {
    display: none;
}

.chatbot-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(196, 198, 210, 0.8);
    border-radius: 999px;
    background: var(--cb-surface-low);
    color: var(--cb-navy);
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.chatbot-chip svg {
    width: 15px;
    height: 15px;
}

.chatbot-chip-accent {
    background: rgba(255, 219, 203, 0.7);
    border-color: rgba(254, 128, 51, 0.55);
    color: var(--cb-on-orange-soft);
}

.chatbot-chip:hover,
.chatbot-chip:focus {
    filter: brightness(0.97);
}

.chatbot-composer {
    margin: 0;
}

.chatbot-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 4px;
    border-radius: 16px;
    border: 1px solid rgba(196, 198, 210, 0.9);
    background: var(--cb-surface-low);
}

.chatbot-input-bar:focus-within {
    border-color: var(--cb-navy);
    box-shadow: 0 0 0 3px rgba(0, 45, 113, 0.12);
}

.chatbot-input {
    flex: 1;
    resize: none;
    min-height: 40px;
    max-height: 96px;
    border: 0;
    background: transparent;
    padding: 8px 6px;
    font-size: 0.9rem;
    color: var(--cb-text);
    text-align: start;
}

.chatbot-input:focus,
.chatbot-date-input:focus {
    outline: none;
}

.chatbot-input::placeholder,
.chatbot-date-input::placeholder {
    color: rgba(116, 119, 130, 0.75);
}

.chatbot-icon-btn,
.chatbot-send,
.chatbot-date-toggle {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}

.chatbot-icon-btn,
.chatbot-date-toggle {
    background: transparent;
    color: var(--cb-outline);
}

.chatbot-icon-btn:hover,
.chatbot-date-toggle:hover,
.chatbot-icon-btn[aria-pressed="true"] {
    background: rgba(222, 233, 255, 0.7);
    color: var(--cb-navy);
}

.chatbot-send {
    background: var(--cb-orange);
    color: #fff;
    box-shadow: 0 2px 6px rgba(158, 67, 0, 0.28);
}

.chatbot-send:hover,
.chatbot-send:focus {
    background: #783100;
    color: #fff;
}

[dir="rtl"] .chatbot-send-icon {
    transform: scaleX(-1);
}

.chatbot-date-composer {
    display: flex;
    flex: 1;
    align-items: center;
    min-width: 0;
}

.chatbot-date-input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 8px 4px;
    font-size: 0.9rem;
    color: var(--cb-text);
}

.chatbot-date-input:disabled,
.chatbot-date-toggle:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chatbot-trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: rgba(116, 119, 130, 0.9);
    font-size: 0.65rem;
    font-weight: 600;
    text-align: center;
}

.chatbot-trust svg {
    width: 13px;
    height: 13px;
    color: var(--cb-emerald);
    flex-shrink: 0;
}

.chatbot-widget :focus-visible {
    outline: 2px solid var(--cb-navy);
    outline-offset: 2px;
}

.chatbot-header :focus-visible {
    outline-color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    .chatbot-spinner,
    .chatbot-online-pill span,
    .chatbot-typing-dots span {
        animation: none;
    }
}

.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;
}
