/* ===================================================
   پشتیبانی حرفه‌ای - استایل فرانت‌اند
   تم: نارنجی و سبز - RTL
   =================================================== */

:root {
    --st-orange: #f97316;
    --st-orange-dark: #ea580c;
    --st-orange-light: #ffedd5;
    --st-green: #16a34a;
    --st-green-dark: #15803d;
    --st-green-light: #dcfce7;
    --st-dark: #1f2937;
    --st-gray: #6b7280;
    --st-gray-light: #f3f4f6;
    --st-white: #ffffff;
    --st-shadow: 0 10px 30px rgba(249, 115, 22, 0.18);
    --st-shadow-green: 0 10px 30px rgba(22, 163, 74, 0.18);
    --st-radius: 18px;
}

.st-widget * {
    box-sizing: border-box;
    font-family: inherit;
}

.st-widget {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99999;
    direction: rtl;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, "Iranian Sans", sans-serif;
}

/* === دکمه معلق === */
.st-fab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--st-orange) 0%, var(--st-orange-dark) 100%);
    color: var(--st-white);
    border: none;
    padding: 16px 24px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    box-shadow: var(--st-shadow);
    transition: all 0.3s ease;
    overflow: visible;
}

.st-fab:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 40px rgba(249, 115, 22, 0.35);
}

.st-fab:active {
    transform: translateY(0) scale(0.98);
}

.st-fab-icon,
.st-fab-close {
    flex-shrink: 0;
}

.st-fab-label {
    letter-spacing: 0.5px;
}

.st-fab-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50px;
    background: var(--st-orange);
    z-index: -1;
    animation: st-pulse 2s infinite;
    pointer-events: none;
}

@keyframes st-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.5); opacity: 0; }
}

.st-widget.st-open .st-fab-pulse {
    display: none;
}

/* === badge نوتیفیکیشن روی دکمه === */
.st-fab-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #16a34a;
    color: #fff;
    border-radius: 50%;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.5), 0 0 0 3px #fff;
    z-index: 2;
    animation: st-badge-bounce 0.5s ease;
}

@keyframes st-badge-bounce {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* === پنل چت === */
.st-panel {
    position: absolute;
    bottom: 90px;
    left: 0;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 130px);
    background: var(--st-white);
    border-radius: var(--st-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: st-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(249, 115, 22, 0.15);
}

@keyframes st-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* هدر پنل */
.st-panel-header {
    background: linear-gradient(135deg, var(--st-green) 0%, var(--st-green-dark) 100%);
    color: var(--st-white);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.st-panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.st-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--st-white);
}

.st-panel-name {
    font-weight: 700;
    font-size: 15px;
}

.st-panel-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.st-dot {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: st-blink 1.5s infinite;
}

@keyframes st-blink {
    50% { opacity: 0.4; }
}

.st-panel-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--st-white);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.st-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* بدنه پنل */
.st-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: linear-gradient(180deg, #fffaf5 0%, #ffffff 100%);
}

.st-panel-body::-webkit-scrollbar {
    width: 6px;
}
.st-panel-body::-webkit-scrollbar-thumb {
    background: var(--st-orange);
    border-radius: 10px;
}

/* صفحه خوش‌آمد */
.st-welcome {
    text-align: center;
    padding: 24px 12px;
}

.st-welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--st-orange) 0%, var(--st-orange-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: var(--st-shadow);
}

.st-welcome h3 {
    margin: 0 0 8px;
    color: var(--st-dark);
    font-size: 18px;
    font-weight: 700;
}

.st-welcome p {
    margin: 0 0 20px;
    color: var(--st-gray);
    font-size: 14px;
    line-height: 1.7;
}

.st-welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.st-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.25s;
    text-align: right;
}

.st-action-btn-primary {
    background: linear-gradient(135deg, var(--st-orange) 0%, var(--st-orange-dark) 100%);
    color: #fff;
    box-shadow: var(--st-shadow);
}

