/* ====================================================
   ویجت پشتیبانی آنلاین - استایل کامل و حرفه‌ای
   ==================================================== */

/* ===== کانتینر اصلی ===== */
.wc-bale-support-container {
    position: fixed;
    z-index: 999999;
    bottom: 30px;
    right: 30px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    direction: rtl;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.wc-bale-support-container.position-left {
    right: auto;
    left: 30px;
    align-items: flex-start;
}

/* ===== دکمه شناور ===== */
.wc-bale-support-toggle {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: var(--bale-support-color, #007cba);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    user-select: none;
}

.wc-bale-support-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.wc-bale-support-toggle:active {
    transform: scale(0.94);
}

.wc-bale-support-icon {
    font-size: 30px;
    line-height: 1;
    color: #ffffff;
    pointer-events: none;
}

/* ===== دایره وضعیت ===== */
.wc-bale-support-status-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2.5px solid #ffffff;
    background: #a0aec0;
    transition: background 0.3s ease;
}

.wc-bale-support-status-dot.online {
    background: #22c55e;
}

.wc-bale-support-status-dot.offline {
    background: #ef4444;
}

/* ===== شمارنده پیام (جابجا شده به بالای دکمه) ===== */
.wc-bale-support-notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 11;
    line-height: 1;
}

.wc-bale-support-notification-badge.multi-digit {
    min-width: 24px;
    height: 24px;
    font-size: 12px;
}

.wc-bale-support-notification-badge.show {
    display: flex;
}

/* ===== پنجره چت ===== */
.wc-bale-support-window {
    display: none;
    position: absolute;
    bottom: 78px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 30px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    flex-direction: column;
    animation: wc-bale-support-slide-up 0.25s ease-out;
    transform-origin: bottom right;
}

