/* Chatbot Design System */
:root {
    --brand-color-primary: #488bfb;
    --brand-color-secondary: #3a73d1;
    --brand-color-accent: #6aa8ff;

    --cb-bg: rgb(245, 249, 255);
    --cb-surface: rgb(255, 255, 255);
    --cb-text: rgb(28, 34, 43);
    --cb-text-dim: rgb(79, 86, 97);
    --cb-border: rgb(229, 231, 235);
    --cb-msg-self: var(--brand-color-primary);
    --cb-msg-other: rgb(243, 244, 246);
    --cb-shadow: 0 10px 40px -10px rgba(8, 21, 44, 0.15);
    --cb-shadow-sm: 0 4px 12px -2px rgba(8, 21, 44, 0.1);
}

.cb-widget {
    position: fixed;
    bottom: 60px;
    right: 0px;
    z-index: 10000;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--cb-text);
}

/*
.cb-toggle-btn {
    width: auto;
    min-width: 56px;
    height: 56px;
    padding: 0 20px;
    border-radius: 16px;
    background: var(--brand-color-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--cb-shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*/
.cb-toggle-btn {
    width: auto;
    min-width: 50px;
    height: 48px;
    padding: 0 16px 0 12px;
    border-radius: 10rem 0 0 10rem;
    background: var(--brand-color-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--cb-shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.cb-toggle-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cb-toggle-btn .cb-status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-width: 2px;
}

.cb-toggle-label {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.cb-toggle-status-text {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.9;
    margin-top: -1px;
}

.cb-toggle-btn:hover {
    transform: translateX(-4px);
    background: var(--brand-color-secondary);
    box-shadow: var(--cb-shadow);
}

.cb-toggle-btn:focus-visible {
    outline: 3px solid var(--brand-color-accent);
    outline-offset: 2px;
}

.cb-window {
    position: absolute;
    bottom: 0px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--cb-surface);
    border-radius: 20px;
    box-shadow: var(--cb-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    border: 1px solid var(--cb-border);
}

.cb-window.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1024px) {
	.cb-window{
		bottom:0px;
	}
}

.cb-header {
    background: var(--cb-surface);
    color: var(--cb-text);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--cb-border);
}

.cb-header h3 {
    margin: 0;
    font-size: 1.25rem !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    letter-spacing: -0.01em;
    padding: 0 !important;
}

.cb-status-header-text {
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
    transition: color 0.3s ease;
    text-transform: capitalize;
}

.cb-close {
    background: var(--cb-msg-other);
    border: none;
    color: var(--cb-text-dim);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cb-close:hover {
    background: var(--cb-border);
    color: var(--cb-text);
}

.cb-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--cb-bg);
}

.cb-message {
    max-width: 90%;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.cb-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--cb-border);
}

.cb-message-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
	max-width:15rem;
    word-wrap: break-word;
}

.cb-message-content a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.cb-message-content a:hover {
    opacity: 1;
}

.cb-message-self .cb-message-content a {
    color: white;
}

