/* ============================================================
   assets/support-chat.css
   Chat ke Tim Support — desain neumorphism premium, konsisten
   dengan design tokens di includes/style.php (var(--ink), --lime,
   --surface, --shadow, dst). Dipakai di /support & /admin/support-chat.
   ============================================================ */

.sc-shell{
    display:grid; grid-template-columns:280px 1fr; gap:14px;
    height:calc(100vh - 150px); min-height:520px; max-width:1180px; margin:0 auto;
}
.sc-shell.sc-shell-3col{ grid-template-columns:270px 1fr 260px; }
.sc-panel{
    background:var(--glass-bg); border:1px solid var(--glass-border); border-radius:var(--radius);
    box-shadow:var(--shadow); backdrop-filter:blur(var(--glass-blur)) saturate(150%); -webkit-backdrop-filter:blur(var(--glass-blur)) saturate(150%);
    display:flex; flex-direction:column; min-height:0; min-width:0; overflow:hidden;
}

/* ============ SIDEBAR (list percakapan admin) ============ */
.sc-side-top{ padding:14px; border-bottom:1px solid var(--glass-border); }
.sc-side-brand{ display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.sc-side-brand .sc-avatar{ width:38px; height:38px; }
.sc-side-brand-name{ font-weight:800; font-size:13.5px; line-height:1.25; }
.sc-side-brand-status{ font-size:10.5px; color:var(--ink-soft); display:flex; align-items:center; gap:5px; }
.sc-search{ position:relative; }
.sc-search input{
    width:100%; padding:9px 12px 9px 34px; border-radius:var(--radius-sm); border:none;
    background:var(--surface); box-shadow:var(--shadow-inset-sm); font-size:12px; color:var(--ink);
}
.sc-search svg{ position:absolute; left:11px; top:50%; transform:translateY(-50%); width:14px; height:14px; color:var(--ink-soft); }
.sc-filter-tabs{ display:flex; gap:5px; padding:10px 14px; overflow-x:auto; border-bottom:1px solid var(--glass-border); flex-shrink:0; }
.sc-filter-tab{
    flex-shrink:0; padding:6px 11px; border-radius:20px; font-size:10.5px; font-weight:700; white-space:nowrap;
    background:var(--surface); box-shadow:var(--shadow-sm); color:var(--ink-soft); cursor:pointer; border:none; transition:.2s var(--ease);
}
.sc-filter-tab.active{ background:var(--ink); color:#fff; box-shadow:none; }
.sc-conv-list{ flex:1; overflow-y:auto; padding:6px; }
.sc-conv-item{
    display:flex; gap:10px; align-items:flex-start; padding:10px; border-radius:12px; cursor:pointer;
    transition:background .2s var(--ease); margin-bottom:2px; position:relative;
}
.sc-conv-item:hover{ background:var(--surface); }
.sc-conv-item.active{ background:var(--surface); box-shadow:var(--shadow-inset-sm); }
.sc-conv-item .sc-avatar{ width:38px; height:38px; flex-shrink:0; }
.sc-conv-item-body{ min-width:0; flex:1; }
.sc-conv-item-top{ display:flex; justify-content:space-between; align-items:baseline; gap:6px; }
.sc-conv-item-name{ font-size:12.5px; font-weight:800; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sc-conv-item-time{ font-size:9.5px; color:var(--ink-soft); flex-shrink:0; }
.sc-conv-item-preview{ font-size:11px; color:var(--ink-soft); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-top:1px; }
.sc-conv-item.unread .sc-conv-item-preview{ color:var(--ink); font-weight:700; }
.sc-conv-badge{
    background:var(--danger); color:#fff; font-size:9.5px; font-weight:800; border-radius:20px;
    min-width:16px; height:16px; padding:0 4px; display:flex; align-items:center; justify-content:center; margin-left:auto;
}
.sc-conv-item-tags{ display:flex; gap:4px; margin-top:4px; }
.sc-conv-status-pill{ font-size:8.5px; font-weight:800; text-transform:uppercase; padding:1px 6px; border-radius:8px; letter-spacing:.03em; }
.sc-conv-status-open{ background:var(--lime-soft); color:var(--lime); }
.sc-conv-status-handled{ background:#FEF3C7; color:#B45309; }
.sc-conv-status-closed{ background:var(--grey); color:var(--ink-soft); }
.sc-empty-list{ text-align:center; padding:40px 16px; color:var(--ink-soft); font-size:12px; }

/* ============ MAIN CHAT AREA ============ */
.sc-chat-col{ display:flex; flex-direction:column; min-width:0; }
.sc-chat-header{
    display:flex; align-items:center; justify-content:space-between; gap:10px;
    padding:12px 16px; border-bottom:1px solid var(--glass-border); flex-shrink:0;
}
.sc-chat-header-left{ display:flex; align-items:center; gap:10px; min-width:0; }
.sc-chat-header-left .sc-back{ display:none; }
.sc-chat-header-name{ font-size:13.5px; font-weight:800; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sc-chat-header-status{ font-size:10.5px; color:var(--ink-soft); display:flex; align-items:center; gap:5px; }
.sc-avatar{
    width:40px; height:40px; border-radius:50%; object-fit:cover; flex-shrink:0;
    box-shadow:var(--shadow-sm); background:var(--surface); display:flex; align-items:center; justify-content:center;
}
.sc-avatar-fallback{ color:var(--lime); }
.sc-avatar-fallback svg{ width:18px; height:18px; }
.sc-status-dot{ width:8px; height:8px; border-radius:50%; background:#9CA3AF; display:inline-block; flex-shrink:0; }
.sc-status-dot.online{ background:#22C55E; box-shadow:0 0 0 3px rgba(34,197,94,.18); }
.sc-status-dot.offline{ background:#9CA3AF; }
.sc-status-dot.maintenance{ background:#F59E0B; }
.sc-chat-header-actions{ display:flex; gap:6px; }

.sc-messages{ flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:2px; position:relative; min-width:0; }
.sc-date-sep{ text-align:center; margin:14px 0 10px; }
.sc-date-sep span{
    background:var(--surface); box-shadow:var(--shadow-sm); padding:4px 12px; border-radius:20px;
    font-size:10px; font-weight:700; color:var(--ink-soft);
}
.sc-system-msg{
    text-align:center; font-size:11px; color:var(--ink-soft); background:var(--surface); box-shadow:var(--shadow-inset-sm);
    padding:8px 14px; border-radius:12px; margin:8px auto; max-width:80%;
}
.sc-system-time{ display:block; font-size:9px; margin-top:2px; opacity:.7; }

.sc-msg{ display:flex; gap:8px; margin:5px 0; max-width:78%; align-items:flex-end; }
.sc-msg-mine{ margin-left:auto; flex-direction:row-reverse; }
.sc-msg-theirs{ margin-right:auto; }
.sc-bubble-wrap{ display:flex; flex-direction:column; min-width:0; }
.sc-msg-mine .sc-bubble-wrap{ align-items:flex-end; }
.sc-sender{ font-size:10px; font-weight:800; color:var(--lime); margin-bottom:2px; padding-left:2px; }
.sc-bubble{
    padding:9px 13px; border-radius:16px; font-size:13px; line-height:1.5; word-break:break-word; box-shadow:var(--shadow-sm);
}
.sc-msg-mine .sc-bubble{ background:var(--lime); color:#fff; border-bottom-right-radius:4px; }
.sc-msg-theirs .sc-bubble{ background:var(--surface); color:var(--ink); border-bottom-left-radius:4px; }
.sc-bubble-deleted{ font-style:italic; color:var(--ink-soft); display:flex; align-items:center; gap:6px; background:var(--surface); }
.sc-bubble-deleted svg{ width:13px; height:13px; }
.sc-text{ white-space:pre-wrap; }
.sc-meta{ display:flex; align-items:center; gap:3px; font-size:9.5px; color:var(--ink-soft); margin-top:3px; padding:0 3px; }
.sc-tick{ width:12px; height:12px; }
.sc-tick-sent{ opacity:.6; }
.sc-tick-read{ color:var(--lime); }

.sc-attach-img{ display:block; margin-bottom:4px; border-radius:12px; overflow:hidden; max-width:220px; }
.sc-attach-img img{ display:block; width:100%; height:auto; max-height:260px; object-fit:cover; }
.sc-attach-file{
    display:flex; align-items:center; gap:8px; background:rgba(255,255,255,.5); border-radius:12px; padding:8px 10px;
    margin-bottom:4px; text-decoration:none; color:inherit; min-width:180px;
}
.sc-msg-mine .sc-attach-file{ background:rgba(255,255,255,.22); }
.sc-attach-file svg:first-child{ width:20px; height:20px; flex-shrink:0; }
.sc-attach-file-info{ display:flex; flex-direction:column; min-width:0; flex:1; }
.sc-attach-file-info b{ font-size:11.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sc-attach-file-info small{ font-size:9.5px; opacity:.75; }
.sc-attach-file svg:last-child{ width:14px; height:14px; flex-shrink:0; opacity:.7; }

.sc-typing-indicator{ display:flex; align-items:center; gap:6px; padding:6px 14px; font-size:11px; color:var(--ink-soft); flex-shrink:0; }
.sc-typing-dots{ display:inline-flex; gap:3px; }
.sc-typing-dots span{ width:5px; height:5px; border-radius:50%; background:var(--ink-soft); animation:sc-bounce 1.2s infinite ease-in-out; }
.sc-typing-dots span:nth-child(2){ animation-delay:.15s; }
.sc-typing-dots span:nth-child(3){ animation-delay:.3s; }
@keyframes sc-bounce{ 0%,60%,100%{ transform:translateY(0); opacity:.5; } 30%{ transform:translateY(-3px); opacity:1; } }

.sc-jump-latest{
    position:absolute; bottom:14px; right:14px; background:var(--ink); color:#fff; border:none; border-radius:20px;
    padding:7px 13px; font-size:11px; font-weight:700; display:flex; align-items:center; gap:5px; box-shadow:var(--shadow);
    cursor:pointer; opacity:0; pointer-events:none; transform:translateY(6px); transition:.2s var(--ease);
}
.sc-jump-latest.show{ opacity:1; pointer-events:auto; transform:translateY(0); }
.sc-jump-latest svg{ width:13px; height:13px; }

.sc-empty-state{ margin:auto; text-align:center; color:var(--ink-soft); padding:30px; }
.sc-empty-state svg{ width:44px; height:44px; margin-bottom:10px; opacity:.5; }
.sc-empty-state p{ font-size:12.5px; max-width:260px; margin:0 auto; }

/* ============ COMPOSER ============ */
.sc-composer{ border-top:1px solid var(--glass-border); padding:10px 14px; flex-shrink:0; position:relative; }
.sc-attach-preview-row{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
.sc-attach-preview{
    position:relative; width:64px; height:64px; border-radius:10px; overflow:hidden; box-shadow:var(--shadow-sm);
    background:var(--surface); display:flex; align-items:center; justify-content:center;
}
.sc-attach-preview img{ width:100%; height:100%; object-fit:cover; }
.sc-attach-preview .sc-attach-preview-file{ display:flex; flex-direction:column; align-items:center; gap:2px; font-size:8px; color:var(--ink-soft); padding:4px; text-align:center; }
.sc-attach-preview .sc-attach-preview-file svg{ width:18px; height:18px; }
.sc-attach-remove{
    position:absolute; top:2px; right:2px; width:16px; height:16px; border-radius:50%; background:rgba(0,0,0,.55);
    color:#fff; border:none; display:flex; align-items:center; justify-content:center; cursor:pointer; padding:0;
}
.sc-attach-remove svg{ width:10px; height:10px; }
.sc-composer-row{ display:flex; align-items:flex-end; gap:6px; }
.sc-composer-btn{
    width:38px; height:38px; border-radius:50%; border:none; background:var(--surface); box-shadow:var(--shadow-sm);
    display:flex; align-items:center; justify-content:center; color:var(--ink-soft); cursor:pointer; flex-shrink:0; transition:.2s var(--ease);
}
.sc-composer-btn:hover{ color:var(--lime); box-shadow:var(--shadow); }
.sc-composer-btn svg{ width:17px; height:17px; }
.sc-composer-input-wrap{ flex:1; background:var(--surface); box-shadow:var(--shadow-inset-sm); border-radius:20px; padding:4px 6px 4px 16px; display:flex; align-items:center; }
.sc-composer-input{
    flex:1; border:none; background:transparent; resize:none; font-size:13px; font-family:var(--font-body); color:var(--ink);
    max-height:110px; padding:8px 0; line-height:1.4;
}
.sc-composer-input:focus{ outline:none; }
.sc-send-btn{
    width:38px; height:38px; border-radius:50%; border:none; background:var(--lime); color:#fff; flex-shrink:0;
    display:flex; align-items:center; justify-content:center; cursor:pointer; box-shadow:var(--shadow-sm); transition:.2s var(--ease);
}
.sc-send-btn svg{ width:16px; height:16px; margin-left:-1px; }
.sc-send-btn:disabled{ opacity:.4; cursor:not-allowed; }
.sc-send-btn:not(:disabled):hover{ transform:scale(1.06); }
.sc-composer-hint{ font-size:9.5px; color:var(--ink-soft); text-align:center; margin-top:6px; }
.sc-dropzone-active{ outline:2px dashed var(--lime); outline-offset:-8px; background:var(--lime-soft); }
.sc-msg-retry{ font-size:9.5px; color:var(--danger); font-weight:700; cursor:pointer; margin-top:2px; text-decoration:underline; }
.sc-msg-sending{ opacity:.55; }

/* ============ EMOJI PICKER ============ */
.sc-emoji-pop{
    position:absolute; bottom:56px; left:0; background:var(--surface); border-radius:14px; box-shadow:var(--shadow-lg);
    padding:10px; display:none; grid-template-columns:repeat(7, 1fr); gap:4px; z-index:40; width:270px;
}
.sc-emoji-pop.open{ display:grid; }
.sc-emoji-pop button{ border:none; background:transparent; font-size:19px; padding:5px; border-radius:8px; cursor:pointer; line-height:1; }
.sc-emoji-pop button:hover{ background:var(--grey); }

/* ============ INFO PANEL (admin, kanan) ============ */
.sc-info-panel{ padding:16px; overflow-y:auto; }
.sc-info-panel h4{ font-size:11px; text-transform:uppercase; color:var(--ink-soft); letter-spacing:.04em; margin:14px 0 8px; }
.sc-info-panel h4:first-child{ margin-top:0; }
.sc-info-row{ display:flex; justify-content:space-between; gap:8px; font-size:12px; padding:6px 0; border-bottom:1px solid var(--grey); }
.sc-info-row span:first-child{ color:var(--ink-soft); }
.sc-info-row span:last-child{ font-weight:700; text-align:right; }
.sc-info-profile{ text-align:center; padding-bottom:6px; }
.sc-info-profile .sc-avatar{ width:64px; height:64px; margin:0 auto 8px; }
.sc-info-profile-name{ font-weight:800; font-size:14px; }
.sc-templates-list{ display:flex; flex-direction:column; gap:6px; }
.sc-template-item{
    text-align:left; background:var(--surface); border:none; box-shadow:var(--shadow-sm); border-radius:10px; padding:8px 10px;
    font-size:11px; cursor:pointer; color:var(--ink); transition:.2s var(--ease);
}
.sc-template-item:hover{ box-shadow:var(--shadow); color:var(--lime); }

/* ============ Loading skeleton ============ */
.sc-skeleton{ display:flex; flex-direction:column; gap:12px; padding:16px; }
.sc-skel-row{ display:flex; gap:8px; align-items:flex-end; }
.sc-skel-row.right{ flex-direction:row-reverse; }
.sc-skel-bubble{ height:34px; border-radius:16px; background:linear-gradient(90deg, var(--grey) 25%, var(--grey-dark) 50%, var(--grey) 75%); background-size:200% 100%; animation:sc-shimmer 1.4s infinite; }
@keyframes sc-shimmer{ 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }

/* ============ Lightbox ============ */
.sc-lightbox-overlay{
    position:fixed; inset:0; background:rgba(10,10,10,.88); z-index:500; display:none;
    align-items:center; justify-content:center; padding:24px;
}
.sc-lightbox-overlay.open{ display:flex; }
.sc-lightbox-overlay img{ max-width:92vw; max-height:88vh; border-radius:8px; box-shadow:0 20px 60px rgba(0,0,0,.5); cursor:zoom-in; transition:transform .25s var(--ease); }
.sc-lightbox-overlay img.zoomed{ cursor:zoom-out; transform:scale(1.7); }
.sc-lightbox-close, .sc-lightbox-download{
    position:absolute; top:18px; width:38px; height:38px; border-radius:50%; background:rgba(255,255,255,.12); color:#fff;
    display:flex; align-items:center; justify-content:center; border:none; cursor:pointer;
}
.sc-lightbox-close{ right:18px; }
.sc-lightbox-download{ right:66px; text-decoration:none; }
.sc-lightbox-close svg, .sc-lightbox-download svg{ width:17px; height:17px; }

/* ============ Landing (belum login) ============ */
.sc-landing{ max-width:760px; margin:0 auto; text-align:center; padding:30px 16px 10px; }
.sc-landing .sc-avatar{ width:76px; height:76px; margin:0 auto 14px; }
.sc-landing-grid{ display:grid; grid-template-columns:repeat(3, 1fr); gap:12px; margin:26px 0; text-align:left; }
.sc-landing-card{ background:var(--glass-bg); border:1px solid var(--glass-border); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow); }
.sc-landing-card svg{ width:22px; height:22px; color:var(--lime); margin-bottom:8px; }
.sc-landing-card h3{ font-size:13px; margin-bottom:4px; }
.sc-landing-card p{ font-size:11.5px; color:var(--ink-soft); line-height:1.5; }

/* ============ RESPONSIVE ============ */
@media (max-width:900px){
    .sc-shell{ grid-template-columns:1fr; height:calc(100vh - 130px); border-radius:0; max-width:100%; overflow-x:hidden; }
    .sc-shell.sc-shell-3col{ grid-template-columns:1fr; }
    .sc-panel.sc-side-panel{ display:flex; }
    .sc-panel.sc-chat-col{ display:flex; }
    .sc-shell:has(.sc-side-panel) .sc-panel.sc-side-panel{ display:flex; }
    .sc-shell:has(.sc-side-panel) .sc-panel.sc-chat-col{ display:none; }
    .sc-shell.sc-conv-open:has(.sc-side-panel) .sc-panel.sc-side-panel{ display:none; }
    .sc-shell.sc-conv-open:has(.sc-side-panel) .sc-panel.sc-chat-col{ display:flex; }
    .sc-info-panel-col{ display:none !important; }
    .sc-chat-header-left .sc-back{ display:flex; }
    .sc-landing-grid{ grid-template-columns:1fr; }
    .sc-msg{ max-width:88%; }
    /* Cegah iOS Safari auto-zoom saat fokus ke input (terjadi kalau font-size < 16px) */
    .sc-composer-input, .sc-search input{ font-size:16px; }
    .sc-emoji-pop{ width:min(270px, calc(100vw - 28px)); }
}
@media (max-width:900px) and (max-height:640px){
    .sc-messages{ padding:10px; }
}
.sc-shell, .sc-panel{ scroll-behavior:smooth; }
.sc-messages::-webkit-scrollbar, .sc-conv-list::-webkit-scrollbar{ width:6px; }
.sc-messages::-webkit-scrollbar-thumb, .sc-conv-list::-webkit-scrollbar-thumb{ background:var(--grey-dark); border-radius:10px; }
