﻿/* ============================================================
   LAUNCHER
   ============================================================ */
#cc-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
    z-index: 999998;
    border: none;
}

/* ============================================================
   PANEL
   ============================================================ */
#cc-panel {
    position: fixed;
    right: 20px;
    bottom: 90px;
    width: 360px;
    height: 520px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 110px);
    max-height: calc(100dvh - 110px);
    background: #f1f5f9;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    font-family: Arial, Helvetica, sans-serif;
}

    #cc-panel.open {
        display: flex;
    }

    #cc-panel.cc-panel-fullscreen {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        height: auto;
        max-width: none;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }

.cc-hidden {
    display: none !important;
}

/* ============================================================
   HEADER
   ============================================================ */
.cc-header {
    background: #2563eb;
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cc-header-title {
    font-weight: 700;
    font-size: 15px;
}

.cc-close {
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    padding: 2px 6px;
}

/* ============================================================
   MESSAGES — agent KIRI (putih), visitor KANAN (biru)
   ============================================================ */
.cc-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px;
    scroll-padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f1f5f9;
}

.cc-msg {
    max-width: 80%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
    flex-shrink: 0;
}

.cc-msg-agent {
    align-self: flex-start;
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.cc-msg-visitor {
    align-self: flex-end;
    background: #2563eb;
    color: #ffffff;
}

.cc-msg-system {
    align-self: center;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 12px;
    text-align: center;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 90%;
}

.cc-msg-text {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Timestamp pesan */
.cc-msg-time {
    margin-top: 4px;
    font-size: 10px;
    opacity: 0.75;
    text-align: right;
    letter-spacing: .02em;
}

.cc-msg-visitor .cc-msg-time {
    color: inherit;
}

.cc-msg-agent .cc-msg-time {
    color: #6b7280;
}

/* Rich text di bubble widget */
.cc-msg-text strong {
    font-weight: 700;
}

.cc-msg-text em {
    font-style: italic;
}

.cc-msg-text u {
    text-decoration: underline;
}

.cc-msg-text s {
    text-decoration: line-through;
}

.cc-msg-text code {
    background: rgba(17, 24, 39, 0.08);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: Consolas, Menlo, monospace;
    font-size: 12px;
}

.cc-msg-visitor code {
    background: rgba(128, 128, 128, 0.25);
}

/* Link di pesan widget */
.cc-msg-text .chat-link {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

.cc-msg-visitor .chat-link {
    color: inherit;
}

.cc-msg-agent .chat-link {
    color: #2563eb;
}

/* ============================================================
   QUOTE / REPLY
   ============================================================ */
.cc-quote {
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    background: #f3f4f6;
    border-radius: 6px;
    padding: 4px 8px;
    margin-bottom: 6px;
    font-size: 12px;
    color: #374151;
}

.cc-msg-visitor .cc-quote {
    background: rgba(128, 128, 128, 0.18);
    border-color: currentColor;
    color: inherit;
}

.cc-quote strong {
    display: block;
    font-size: 10px;
    margin-bottom: 2px;
}

.cc-quote span {
    display: block;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 200px;
}

.cc-reply-btn {
    display: block;
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.6;
    font-size: 11px;
    cursor: pointer;
    margin-top: 4px;
    padding: 0;
}

    .cc-reply-btn:hover {
        opacity: 1;
    }

/* ============================================================
   ATTACHMENTS
   ============================================================ */
.cc-attachments-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.cc-attachment img, .cc-attachment video {
    max-width: 200px;
    max-height: 160px;
    border-radius: 8px;
    display: block;
}

.cc-attachment audio {
    width: 200px;
    display: block;
}

.cc-attachment a {
    font-size: 12px;
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

/* ============================================================
   INPUT AREA
   ============================================================ */
.cc-input-area {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
}

.cc-input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

    .cc-input:focus {
        border-color: #2563eb;
    }

.cc-input-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.cc-attach, .cc-mic {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: #f3f4f6;
    color: #374151;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

    .cc-mic.recording {
        background: #fee2e2;
        color: #dc2626;
    }

    .cc-mic.recorded {
        background: #fef3c7;
        color: #92400e;
    }

/* Ikon mic SVG */
.cc-mic-svg {
    display: block;
    width: 22px;
    height: 22px;
}

.cc-mic.recording .cc-mic-svg {
    animation: cc-mic-pulse 1s infinite;
}

@keyframes cc-mic-pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.35;
    }
}

.cc-send {
    margin-left: auto;
    flex: 0 0 auto;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: #2563eb;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    padding: 0 18px;
    cursor: pointer;
}

/* ============================================================
   REPLY BAR
   ============================================================ */
.cc-reply-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    width: 100%;
    box-sizing: border-box;
}

.cc-reply-content {
    flex: 1;
    min-width: 0;
}

    .cc-reply-content strong {
        display: block;
        font-size: 11px;
        color: #1d4ed8;
    }

    .cc-reply-content span {
        display: block;
        color: #374151;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }

.cc-reply-cancel {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

    .cc-reply-cancel:hover {
        color: #dc2626;
    }

/* ============================================================
   RECORDING / RECORDED INFO
   ============================================================ */
.cc-recording-info, .cc-recorded-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    font-size: 12px;
    color: #374151;
    box-sizing: border-box;
}

.cc-recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #dc2626;
    animation: cc-blink 1s infinite;
    flex-shrink: 0;
}

@keyframes cc-blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }
}

/* ============================================================
   DRAG & DROP + KOMPOSE
   ============================================================ */
.cc-drop {
    position: absolute;
    inset: 8px;
    z-index: 40;
    background: rgba(37, 99, 235, 0.12);
    border: 2px dashed #2563eb;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #1d4ed8;
    pointer-events: none;
}

