/* ============================================
   Chat.P.t.P - استایل کامل
   ============================================ */

/* استفاده از فونت قالب */
#ptp-chat-modal, #ptp-chat-floating, .ptp-notification, #ptp-chat-modal input, #ptp-chat-modal textarea, #ptp-chat-modal button {
    font-family: inherit !important;
}

/* ========== آیکون شناور ========== */
#ptp-chat-floating {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
    width: 56px !important;
    height: 56px !important;
    background: linear-gradient(145deg, #d4af37, #b8941f) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    z-index: 999998 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 15px rgba(212,175,55,0.5) !important;
    animation: ptp-rotate 10s ease-in-out infinite !important;
    transition: transform 0.3s, box-shadow 0.3s !important;
}

#ptp-chat-floating.ptp-left {
    right: auto !important;
    left: 20px !important;
}

#ptp-chat-floating img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

@keyframes ptp-rotate {
    0%, 100% { transform: perspective(500px) rotateY(0deg) scale(1); }
    15% { transform: perspective(500px) rotateY(360deg) scale(1.12); }
    30% { transform: perspective(500px) rotateY(360deg) scale(1); }
}

#ptp-chat-floating:hover {
    animation-play-state: paused;
    transform: perspective(500px) rotateY(8deg) scale(1.1) !important;
    box-shadow: 0 8px 25px rgba(212,175,55,0.7) !important;
}

/* ========== overlay ========== */
#ptp-chat-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.25);
    z-index: 999999;
}

#ptp-chat-modal-overlay.active {
    display: flex;
}

/* overlay راست - مودال پایین راست، چسبیده به آیکون */
#ptp-chat-modal-overlay.ptp-right {
    justify-content: flex-end;
    align-items: flex-end;
    padding: 0 20px 90px 0;
}

/* overlay چپ - مودال پایین چپ، چسبیده به آیکون */
#ptp-chat-modal-overlay.ptp-left {
    justify-content: flex-start;
    align-items: flex-end;
    padding: 0 0 90px 20px;
}

/* ========== مودال ========== */
#ptp-chat-modal {
    width: 370px;
    max-width: 92vw;
    height: 480px;
    max-height: 70vh;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== هدر ========== */
.ptp-modal-header {
    background: linear-gradient(135deg, #d4af37, #fff5e6);
    color: #800000;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 13px;
    border-bottom: 2px solid #800000;
    flex-shrink: 0;
}

.ptp-close {
    font-size: 20px;
    cursor: pointer;
    background: none;
    border: none;
    color: #800000;
    padding: 0 4px;
}

.ptp-close:hover {
    color: #ff0000;
}

/* ========== بخش‌های ورود ========== */
.ptp-auth-section {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.ptp-auth-section h4 {
    color: #800000;
    text-align: center;
    margin-bottom: 15px;
    font-size: 13px;
}

.ptp-form-group {
    margin-bottom: 10px;
}

.ptp-form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 13px;
    box-sizing: border-box;
}

.ptp-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

/* ========== بخش چت ========== */
.ptp-chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.ptp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    min-height: 0;
}

.ptp-msg {
    margin: 6px 0;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 80%;
    word-wrap: break-word;
    clear: both;
    font-size: 12px;
    line-height: 1.6;
}

.ptp-user {
    background: #e3f2fd;
    float: right;
    text-align: right;
    border-bottom-right-radius: 2px;
}

.ptp-agent {
    background: #f0f0f0;
    float: left;
    text-align: left;
    border-bottom-left-radius: 2px;
}

.ptp-system {
    text-align: center;
    color: #888;
    font-style: italic;
    clear: both;
    max-width: 100%;
}

.time {
    font-size: 9px;
    color: #aaa;
    margin-top: 3px;
    display: block;
}

/* ========== ناحیه ورودی ========== */
.ptp-input-area {
    border-top: 1px solid #ddd;
    padding: 8px 10px;
    display: flex;
    gap: 5px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}

.ptp-toolbar {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}

.ptp-tool-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 5px;
    transition: all 0.2s;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.ptp-tool-btn:hover {
    background: #f0f0f0;
    color: #800000;
}

.ptp-text-input {
    flex: 1;
    resize: none;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    min-height: 38px;
    height: 38px;
    max-height: 80px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.ptp-text-input:focus {
    border-color: #800000;
    box-shadow: 0 0 0 2px rgba(128, 0, 0, 0.1);
}

.ptp-send-btn {
    background: #800000;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 16px;
    height: 38px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.ptp-send-btn:hover {
    background: #a00020;
}

/* ========== دکمه‌های عمومی ========== */
.ptp-btn {
    background: #800000;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.ptp-btn:hover {
    background: #a00020;
}

.ptp-btn-special {
    background: linear-gradient(135deg, #d4af37, #b8941f);
    color: #000;
    font-weight: bold;
}

.ptp-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== نوتیفیکیشن ========== */
.ptp-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-right: 4px solid #d4af37;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000000;
    font-size: 12px;
    animation: notifyIn 0.3s ease;
}

.ptp-notification.success { border-color: #27ae60; color: #155724; }
.ptp-notification.error { border-color: #c0392b; color: #721c24; }

@keyframes notifyIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-15px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== ریسپانسیو ========== */
@media (max-width: 480px) {
    #ptp-chat-modal {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    #ptp-chat-modal-overlay.ptp-right,
    #ptp-chat-modal-overlay.ptp-left {
        padding: 0 !important;
    }
}

/* ========== مودال تماس ========== */
#ptp-call-modal {
    font-family: inherit;
}
#ptp-remote-video {
    background: #000;
}
#ptp-local-video {
    z-index: 10;
}
.ptp-call-btn.off {
    background: rgba(255,255,255,0.05);
}
.ptp-call-btn.off svg {
    opacity: 0.4;
}

/* موقعیت مودال تماس صوتی پایین راست */
#ptp-voice-call-modal {
    bottom: 90px !important;
    right: 20px !important;
    left: auto !important;
}