.st-action-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(249, 115, 22, 0.35);
}

.st-action-btn-secondary {
    background: var(--st-green-light);
    color: var(--st-green-dark);
    border: 1.5px solid var(--st-green);
}

.st-action-btn-secondary:hover {
    background: var(--st-green);
    color: #fff;
}

/* فرم */
.st-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* بخش خوش‌آمد در فرم */
.st-form-welcome {
    text-align: center;
    padding: 6px 0 14px;
    margin-bottom: 4px;
    border-bottom: 1px solid #f3f4f6;
}

.st-mini-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 10px;
    background: linear-gradient(135deg, var(--st-orange) 0%, var(--st-orange-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.25);
}

.st-form-welcome p {
    margin: 0;
    color: var(--st-gray);
    font-size: 13px;
    line-height: 1.6;
}

/* دکمه لینکی برای دسترسی‌های ثانویه مثل پیگیری */
.st-link-btn {
    background: transparent !important;
    color: var(--st-orange-dark) !important;
    border: none !important;
    box-shadow: none !important;
    text-decoration: none;
    font-size: 13px;
    padding: 10px 4px !important;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: color 0.2s;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.st-link-btn:hover {
    color: var(--st-orange) !important;
    transform: none !important;
    box-shadow: none !important;
}

/* اطلاعات شماره تیکت پس از ارسال موفق */
.st-ticket-id-info {
    text-align: center;
    color: var(--st-gray);
    font-size: 13px;
    padding: 8px 0 4px;
    margin-bottom: 4px;
}

.st-ticket-id-info strong {
    color: var(--st-orange-dark);
    font-size: 16px;
}

.st-form-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--st-dark);
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.st-form-back {
    background: var(--st-gray-light);
    color: var(--st-dark);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

.st-form-back:hover {
    background: #e5e7eb;
}

.st-field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--st-dark);
    margin-bottom: 4px;
    display: block;
}

.st-input,
.st-textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: var(--st-dark);
    transition: all 0.2s;
    font-family: inherit;
}

.st-textarea {
    resize: vertical;
    min-height: 90px;
}

.st-input:focus,
.st-textarea:focus {
    outline: none;
    border-color: var(--st-orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.st-submit-btn {
    background: linear-gradient(135deg, var(--st-orange) 0%, var(--st-orange-dark) 100%);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
    box-shadow: var(--st-shadow);
}

.st-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(249, 115, 22, 0.35);
}

.st-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.st-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid #fecaca;
}

.st-success {
    background: var(--st-green-light);
    color: var(--st-green-dark);
    padding: 14px;
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
    border: 1px solid var(--st-green);
    margin-bottom: 12px;
}

/* === لیست تیکت‌ها === */
.st-ticket-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* دکمه «تیکت جدید» در بالای لیست */
.st-new-ticket-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: linear-gradient(135deg, var(--st-green) 0%, var(--st-green-dark) 100%);
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
    box-shadow: var(--st-shadow-green);
    font-family: inherit;
}

.st-new-ticket-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(22, 163, 74, 0.35);
}

.st-new-ticket-btn:active {
    transform: translateY(0) scale(0.98);
}

.st-ticket-item {
    background: #fff;
    border: 1.5px solid #f3f4f6;
    border-right: 4px solid var(--st-orange);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
}