.cc-compose {
    position: absolute;
    inset: 0;
    z-index: 45;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.cc-compose-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 14px;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cc-compose-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px;
    min-height: 56px;
}

    .cc-compose-preview img {
        width: 48px;
        height: 48px;
        object-fit: cover;
        border-radius: 8px;
        flex-shrink: 0;
    }

.cc-compose-icon {
    font-size: 24px;
}

.cc-compose-name {
    font-size: 12px;
    font-weight: 600;
    color: #111827;
    word-break: break-all;
}

.cc-compose-input {
    width: 100%;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.cc-compose-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.cc-compose-cancel, .cc-compose-send {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

.cc-compose-cancel {
    background: #6b7280;
}

.cc-compose-send {
    background: #2563eb;
}

/* ============================================================
   LIGHTBOX / FILE PREVIEW MODAL
   ============================================================ */
.lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    background: rgba(17, 24, 39, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lb-image {
    max-width: 92vw;
    max-height: 82vh;
    object-fit: contain;
    transition: transform 0.15s ease;
    user-select: none;
    -webkit-user-drag: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    background: #fff;
}

.lb-toolbar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: rgba(31, 41, 55, 0.9);
    padding: 8px 10px;
    border-radius: 10px;
    z-index: 10;
}

.lb-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

    .lb-btn:hover {
        background: rgba(255, 255, 255, 0.25);
    }

.lb-title {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(31, 41, 55, 0.8);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    max-width: 80vw;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    z-index: 10;
}

.fp-frame-wrap {
    width: 92vw;
    height: 86vh;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

    .fp-frame-wrap iframe {
        flex: 1;
        border: none;
        width: 100%;
    }

.fp-fallback {
    width: min(92vw, 420px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    gap: 16px;
}

    .fp-fallback .fp-icon {
        font-size: 64px;
    }

    .fp-fallback .fp-name {
        font-size: 16px;
        font-weight: 600;
        color: #111827;
        word-break: break-all;
        max-width: 80%;
    }

    .fp-fallback .fp-actions {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .fp-fallback button {
        padding: 10px 18px;
        border: none;
        border-radius: 8px;
        background: #2563eb;
        color: #fff;
        font-size: 14px;
        cursor: pointer;
    }

        .fp-fallback button.secondary {
            background: #6b7280;
        }

.fp-media {
    max-width: 92vw;
    max-height: 86vh;
    background: #000;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

    .fp-media video {
        max-width: 92vw;
        max-height: 86vh;
        border-radius: 12px;
        display: block;
    }

    .fp-media audio {
        width: min(92vw, 420px);
        display: block;
    }

/* ============================================================
   THEME CUSTOM WIDGET (CSS VARIABLES)
   ============================================================ */
#cc-launcher, .cc-header {
    background: var(--lcw-primary, #2563eb);
}

/* Bubble visitor: warna latar & teks independen dari primary */
.cc-msg-visitor {
    background: var(--lcw-visitor-bubble, var(--lcw-primary, #2563eb));
    color: var(--lcw-visitor-text, #ffffff);
}

.cc-send, .cc-compose-send {
    background: var(--lcw-button, var(--lcw-primary, #2563eb));
}

#cc-panel, .cc-messages {
    background: var(--lcw-bg, #f1f5f9);
}

.cc-msg-agent {
    background: var(--lcw-agent-bubble, #ffffff);
    color: var(--lcw-agent-text, #111827);
}

.cc-input-area {
    background: var(--lcw-agent-bubble, #ffffff);
}

.cc-input:focus {
    border-color: var(--lcw-primary, #2563eb);
}

/* ============================================================
   RESPONSIVE & FULLSCREEN
   ============================================================ */
@media (max-width: 480px) {
    #cc-panel {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        height: auto;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
}

/* ===== KARTU FILE + TOMBOL DOWNLOAD ===== */
.file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(128, 128, 128, 0.08);
    border: 1px solid rgba(128, 128, 128, 0.25);
    border-radius: 10px;
    padding: 8px 10px;
    max-width: 260px;
}

.file-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 12px;
    font-weight: 600;
    word-break: break-all;
}

.file-size {
    font-size: 11px;
    opacity: .7;
}

.file-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.file-download, .file-preview {
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 600;
}

.file-download {
    background: #2563eb;
    color: #fff;
}

.file-preview {
    background: rgba(128, 128, 128, 0.2);
    color: inherit;
}

/* Kontras tombol di bubble berwarna */
.cc-msg-visitor .file-download,
.message-item.agent .file-download {
    background: rgba(255, 255, 255, 0.92);
    color: #1e40af;
}

.h-attachment .file-card {
    max-width: 200px;
}

/* ===== HEADER DENGAN AVATAR AGENT ===== */
.cc-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,.25);
    flex-shrink: 0;
}

.cc-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 16px;
}

.cc-header-info {
    min-width: 0;
}

.cc-header-status {
    font-size: 12px;
    opacity: .95;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.cc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

    .cc-dot.off {
        background: #9ca3af;
    }

/* ===== META (NAMA + WAKTU) DI ATAS BUBBLE ===== */
.cc-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 80%;
}

    .cc-row.agent {
        align-self: flex-start;
        align-items: flex-start;
    }

    .cc-row.visitor {
        align-self: flex-end;
        align-items: flex-end;
    }

.cc-msg-meta {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 10px;
    color: #64748b;
    padding: 0 2px;
}

.cc-meta-name {
    font-weight: 700;
    color: #475569;
}

.cc-row .cc-msg {
    max-width: 100%;
}