/* Chat Tester — Styles for <chat-tester> component */

/* Container */
.ct-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* Toggle Button */
.ct-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--color-primary), #3b82f6);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(26, 86, 219, 0.35);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}
.ct-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(26, 86, 219, 0.45);
}
.ct-toggle__icon { display: flex; }
.ct-toggle__pulse {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: var(--color-success);
    border-radius: 50%;
    border: 2px solid #fff;
    animation: ctPulse 2s infinite;
}
@keyframes ctPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.3); }
}

/* Panel */
.ct-panel {
    display: flex;
    flex-direction: column;
    width: 420px;
    height: 600px;
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    animation: ctSlideUp 0.3s ease-out;
}
@keyframes ctSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.ct-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--color-primary), #3b82f6);
    color: #fff;
    flex-shrink: 0;
}
.ct-header__info { display: flex; align-items: center; gap: 10px; }
.ct-header__avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ct-header__title {
    display: block;
    font-size: 14px;
    font-weight: 700;
}
.ct-header__status {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    margin-top: 1px;
}
.ct-header__status--active { opacity: 1; color: #86efac; }
.ct-header__actions { display: flex; gap: 4px; }
.ct-header__btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}
.ct-header__btn:hover { background: rgba(255, 255, 255, 0.3); }

/* Messages */
.ct-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}
.ct-messages::-webkit-scrollbar { width: 4px; }
.ct-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* Welcome */
.ct-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    flex: 1;
}
.ct-welcome__icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--color-primary);
}
.ct-welcome__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 8px;
}
.ct-welcome__desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin: 0 0 20px;
    max-width: 300px;
}
.ct-btn-start {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.ct-btn-start:hover { background: var(--color-primary-hover); transform: translateY(-1px); }
.ct-btn-start:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Messages */
.ct-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: ctFadeIn 0.25s ease-out;
}
@keyframes ctFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.ct-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.ct-msg--bot { align-self: flex-start; }
.ct-msg--error { align-self: center; }

.ct-msg__avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--color-primary), #3b82f6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    margin-top: 2px;
}

.ct-msg__content { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.ct-msg__bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.ct-msg--bot .ct-msg__bubble {
    background: #fff;
    color: var(--color-text);
    border: 1px solid #e5e7eb;
    border-radius: 14px 14px 14px 4px;
}
.ct-msg--user .ct-msg__bubble {
    background: var(--color-primary);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
}
.ct-msg__bubble--error {
    background: var(--color-danger-light) !important;
    color: var(--color-danger) !important;
    border: 1px solid #fecaca !important;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ct-msg__time {
    font-size: 11px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
.ct-msg--user .ct-msg__time { text-align: right; justify-content: flex-end; }

/* Typing indicator */
.ct-typing {
    display: flex;
    gap: 8px;
    align-self: flex-start;
    align-items: center;
    animation: ctFadeIn 0.2s ease-out;
}
.ct-typing__dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px 14px 14px 4px;
}
.ct-typing__dots span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: ctBounce 1.4s ease-in-out infinite;
}
.ct-typing__dots span:nth-child(2) { animation-delay: 0.16s; }
.ct-typing__dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes ctBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Quick buttons */
.ct-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 16px;
}
.ct-buttons:empty { display: none; }
.ct-quick-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    border: 1px solid rgba(26, 86, 219, 0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.ct-quick-btn:hover {
    background: var(--color-primary);
    color: #fff;
}

/* Input area */
.ct-input-area {
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
}
.ct-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
}
.ct-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    font-size: 13.5px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.15s;
    max-height: 120px;
    background: #f8fafc;
}
.ct-input:focus {
    border-color: var(--color-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}
.ct-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.ct-send:hover:not(:disabled) { background: var(--color-primary-hover); }
.ct-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Spinner */
.ct-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ctSpin 0.6s linear infinite;
}
@keyframes ctSpin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 480px) {
    .ct-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        border-radius: 12px;
    }
    .ct-container {
        bottom: 8px;
        right: 8px;
    }
}
