.chat-widget {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1060;
    font-family: var(--font-yekanbakh, 'Yekan Bakh', sans-serif);
}

.chat-widget__toggle {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: #ef4056;
    color: #fff;
    box-shadow: 0 8px 24px rgba(239, 64, 86, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-widget__toggle:hover {
    transform: scale(1.05);
}

.chat-widget__toggle-icon {
    font-size: 26px;
    line-height: 1;
}

.chat-widget__toggle-icon--close {
    display: none;
}

.chat-widget.is-open .chat-widget__toggle-icon--open {
    display: none;
}

.chat-widget.is-open .chat-widget__toggle-icon--close {
    display: block;
}

.chat-widget__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #212529;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.chat-widget__panel {
    position: absolute;
    left: 0;
    bottom: 72px;
    width: min(360px, calc(100vw - 32px));
    height: min(520px, calc(100vh - 120px));
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #ececec;
}

.chat-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #ef4056, #d93649);
    color: #fff;
}

.chat-widget__title {
    display: block;
    font-size: 15px;
    font-weight: 700;
}

.chat-widget__status {
    display: block;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.chat-widget__status.is-connecting {
    opacity: 0.75;
}

.chat-widget__status.is-offline {
    color: #ffe0e0;
}

.chat-widget__close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-widget__guest-form {
    padding: 16px;
    overflow-y: auto;
}

.chat-widget__intro {
    font-size: 13px;
    color: #616161;
    margin: 0 0 14px;
    line-height: 1.7;
}

.chat-widget__field {
    margin-bottom: 12px;
}

.chat-widget__field label {
    display: block;
    font-size: 13px;
    color: #424750;
    margin-bottom: 6px;
    font-weight: 600;
}

.chat-widget__input {
    width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-widget__input:focus {
    border-color: #ef4056;
}

.chat-widget__submit {
    width: 100%;
    border: none;
    border-radius: 10px;
    background: #ef4056;
    color: #fff;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.chat-widget__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-widget__error {
    margin: 10px 0 0;
    color: #dc3545;
    font-size: 12px;
    line-height: 1.6;
}

.chat-widget__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #f7f7f8;
}

.chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-widget__message {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.7;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-widget__message--customer {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #ececec;
    border-bottom-right-radius: 4px;
}

.chat-widget__message--admin {
    align-self: flex-end;
    background: #ef4056;
    color: #fff;
    border-bottom-left-radius: 4px;
}

.chat-widget__message--system {
    align-self: center;
    background: #ececec;
    color: #616161;
    font-size: 12px;
    max-width: 95%;
    text-align: center;
}

.chat-widget__message-time {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    opacity: 0.7;
}

.chat-widget__typing {
    padding: 0 14px 8px;
    font-size: 12px;
    color: #81858b;
}

.chat-widget__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #ececec;
    background: #fff;
}

.chat-widget__textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    max-height: 100px;
    font-family: inherit;
    outline: none;
}

.chat-widget__textarea:focus {
    border-color: #ef4056;
}

.chat-widget__send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: #ef4056;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-widget__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-widget__empty {
    margin: auto;
    text-align: center;
    color: #81858b;
    font-size: 13px;
    line-height: 1.8;
    padding: 20px;
}

@media (max-width: 991.98px) {
    .chat-widget {
        bottom: 86px;
    }

    .chat-widget.is-open {
        inset: 0;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
    }

    .chat-widget.is-open .chat-widget__toggle {
        display: none;
    }

    .chat-widget__panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .chat-widget__header {
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }

    .chat-widget__composer {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    body.chat-widget-open {
        overflow: hidden;
    }
}

@media (max-width: 575.98px) {
    .chat-widget {
        left: 12px;
        bottom: 82px;
    }

    .chat-widget.is-open {
        left: 0;
    }
}
