/* =============================================================
   Chat Widget — CSS Variables (edit here to re-theme)
   ============================================================= */
:root {
    --chat-primary:        #EC4740;
    --chat-primary-dark:   #db241e;
    --chat-telegram:       #2ca5e0;
    --chat-telegram-dark:  #1a8bbf;
    --chat-fab-size:       56px;
    --chat-widget-width:   340px;
    --chat-radius:         16px;
    --chat-radius-sm:      8px;
    --chat-shadow:         0 8px 40px rgba(0, 0, 0, .5);
    --chat-bg:             #1e1e25;
    --chat-header-bg:      #EC4740;
    --chat-header-text:    #ffffff;
    --chat-text:           #C8C6DD;
    --chat-muted:          #8481A6;
    --chat-border:         #3a3a45;
    --chat-bubble-bot-bg:  #15151b;
    --chat-success-color:  #6fcf97;
    --chat-error-color:    #EC4740;
    --chat-z:              9999;
}

/* =============================================================
   FAB button
   ============================================================= */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 10px;
    z-index: var(--chat-z);
    width: var(--chat-fab-size);
    height: var(--chat-fab-size);
    border-radius: 50%;
    background: var(--chat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 34px rgba(236, 71, 64, .35);
    transition: background .2s, transform .15s;
    outline: none;
}

.chat-fab:hover {
    background: var(--chat-primary-dark);
    transform: scale(1.08);
}

.chat-fab:active {
    transform: scale(.96);
}

/* =============================================================
   Widget container
   ============================================================= */
.chat-widget {
    position: fixed;
    bottom: calc(var(--chat-fab-size) + 32px);
    right: 24px;
    z-index: var(--chat-z);
    width: var(--chat-widget-width);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.chat-widget.chat-widget--open {
    display: flex;
    animation: chat-slide-up .25s ease;
}

@keyframes chat-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =============================================================
   Header
   ============================================================= */
.chat-widget__header {
    background: var(--chat-header-bg);
    color: var(--chat-header-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
}

.chat-widget__header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-widget__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;

    img{
        max-width: none;
        height: 33px;
        width: fit-content;
        margin-top: auto;
    }
}

.chat-widget__name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.chat-widget__status {
    font-size: 11px;
    opacity: .8;
}

.chat-widget__close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: .75;
    transition: opacity .15s;
    display: flex;
    align-items: center;
}

.chat-widget__close:hover {
    opacity: 1;
}

/* =============================================================
   Panels
   ============================================================= */
.chat-panel {
    padding: 16px;
}

/* =============================================================
   Welcome panel
   ============================================================= */
.chat-bubble--bot {
    background: var(--chat-bubble-bot-bg);
    color: var(--chat-text);
    border-radius: 4px 14px 14px 14px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.chat-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =============================================================
   Buttons
   ============================================================= */
.chat-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    border-radius: var(--chat-radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .18s, transform .1s;
    line-height: 1.3;
    font-family: inherit;
}

.chat-btn:active {
    transform: scale(.97);
}

.chat-btn--primary {
    background: var(--chat-primary);
    color: #fff;
}

.chat-btn--primary:hover {
    background: var(--chat-primary-dark);
    color: #fff;
    text-decoration: none;
}

.chat-btn--outline {
    background: transparent;
    color: var(--chat-primary);
    border: 1.5px solid var(--chat-primary);
}

.chat-btn--outline:hover {
    background: rgba(236, 71, 64, .1);
    text-decoration: none;
}

.chat-btn--telegram {
    background: var(--chat-telegram);
    color: #fff;
}

.chat-btn--telegram:hover {
    background: var(--chat-telegram-dark);
    color: #fff;
    text-decoration: none;
}

.chat-btn--ghost {
    background: transparent;
    color: var(--chat-muted);
    border: none;
    padding-left: 0;
    font-size: 13px;
}

.chat-btn--ghost:hover {
    color: var(--chat-text);
}

.chat-btn--full {
    width: 100%;
}

/* =============================================================
   Form fields
   ============================================================= */
.chat-field {
    margin-bottom: 12px;
}

.chat-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.chat-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--chat-muted);
    margin-bottom: 4px;
}

.chat-required {
    color: var(--chat-error-color);
}

.chat-input {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--chat-border);
    border-radius: var(--chat-radius-sm);
    font-size: 13px;
    color: var(--chat-text);
    background: #131316;
    box-sizing: border-box;
    transition: border-color .15s;
    outline: none;
    font-family: inherit;
}

.chat-input:focus {
    border-color: var(--chat-primary);
}

.chat-input--error {
    border-color: var(--chat-error-color) !important;
}

.chat-textarea {
    resize: vertical;
    min-height: 64px;
}

.chat-error {
    display: none;
    font-size: 11px;
    color: var(--chat-error-color);
    margin-top: 3px;
}

.chat-error--visible {
    display: block;
}

/* File input */
.chat-file-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1.5px dashed var(--chat-border);
    border-radius: var(--chat-radius-sm);
    cursor: pointer;
    font-size: 12px;
    color: var(--chat-muted);
    transition: border-color .15s, color .15s;
    width: 100%;
    box-sizing: border-box;
}

.chat-file-label:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.chat-input-file {
    display: none;
}

.chat-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.chat-previews img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    border: 1.5px solid var(--chat-border);
}

/* Submit loading state */
.chat-btn--loading {
    opacity: .7;
    pointer-events: none;
}

.chat-btn--loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,.6);
    border-top-color: #fff;
    border-radius: 50%;
    animation: chat-spin .6s linear infinite;
    margin-left: 6px;
    vertical-align: middle;
}

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

/* =============================================================
   Success panel
   ============================================================= */
.chat-success-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
    color: var(--chat-success-color);
}

.chat-success-text {
    font-size: 14px;
    line-height: 1.55;
    color: var(--chat-text);
    text-align: center;
    margin: 0 0 16px;
}

/* =============================================================
   Mobile
   ============================================================= */
@media (max-width: 480px) {
    .chat-widget {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: calc(var(--chat-fab-size) + 16px);
    }

    .chat-fab {
        right: 16px;
        bottom: 16px;
    }
}