.st-ticket-item:hover {
    border-color: var(--st-orange);
    border-right-color: var(--st-green);
    transform: translateX(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

/* تیکت با پاسخ خوانده نشده از پشتیبان */
.st-ticket-item-unread {
    background: linear-gradient(90deg, #fff7ed 0%, #ffffff 60%);
    border-color: var(--st-orange-light);
    border-right-color: var(--st-green);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.12);
    animation: st-unread-glow 2s ease-in-out infinite;
}

@keyframes st-unread-glow {
    0%, 100% { box-shadow: 0 4px 12px rgba(22, 163, 74, 0.12); }
    50%      { box-shadow: 0 4px 18px rgba(22, 163, 74, 0.25); }
}

.st-ticket-item-unread .st-ticket-item-subject {
    color: var(--st-orange-dark);
    font-weight: 800;
}

.st-ticket-item-unread:hover {
    background: linear-gradient(90deg, #ffedd5 0%, #ffffff 60%);
    border-color: var(--st-orange);
    border-right-color: var(--st-green-dark);
}

/* نقطه نوتیفیکیشن کنار تیکت خوانده نشده */
.st-ticket-unread-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    background: var(--st-green);
    border-radius: 50%;
    margin-left: 8px;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
    animation: st-dot-pulse 1.4s ease-in-out infinite;
    vertical-align: middle;
}

@keyframes st-dot-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2); }
    50%      { transform: scale(1.25); box-shadow: 0 0 0 5px rgba(22, 163, 74, 0.1); }
}

.st-ticket-item-subject {
    font-weight: 700;
    color: var(--st-dark);
    font-size: 14px;
    margin: 0 0 6px;
}

.st-ticket-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--st-gray);
}

.st-ticket-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.st-badge-open {
    background: var(--st-orange-light);
    color: var(--st-orange-dark);
}

.st-badge-waiting {
    background: #fef9c3;
    color: #a16207;
}

.st-badge-closed {
    background: var(--st-gray-light);
    color: var(--st-gray);
}

.st-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--st-gray);
    font-size: 14px;
}

.st-empty-state svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

/* === صفحه گفتگو === */
.st-conversation {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.st-conversation-header {
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.st-conversation-subject {
    font-weight: 700;
    color: var(--st-dark);
    font-size: 15px;
    margin: 0;
}

.st-conversation-back {
    background: var(--st-gray-light);
    color: var(--st-dark);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.st-conversation-back:hover {
    background: #e5e7eb;
}

.st-conversation-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 8px;
}

.st-conversation-messages::-webkit-scrollbar {
    width: 6px;
}
.st-conversation-messages::-webkit-scrollbar-thumb {
    background: var(--st-orange);
    border-radius: 10px;
}

.st-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.st-msg-user {
    align-self: flex-start;
}

.st-msg-admin {
    align-self: flex-end;
}

.st-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.6;
    word-wrap: break-word;
}

.st-msg-user .st-msg-bubble {
    background: var(--st-orange-light);
    color: var(--st-dark);
    border-bottom-right-radius: 4px;
}

.st-msg-admin .st-msg-bubble {
    background: var(--st-green);
    color: #fff;
    border-bottom-left-radius: 4px;
}

.st-msg-meta {
    font-size: 11px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.st-msg-user .st-msg-meta {
    color: var(--st-orange-dark);
}

.st-msg-admin .st-msg-meta {
    color: var(--st-green-dark);
    justify-content: flex-end;
}

.st-msg-time {
    opacity: 0.7;
    font-weight: 400;
}

.st-msg-tag {
    background: var(--st-green);
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.st-msg-closed-notice {
    text-align: center;
    background: var(--st-gray-light);
    color: var(--st-gray);
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    margin: 8px 0;
}

/* فوتر پاسخ */
.st-panel-footer {
    padding: 12px;
    border-top: 1px solid #f3f4f6;
    background: #fff;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.st-reply-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    background: #fff;
    color: var(--st-dark);
}

.st-reply-input:focus {
    outline: none;
    border-color: var(--st-orange);
}

.st-send-btn {
    background: linear-gradient(135deg, var(--st-orange) 0%, var(--st-orange-dark) 100%);
    color: #fff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    box-shadow: var(--st-shadow);
}

.st-send-btn:hover {
    transform: scale(1.05);
}

.st-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* اسپینر */
.st-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--st-orange-light);
    border-top-color: var(--st-orange);
    border-radius: 50%;
    animation: st-spin 0.8s linear infinite;
    margin: 20px auto;
}

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

/* ===================================================
   زبانه کناری برای موبایل - فقط در صفحه‌های کوچک فعال
   =================================================== */

/* === مخفی کردن زبانه موبایل در دسکتاپ === */
#st-mobile-tab {
    display: none !important;
}

