/**
 * Luna Chatbot - Public Styles
 * 
 * نسخه ساده و بدون تداخل
 *
 * @package LunaChatbot
 * @version 1.0.0
 */

/* ============================================================
   متغیرها
   ============================================================ */
:root {
    --luna-primary: #1e88e5;
    --luna-primary-dark: #1976d2;
    --luna-white: #ffffff;
    --luna-gray-50: #f8f9fa;
    --luna-gray-200: #e9ecef;
    --luna-text-primary: #333;
    --luna-text-muted: #999;
    --luna-radius-lg: 20px;
    --luna-radius-pill: 50px;
    --luna-font: Tahoma, Arial, sans-serif;
}

/* ============================================================
   دکمه شناور - موقعیت اصلی
   ============================================================ */
.luna-main-wrap {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2147483647;
    direction: rtl;
    font-family: var(--luna-font);
    line-height: 1.5;
    pointer-events: none;
}

.luna-main-wrap *,
.luna-main-wrap *::before,
.luna-main-wrap *::after {
    box-sizing: border-box;
    pointer-events: auto;
}

/* ============================================================
   دکمه اصلی
   ============================================================ */
.luna-main-wrap .luna-btn {
    background: linear-gradient(135deg, var(--luna-primary) 0%, var(--luna-primary-dark) 100%);
    color: var(--luna-white);
    border: none;
    border-radius: var(--luna-radius-pill);
    padding: 10px 25px 10px 18px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 10px 35px rgba(30, 136, 229, 0.5);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    outline: none;
    font-family: inherit;
    min-width: 360px;
    max-width: 450px;
    direction: ltr;
    position: relative;
    line-height: 1.4;
}

.luna-main-wrap .luna-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 45px rgba(30, 136, 229, 0.7);
}

/* آیکون */
.luna-main-wrap .luna-btn .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    min-width: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    overflow: hidden;
    flex-shrink: 0;
    font-size: 28px;
    order: -1;
}

.luna-main-wrap .luna-btn .icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* متن */
.luna-main-wrap .luna-btn .title {
    flex: 1;
    direction: rtl;
    text-align: right;
    line-height: 1.4;
    min-width: 0;
}

.luna-main-wrap .luna-btn .title > span:first-child {
    display: block;
    font-weight: 700;
    font-size: 15px;
    color: var(--luna-white);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.luna-main-wrap .luna-btn .sub {
    font-size: 12px;
    opacity: 0.9;
    display: block;
    font-weight: 400;
    color: #bbdefb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   پنجره چت
   ============================================================ */
.luna-main-wrap .luna-box {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 130px);
    background: var(--luna-white);
    border-radius: var(--luna-radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    flex-direction: column;
    direction: rtl;
    font-family: var(--luna-font);
    z-index: 2147483647;
}

.luna-main-wrap .luna-box.active {
    display: flex;
    animation: lunaSlideUp 0.3s ease;
}

/* هدر */
.luna-main-wrap .luna-box .header {
    background: linear-gradient(135deg, var(--luna-primary) 0%, var(--luna-primary-dark) 100%);
    color: var(--luna-white);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 65px;
    border-radius: var(--luna-radius-lg) var(--luna-radius-lg) 0 0;
}

.luna-main-wrap .luna-box .header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.luna-main-wrap .luna-box .header-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.luna-main-wrap .luna-box .header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.luna-main-wrap .luna-box .header-name {
    font-weight: 700;
    font-size: 15px;
    display: block;
    color: var(--luna-white);
}

.luna-main-wrap .luna-box .header-status {
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--luna-white);
}

.luna-main-wrap .luna-box .header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4cd964;
    display: inline-block;
    animation: lunaBlink 2s infinite;
}

.luna-main-wrap .luna-box .header-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.luna-main-wrap .luna-box .header-btn {
    background: rgba(255, 255, 255, 0.2);
    color: var(--luna-white);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
    font-family: inherit;
    padding: 0;
}

.luna-main-wrap .luna-box .header-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.luna-main-wrap .luna-box .header-btn.close:hover {
    background: #dc3545;
    transform: rotate(90deg);
}