.wc-bale-support-container.position-left .wc-bale-support-window {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.wc-bale-support-container.open .wc-bale-support-window {
    display: flex;
}

@keyframes wc-bale-support-slide-up {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===== هدر ===== */
.wc-bale-support-header {
    padding: 16px 20px;
    background: var(--bale-support-color, #007cba);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.wc-bale-support-title {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.3px;
}

.wc-bale-support-status-text {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 400;
}

.wc-bale-support-close {
    all: unset;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
    line-height: 1;
}

.wc-bale-support-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ===== فرم تکمیل اطلاعات (حرفه‌ای و زیبا) ===== */
.wc-bale-support-info-form {
    display: none;
    flex-direction: column;
    flex: 1;
    padding: 20px 24px 24px;
    background: #f8fafc;
    overflow-y: auto;
}

.wc-bale-info-header {
    text-align: center;
    margin-bottom: 16px;
}

.wc-bale-info-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    display: block;
}

.wc-bale-info-desc {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}

.wc-bale-info-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
}

.wc-bale-info-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wc-bale-info-field label {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.wc-bale-info-field label .required-star {
    color: #ef4444;
    margin-right: 2px;
}

.wc-bale-info-field label .optional-badge {
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 12px;
    margin-right: 6px;
}

.wc-bale-info-field input {
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
    color: #1e293b;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.wc-bale-info-field input:focus {
    border-color: var(--bale-support-color, #007cba);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.12);
}

.wc-bale-info-field input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.wc-bale-info-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    border-right: 3px solid #dc2626;
    display: none;
}

.wc-bale-info-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.wc-bale-info-btn-primary {
    all: unset;
    flex: 1;
    padding: 12px 20px;
    background: var(--bale-support-color, #007cba);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.wc-bale-info-btn-primary:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.wc-bale-info-btn-primary:active {
    transform: scale(0.96);
}

.wc-bale-info-btn-skip {
    all: unset;
    padding: 12px 20px;
    background: #e2e8f0;
    color: #475569;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: none;
}

.wc-bale-info-btn-skip:hover {
    background: #cbd5e1;
}

/* ===== پیام‌ها ===== */
.wc-bale-support-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 12px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* اسکرول‌بار */
.wc-bale-support-messages::-webkit-scrollbar {
    width: 6px;
}

.wc-bale-support-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.wc-bale-support-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.wc-bale-support-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.wc-bale-support-messages {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* ===== پیام‌ها ===== */
.wc-bale-support-message {
    max-width: 82%;
    padding: 10px 16px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    animation: wc-bale-support-fade-in 0.2s ease;
}

@keyframes wc-bale-support-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wc-bale-support-message.bot {
    background: var(--bale-support-color, #007cba);
    color: #ffffff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.wc-bale-support-message.user {
    background: #e9edf2;
    color: #1e293b;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.wc-bale-support-message.auto {
    background: #f1f5f9;
    color: #1e293b;
    border-right: 4px solid var(--bale-support-color, #007cba);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.wc-bale-support-message.tracking {
    background: #f0fdf4;
    color: #166534;
    border-right: 4px solid #22c55e;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    padding: 12px 18px;
    max-width: 90%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    line-height: 1.8;
}

.wc-bale-support-message a {
    color: var(--bale-support-color, #007cba);
    text-decoration: underline;
    word-break: break-all;
}

.wc-bale-support-message a:hover {
    opacity: 0.8;
}

.wc-bale-support-ticks {
    font-size: 12px;
    color: #94a3b8;
    transition: color 0.5s ease;
    margin-right: 4px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ===== دکمه‌های انتخاب سفارش ===== */
.wc-bale-support-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 4px;
    justify-content: flex-start;
    max-width: 90%;
}

.wc-bale-support-order-btn {
    all: unset;
    padding: 8px 16px;
    background: #ffffff;
    border: 1.5px solid var(--bale-support-color, #007cba);
    border-radius: 20px;
    color: var(--bale-support-color, #007cba);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-width: 60px;
}

.wc-bale-support-order-btn:hover {
    background: var(--bale-support-color, #007cba);
    color: #ffffff;
    transform: scale(1.04);
}

.wc-bale-support-order-btn:active {
    transform: scale(0.94);
}

/* ===== ناحیه ورودی ===== */
.wc-bale-support-input-area {
    display: flex;
    padding: 12px 16px 16px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
    flex-shrink: 0;
    gap: 8px;
    align-items: center;
}

.wc-bale-support-track-btn {
    all: unset;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #475569;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    border: 1.5px solid #e2e8f0;
}

.wc-bale-support-track-btn:hover {
    background: #e2e8f0;
    transform: scale(1.04);
    border-color: var(--bale-support-color, #007cba);
}

.wc-bale-support-track-btn:active {
    transform: scale(0.94);
}

#wc-bale-support-input {
    all: unset;
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 50px;
    padding: 10px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #f8fafc;
    color: #1e293b;
    font-family: inherit;
    min-height: 44px;
    box-sizing: border-box;
}

#wc-bale-support-input:focus {
    border-color: var(--bale-support-color, #007cba);
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.12);
    background: #ffffff;
}

#wc-bale-support-input::placeholder {
    color: #94a3b8;
}

#wc-bale-support-send {
    all: unset;
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--bale-support-color, #007cba);
    color: #ffffff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

#wc-bale-support-send:hover {
    opacity: 0.85;
    transform: scale(1.04);
}

#wc-bale-support-send:active {
    transform: scale(0.94);
}

#wc-bale-support-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== رسپانسیو (موبایل) ===== */
@media (max-width: 520px) {
    .wc-bale-support-container {
        bottom: 16px;
        right: 16px;
    }

    .wc-bale-support-container.position-left {
        left: 16px;
        right: auto;
    }

    .wc-bale-support-toggle {
        width: 56px;
        height: 56px;
    }

    .wc-bale-support-icon {
        font-size: 26px;
    }

    .wc-bale-support-window {
        width: calc(100vw - 32px);
        max-width: 100vw;
        height: 480px; /* افزایش ارتفاع در موبایل */
        max-height: calc(100vh - 100px);
        bottom: 70px;
        right: 0;
        border-radius: 16px;
    }

    .wc-bale-support-container.position-left .wc-bale-support-window {
        left: 0;
        right: auto;
    }

    .wc-bale-support-header {
        padding: 12px 16px;
    }

    .wc-bale-support-title {
        font-size: 15px;
    }

    .wc-bale-support-status-text {
        font-size: 12px;
    }

    .wc-bale-support-message {
        font-size: 13px;
        padding: 8px 14px;
        max-width: 88%;
    }

    .wc-bale-support-message.tracking {
        padding: 10px 14px;
        font-size: 13px;
    }

    #wc-bale-support-input {
        font-size: 13px;
        padding: 8px 14px;
        min-height: 40px;
    }

    #wc-bale-support-send {
        width: 40px;
        height: 40px;
        font-size: 17px;
    }

    .wc-bale-support-track-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .wc-bale-support-info-form {
        padding: 16px 18px 18px;
    }

    .wc-bale-info-title {
        font-size: 16px;
    }

    .wc-bale-info-field input {
        font-size: 13px;
        padding: 8px 12px;
    }

    .wc-bale-info-btn-primary,
    .wc-bale-info-btn-skip {
        font-size: 13px;
        padding: 10px 16px;
    }

    .wc-bale-support-button-group {
        gap: 6px;
    }

    .wc-bale-support-order-btn {
        font-size: 12px;
        padding: 6px 14px;
        min-width: 50px;
    }

    .wc-bale-support-notification-badge {
        font-size: 10px;
        min-width: 18px;
        height: 18px;
        top: -6px;
        right: -6px;
    }
}

@media (max-width: 380px) {
    .wc-bale-support-window {
        height: 400px;
        bottom: 62px;
    }

    .wc-bale-support-toggle {
        width: 48px;
        height: 48px;
    }

    .wc-bale-support-icon {
        font-size: 22px;
    }

    .wc-bale-support-message {
        font-size: 12px;
        padding: 6px 12px;
        max-width: 92%;
    }

    #wc-bale-support-input {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 36px;
    }

    #wc-bale-support-send {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .wc-bale-support-track-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

/* ===== حالت تاریک ===== */
@media (prefers-color-scheme: dark) {
    .wc-bale-support-window {
        background: #1e293b;
    }

    .wc-bale-support-messages {
        background: #0f172a;
    }

    .wc-bale-support-message.user {
        background: #334155;
        color: #e2e8f0;
    }

    .wc-bale-support-message.auto {
        background: #1e293b;
        color: #e2e8f0;
        border-right-color: var(--bale-support-color, #007cba);
    }

    .wc-bale-support-message.tracking {
        background: #1e293b;
        color: #86efac;
        border-right-color: #22c55e;
    }

    .wc-bale-support-input-area {
        background: #1e293b;
        border-top-color: #334155;
    }

    #wc-bale-support-input {
        background: #0f172a;
        color: #e2e8f0;
        border-color: #334155;
    }

    #wc-bale-support-input:focus {
        background: #1e293b;
        border-color: var(--bale-support-color, #007cba);
    }

    .wc-bale-support-info-form {
        background: #0f172a;
    }

    .wc-bale-info-title {
        color: #e2e8f0;
    }

    .wc-bale-info-desc {
        color: #94a3b8;
    }

    .wc-bale-info-field label {
        color: #e2e8f0;
    }

    .wc-bale-info-field input {
        background: #1e293b;
        color: #e2e8f0;
        border-color: #334155;
    }

    .wc-bale-info-field input:focus {
        border-color: var(--bale-support-color, #007cba);
        box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.2);
    }

    .wc-bale-info-btn-skip {
        background: #334155;
        color: #94a3b8;
    }

    .wc-bale-info-btn-skip:hover {
        background: #475569;
    }

    .wc-bale-info-error {
        background: #451a1a;
        color: #f87171;
        border-right-color: #ef4444;
    }

    .wc-bale-support-close {
        background: rgba(255, 255, 255, 0.1);
    }

    .wc-bale-support-close:hover {
        background: rgba(255, 255, 255, 0.2);
    }

    .wc-bale-support-messages::-webkit-scrollbar-track {
        background: #1e293b;
    }

    .wc-bale-support-messages::-webkit-scrollbar-thumb {
        background: #475569;
    }

    .wc-bale-support-messages::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }

    .wc-bale-support-messages {
        scrollbar-color: #475569 #1e293b;
    }

    .wc-bale-support-order-btn {
        background: #1e293b;
        color: #94a3b8;
        border-color: #475569;
    }

    .wc-bale-support-order-btn:hover {
        background: var(--bale-support-color, #007cba);
        color: #ffffff;
    }

    .wc-bale-support-track-btn {
        background: #1e293b;
        color: #94a3b8;
        border-color: #334155;
    }

    .wc-bale-support-track-btn:hover {
        background: #334155;
        border-color: var(--bale-support-color, #007cba);
    }
}