.cb-message-self {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cb-message-self .cb-message-content {
    background: var(--cb-msg-self);
    color: white;
    border-bottom-right-radius: 4px;
}

.cb-message-other {
    align-self: flex-start;
}

.cb-message-other .cb-message-content {
    background: var(--cb-surface);
    color: var(--cb-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--cb-border);
}

.cb-message-meta {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.5;
    display: block;
}

.cb-message-self .cb-message-meta {
    text-align: right;
}

.cb-input-area {
    padding: 20px;
    background: var(--cb-surface);
    border-top: 1px solid var(--cb-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.cb-input-wrapper {
    display: flex;
    gap: 12px;
}

.cb-input-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.cb-char-counter {
    font-size: 11px;
    color: var(--cb-text-dim);
    transition: color 0.2s;
}

.cb-char-counter.limit-reached {
    color: rgb(202, 84, 90);
    font-weight: 600;
}

.cb-input {
    flex: 1;
    border: 1px solid var(--cb-border);
    padding: 12px 16px;
    border-radius: 12px;
    outline: none;
    font-size: 14px;
    background: var(--cb-bg);
    transition: all 0.2s ease;
}

.cb-input:focus {
    border-color: var(--brand-color-primary);
    background: var(--cb-surface);
    box-shadow: 0 0 0 3px rgba(72, 139, 251, 0.15);
}

.cb-send {
    background: var(--brand-color-primary);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.cb-send:hover {
    background: var(--brand-color-secondary);
}

.cb-send:focus-visible {
    outline: 3px solid var(--brand-color-accent);
    outline-offset: 2px;
}

/* ── Rate-limit Cooldown Overlay ─────────────────────────────────────────────
   Sits inside .cb-window (position: absolute), covering messages + input.
   Appears when the server returns rate_limited: true.
   Auto-dismisses when the countdown reaches zero.
   ─────────────────────────────────────────────────────────────────────────── */

.cb-cooldown-overlay {
    position: absolute;
    inset: 0;
    /* covers the entire chat window */
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: inherit;
    animation: cb-fade-in 0.25s ease;
}

@keyframes cb-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.cb-cooldown-card {
    background: var(--cb-surface);
    border: 1px solid var(--cb-border);
    border-radius: 16px;
    padding: 32px 28px 28px;
    width: 82%;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.3);
    animation: cb-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cb-slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cb-cooldown-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgb(255, 232, 227);
    color: rgb(202, 84, 90);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.cb-cooldown-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--cb-text);
    letter-spacing: -0.01em;
}

.cb-cooldown-desc {
    margin: 0;
    font-size: 12px;
    color: var(--cb-text-dim);
    line-height: 1.6;
}

/* SVG countdown ring */
.cb-cooldown-ring-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 12px 0 4px;
}

.cb-cooldown-ring {
    width: 80px;
    height: 80px;
    transform: rotate(-90deg);
    /* start progress from 12 o'clock */
}

.cb-cooldown-ring-bg {
    fill: none;
    stroke: var(--cb-border);
    stroke-width: 5;
}

.cb-cooldown-ring-fill {
    fill: none;
    stroke: rgb(197, 56, 41);
    /* warm amber-orange */
    stroke-width: 5;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear;
}

.cb-cooldown-seconds {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--cb-text);
    letter-spacing: -0.03em;
}

.cb-cooldown-label {
    margin: 0;
    font-size: 11px;
    color: var(--cb-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.cb-date-divider {
    text-align: center;
    font-size: 11px;
    color: var(--cb-text-dim);
    margin: 16px 0 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cb-load-more {
    display: block;
    margin: 0 auto 16px;
    padding: 6px 14px;
    font-size: 12px;
    background: transparent;
    color: var(--brand-color-primary);
    border: 1px solid var(--brand-color-primary);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.cb-load-more:hover {
    background: var(--brand-color-primary);
    color: white;
}

.cb-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}



/* File Preview Bar */
.cb-file-preview {
    position: absolute;
    bottom: 100%;
    left: 20px;
    right: 20px;
    background: var(--cb-surface);
    border: 1px solid var(--cb-border);
    border-bottom: 2px solid var(--brand-color-primary);
    border-radius: 12px 12px 0 0;
    padding: 8px 12px;
    display: none;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.05);
    transform: translateY(1px);
}

.cb-file-preview.active {
    display: flex;
}

.cb-preview-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--cb-text);
    overflow: hidden;
}

.cb-preview-info .file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.cb-remove-file {
    background: none;
    border: none;
    color: var(--cb-text-dim);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.cb-remove-file:hover {
    color: #ef4444;
}


/* media queries */

@media screen and (max-width:1024px) {
    .cb-widget {
        bottom: 60px;
    }
}

/* Custom Global Modal Styles (shared) */
.cb-modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cb-fade-in 0.3s ease;
}

.cb-modal {
    background: var(--cb-surface);
    border-radius: 16px;
    width: 85%;
    max-width: 300px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: cb-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.cb-modal-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cb-modal-icon-wrap.primary {
    background: var(--brand-color-primary);
}

.cb-modal-icon-wrap.danger {
    background: #ef4444;
}

.cb-modal-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--cb-text);
}

.cb-modal-desc {
    margin: 0 0 20px;
    font-size: 13px;
    color: var(--cb-text-dim);
    line-height: 1.5;
}

.cb-modal-actions {
    display: flex;
    gap: 10px;
}

.cb-modal-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.cb-modal-btn-primary {
    background: var(--brand-color-primary);
    color: white;
}

.cb-modal-btn-secondary {
    background: var(--cb-msg-other);
    color: var(--cb-text);
}

/* Status Indicator */
.cb-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    vertical-align: middle;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    border: 1.5px solid #ffffff;
}

.cb-status-dot.online {
    background-color: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    animation: cb-pulse-green 2s infinite;
}

.cb-status-dot.offline {
    background-color: #ef4444;
    box-shadow: none;
    animation: none;
}

#cb-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 8px;
    height: 8px;
}

.cb-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes cb-pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}