/* پیام‌ها */
.luna-main-wrap .luna-box .msgs {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: var(--luna-gray-50);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.luna-main-wrap .luna-box .msgs::-webkit-scrollbar {
    width: 6px;
}

.luna-main-wrap .luna-box .msgs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.luna-main-wrap .luna-box .msg {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 88%;
    font-size: 13px;
    line-height: 1.8;
    word-wrap: break-word;
    white-space: pre-line;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    animation: lunaFadeIn 0.3s ease;
}

.luna-main-wrap .luna-box .msg .msg-content {
    flex: 1;
}

.luna-main-wrap .luna-box .msg.user {
    background: linear-gradient(135deg, var(--luna-primary) 0%, var(--luna-primary-dark) 100%);
    color: var(--luna-white);
    align-self: flex-end;
    border-radius: 15px 15px 4px 15px;
    margin-left: 30px;
}

.luna-main-wrap .luna-box .msg.bot {
    background: var(--luna-white);
    color: var(--luna-text-primary);
    align-self: flex-start;
    border-radius: 15px 15px 15px 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-right: 30px;
    border-right: 3px solid var(--luna-primary);
}

.luna-main-wrap .luna-box .msg .speak-btn {
    cursor: pointer;
    font-size: 20px;
    color: var(--luna-primary);
    font-weight: bold;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    user-select: none;
    padding: 2px;
}

.luna-main-wrap .luna-box .msg .speak-btn:hover {
    transform: scale(1.2);
}

/* نشانگر تایپ */
.luna-main-wrap .luna-box .luna-typing {
    padding: 10px 20px;
    display: flex;
    gap: 5px;
    align-items: center;
    background: var(--luna-gray-50);
    border-top: 1px solid var(--luna-gray-200);
}

.luna-main-wrap .luna-box .luna-typing span {
    width: 8px;
    height: 8px;
    background: var(--luna-primary);
    border-radius: 50%;
    display: inline-block;
    animation: lunaTypingBounce 1.4s infinite ease-in-out;
}

.luna-main-wrap .luna-box .luna-typing span:nth-child(1) { animation-delay: 0s; }
.luna-main-wrap .luna-box .luna-typing span:nth-child(2) { animation-delay: 0.2s; }
.luna-main-wrap .luna-box .luna-typing span:nth-child(3) { animation-delay: 0.4s; }

/* ورودی */
.luna-main-wrap .luna-box .input-area {
    padding: 12px 15px;
    border-top: 1px solid var(--luna-gray-200);
    display: flex;
    gap: 8px;
    background: var(--luna-white);
    align-items: center;
}

.luna-main-wrap .luna-box .input-area input {
    flex: 1;
    padding: 11px 16px;
    border: 2px solid var(--luna-gray-200);
    border-radius: 25px;
    outline: none;
    font-size: 13px;
    font-family: var(--luna-font);
    background: var(--luna-gray-50);
    color: var(--luna-text-primary);
    min-width: 0;
}

.luna-main-wrap .luna-box .input-area input:focus {
    border-color: var(--luna-primary);
    background: var(--luna-white);
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
}

.luna-main-wrap .luna-box .input-area input::placeholder {
    color: var(--luna-text-muted);
}

.luna-main-wrap .luna-box .input-area button {
    background: var(--luna-primary);
    color: var(--luna-white);
    border: none;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
    flex-shrink: 0;
    font-family: inherit;
    padding: 0;
}

.luna-main-wrap .luna-box .input-area button:hover:not(:disabled) {
    background: var(--luna-primary-dark);
    transform: scale(1.08);
}

.luna-main-wrap .luna-box .input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.luna-main-wrap .luna-box .input-area button.mic-btn {
    background: #28a745;
}

.luna-main-wrap .luna-box .input-area button.mic-btn:hover:not(.recording) {
    background: #218838;
}

.luna-main-wrap .luna-box .input-area button.mic-btn.recording {
    background: #dc3545;
    animation: lunaPulse 1s infinite;
}

/* فوتر */
.luna-main-wrap .luna-box .luna-footer {
    padding: 6px 15px;
    background: #f0f0f1;
    text-align: center;
    font-size: 10px;
    color: var(--luna-text-muted);
    border-top: 1px solid var(--luna-gray-200);
}

/* ============================================================
   انیمیشن‌ها
   ============================================================ */
@keyframes lunaSlideUp {
    from { opacity: 0; transform: translate(-50%, 30px) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes lunaFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes lunaPulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

@keyframes lunaTypingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes lunaBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================================
   واکنش‌گرایی
   ============================================================ */
@media (max-width: 480px) {
    .luna-main-wrap {
        bottom: 15px;
        left: 10px;
        right: 10px;
        transform: none;
    }
    
    .luna-main-wrap .luna-btn {
        width: 100%;
        min-width: auto;
        padding: 10px 15px;
        gap: 12px;
    }
    
    .luna-main-wrap .luna-btn .icon {
        width: 42px;
        height: 42px;
        min-width: 42px;
        font-size: 22px;
    }
    
    .luna-main-wrap .luna-btn .title > span:first-child {
        font-size: 13px;
    }
    
    .luna-main-wrap .luna-btn .sub {
        font-size: 10px;
    }
    
    .luna-main-wrap .luna-box {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 120px) !important;
        max-height: calc(100vh - 120px) !important;
        bottom: 80px !important;
        left: 10px !important;
        right: 10px !important;
        transform: none !important;
    }
}

@media (max-width: 360px) {
    .luna-main-wrap .luna-btn .sub {
        display: none;
    }
}

/* ============================================================
   پنهان در ویرایشگر Elementor
   ============================================================ */
.elementor-editor-active .luna-main-wrap {
    display: none !important;
}