/* === ریست کردن استایل‌های موبایل برای دسکتاپ === */
@media (min-width: 601px) {
    .st-widget {
        bottom: 24px !important;
        left: 24px !important;
        transform: none !important;
        transition: all 0.3s ease !important;
    }
}

/* === استایل‌های مخصوص موبایل (زیر 600 پیکسل) === */
@media (max-width: 600px) {
    /* نمایش زبانه فقط در موبایل */
    #st-mobile-tab {
        display: flex !important;
        position: absolute !important;
        right: -38px !important;
        bottom: 12px !important;
        width: 36px !important;
        height: 58px !important;
        background: linear-gradient(135deg, var(--st-orange) 0%, var(--st-orange-dark) 100%) !important;
        color: var(--st-white) !important;
        border: none !important;
        border-radius: 0 14px 14px 0 !important;
        cursor: pointer !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 4px 4px 15px rgba(249, 115, 22, 0.35) !important;
        z-index: 99998 !important;
        transition: all 0.25s ease !important;
        writing-mode: vertical-rl !important;
        text-orientation: mixed !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        letter-spacing: 1.5px !important;
        padding: 6px 0 !important;
        font-family: inherit !important;
        flex-direction: column !important;
        gap: 2px !important;
    }

    #st-mobile-tab:hover {
        width: 42px !important;
        background: linear-gradient(135deg, #fb923c 0%, var(--st-orange-dark) 100%) !important;
        box-shadow: 6px 6px 20px rgba(249, 115, 22, 0.45) !important;
    }

    /* آیکون فلش روی زبانه */
    #st-mobile-tab .st-tab-arrow {
        display: block !important;
        transition: transform 0.3s ease !important;
    }

    #st-widget.st-mobile-visible #st-mobile-tab .st-tab-arrow {
        transform: rotate(180deg) !important;
    }

    /* badge نوتیفیکیشن روی زبانه */
    #st-mobile-tab .st-tab-badge {
        position: absolute !important;
        top: 4px !important;
        left: 50% !important;
        transform: translateX(-50%) rotate(90deg) !important;
        background: #16a34a !important;
        color: #fff !important;
        border-radius: 50% !important;
        min-width: 18px !important;
        height: 18px !important;
        padding: 0 4px !important;
        font-size: 10px !important;
        font-weight: 700 !important;
        line-height: 18px !important;
        text-align: center !important;
        box-shadow: 0 2px 6px rgba(22, 163, 74, 0.5) !important;
        animation: st-badge-bounce 0.5s ease !important;
    }

    /* === موقعیت‌دهی ویجت اصلی در موبایل === */
    .st-widget {
        bottom: 0 !important;
        left: 0 !important;
        right: auto !important;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    /* هاید کردن ویجت در موبایل - به صورت پیش‌فرض خارج صفحه */
    .st-widget:not(.st-mobile-visible) {
        transform: translateX(-96%) !important;
    }

    .st-widget.st-mobile-visible {
        transform: translateX(0) !important;
    }

    /* === دکمه اصلی در موبایل === */
    .st-fab {
        padding: 12px 18px !important;
        font-size: 14px !important;
        border-radius: 40px !important;
    }

    /* === پنل در موبایل === */
    .st-panel {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 70px !important;
        height: calc(100vh - 90px) !important;
        max-height: calc(100vh - 90px) !important;
        border-radius: 16px 16px 0 0 !important;
    }

    /* مخفی کردن pulse انیمیشن در موبایل */
    .st-fab-pulse {
        display: none !important;
    }
}
