/* =============================================
   Chat Panel - Slide-out Drawer Integration
   ============================================= */

.chat-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1080;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-panel-overlay.active {
    display: block;
    opacity: 1;
}

.chat-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    max-width: calc(100vw - 20px);
    height: 100vh;
    height: 100dvh;
    background: #fff;
    z-index: 1081;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.open {
    right: 0;
}

.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f8f9fc;
    border-bottom: 1px solid #edf0f5;
    flex-shrink: 0;
    min-height: 56px;
}

.chat-panel-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-panel-icon {
    font-size: 1.25rem;
    color: var(--primary-color, #2180f3);
}

.chat-panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
}

.chat-panel-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-panel-open-full {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: #8e8e93;
    text-decoration: none;
    font-size: 1.1rem;
    transition: background 0.15s, color 0.15s;
}

.chat-panel-open-full:hover {
    background: rgba(33, 128, 243, 0.08);
    color: var(--primary-color, #2180f3);
}

.chat-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #8e8e93;
    font-size: 1.3rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.chat-panel-close:hover {
    background: rgba(255, 59, 48, 0.08);
    color: #ff3b30;
}

.chat-panel-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.chat-panel-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Chat Icon with Badge */
.chat-icon-wrapper {
    position: fixed;
    bottom: 0.7rem;
    right: 6.625rem;
    z-index: 1086;
    cursor: pointer;
}

.chat-icon-btn {
    display: block;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    overflow: hidden;
    position: relative;
}

.chat-icon-btn:hover {
    transform: translateY(-5px);
}

.chat-icon-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #ff3b30;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.4);
    display: none;
    pointer-events: none;
}

.chat-unread-badge.show {
    display: block;
}

.chat-unread-badge.pulse {
    animation: badgePulse 0.4s ease;
}

@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ============================================
   DARK MODE
   ============================================ */
.dark .chat-panel {
    background: #1e1e1e;
}

.dark .chat-panel-header {
    background: #1a1a1a;
    border-color: #2a2a2a;
}

.dark .chat-panel-title {
    color: #e0e0e0;
}

.dark .chat-panel-open-full {
    color: #aaa;
}

.dark .chat-panel-open-full:hover {
    background: rgba(33, 128, 243, 0.12);
}

.dark .chat-panel-close {
    color: #aaa;
}

.dark .chat-panel-close:hover {
    background: rgba(255, 59, 48, 0.12);
}

.dark .chat-panel-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.dark .chat-icon-btn {
    background: #2a2a2a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .chat-panel {
        width: 100vw;
        max-width: 100vw;
        right: -100vw;
    }

    .chat-icon-wrapper {
        right: 70px;
        bottom: 12px;
    }

    .chat-icon-btn {
        width: 48px;
        height: 48px;
    }
}
