/* ==========================================================================
   Paikar AI Secretary - Frontend Chat Widget Styles (RTL)
   ========================================================================== */

.paikar-widget-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    direction: rtl;
    text-align: right;
    box-sizing: border-box;
}

.paikar-widget-wrapper * {
    box-sizing: border-box;
}

/* 1. Toggle Button */
.paikar-toggle-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e1e2d 0%, #151521 100%);
    color: #ffffff;
    border: 2px solid #e92026;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(233, 32, 38, 0.35);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    padding: 0;
    outline: none;
}

.paikar-toggle-button:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 28px rgba(233, 32, 38, 0.45);
}

.paikar-pulsing-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: paikar-pulse 2s infinite;
}

@keyframes paikar-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* 2. Chat Window */
.paikar-chat-window {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 380px;
    height: 590px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.paikar-chat-window.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.85) translateY(20px);
    pointer-events: none;
}

/* Header */
.paikar-chat-header {
    background: #1e1e2d;
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e92026;
}

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

.paikar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #2a2a3c;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
    border: 1px solid #e92026;
}

.paikar-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #1e1e2d;
    border-radius: 50%;
}

.paikar-title-group h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
}

.paikar-status-text {
    font-size: 11px;
    color: #94a3b8;
    display: block;
}

.paikar-header-controls {
    display: flex;
    gap: 6px;
}

.paikar-icon-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.paikar-icon-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* Messages Body */
.paikar-messages-body {
    flex: 1;
    background: #f8fafc;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.paikar-msg-item {
    display: flex;
    width: 100%;
}

.paikar-msg-user {
    justify-content: flex-start; /* در RTL به سمت راست می‌چسبد */
}

.paikar-msg-assistant {
    justify-content: flex-end; /* در RTL به سمت چپ می‌چسبد */
}

.paikar-bubble {
    max-width: 85%;
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.65;
    word-break: break-word;
}

.paikar-msg-user .paikar-bubble {
    background: #e92026;
    color: #ffffff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 8px rgba(233, 32, 38, 0.2);
}

.paikar-msg-assistant .paikar-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.paikar-bubble p {
    margin: 0 0 8px 0;
}
.paikar-bubble p:last-child {
    margin-bottom: 0;
}
.paikar-bubble ul, .paikar-bubble ol {
    margin: 6px 0;
    padding-right: 18px;
}
.paikar-bubble li {
    margin-bottom: 4px;
}
.paikar-bubble strong {
    font-weight: 700;
}
.paikar-bubble a {
    color: #e92026;
    text-decoration: underline;
}
.paikar-msg-user .paikar-bubble a {
    color: #ffffff;
}

/* Quick Action Chips */
.paikar-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.paikar-chip {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 11.5px;
    padding: 6px 11px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.paikar-chip:hover {
    border-color: #e92026;
    color: #e92026;
    background: #fff5f5;
    transform: translateY(-1px);
}

/* Typing Indicator */
.paikar-typing-indicator {
    padding: 6px 16px;
    background: #f1f5f9;
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
}

.paikar-dots {
    display: flex;
    gap: 4px;
}

.paikar-dots span {
    width: 6px;
    height: 6px;
    background: #e92026;
    border-radius: 50%;
    animation: paikar-dot-bounce 1.4s infinite ease-in-out both;
}

.paikar-dots span:nth-child(1) { animation-delay: -0.32s; }
.paikar-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes paikar-dot-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Footer & Input */
.paikar-chat-footer {
    padding: 10px 14px 8px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.paikar-form-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    transition: border-color 0.2s;
}

.paikar-form-inner:focus-within {
    border-color: #e92026;
    background: #ffffff;
}

.paikar-form-inner textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 13px;
    color: #1e293b;
    outline: none;
    max-height: 80px;
    padding: 6px 0;
    line-height: 1.4;
}

.paikar-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #e92026;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    transform: rotate(180deg); /* چرخش جهت فلش در زبان فارسی RTL */
}

.paikar-send-btn:hover {
    background: #c5161b;
}

.paikar-footer-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 11px;
}

.paikar-link-btn {
    background: transparent;
    border: none;
    color: #0284c7;
    cursor: pointer;
    padding: 0;
    font-size: 11px;
    font-family: inherit;
}
.paikar-link-btn:hover {
    text-decoration: underline;
}

.paikar-copyright {
    color: #94a3b8;
    font-size: 10px;
}

/* Inner Escalation Modal */
.paikar-inner-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 10;
}

.paikar-inner-modal-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    width: 100%;
}

.paikar-inner-modal-box h5 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: #1e293b;
}

.paikar-inner-modal-box p {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.paikar-input-text {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12.5px;
    box-sizing: border-box;
}

.paikar-modal-btns {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.paikar-btn-primary {
    flex: 1;
    background: #e92026;
    color: #ffffff;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: bold;
}

.paikar-btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12.5px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .paikar-widget-wrapper {
        bottom: 16px;
        right: 16px;
    }
    .paikar-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
