/* ═══════════════════════════════════════════════════════════════
   CaseVendoty — Modern Corporate UI
   ═══════════════════════════════════════════════════════════════ */

:root {
    --cv-primary:       #2563eb;
    --cv-primary-hover: #1d4ed8;
    --cv-primary-light: #eff6ff;
    --cv-sidebar-bg:    #0f172a;
    --cv-sidebar-hover: #1e293b;
    --cv-sidebar-text:  #94a3b8;
    --cv-sidebar-active:#ffffff;
    --cv-surface:       #ffffff;
    --cv-bg:            #f1f5f9;
    --cv-border:        #e2e8f0;
    --cv-text:          #0f172a;
    --cv-text-muted:    #64748b;
    --cv-success:       #16a34a;
    --cv-warning:       #d97706;
    --cv-danger:        #dc2626;
    --cv-radius:        12px;
    --cv-radius-sm:     8px;
    --cv-shadow:        0 1px 3px 0 rgb(0 0 0/.08), 0 1px 2px -1px rgb(0 0 0/.05);
    --cv-shadow-md:     0 4px 6px -1px rgb(0 0 0/.08), 0 2px 4px -2px rgb(0 0 0/.05);
    --cv-shadow-lg:     0 10px 15px -3px rgb(0 0 0/.08), 0 4px 6px -4px rgb(0 0 0/.05);
    --cv-transition:    all .18s ease;
}

* { box-sizing: border-box; }

html, body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: var(--cv-bg);
    color: var(--cv-text);
    height: 100%;
    margin: 0;
}

/* ── Layout ─────────────────────────────────────────────────── */
.cv-wrapper   { height: 100vh; overflow: hidden; }
.cv-sidebar   { width: 240px; min-width: 240px; background: var(--cv-sidebar-bg); overflow-y: auto; flex-shrink: 0; }
.cv-main      { overflow-y: auto; overflow-x: hidden; height: 100vh; background: var(--cv-bg); min-width: 0; flex: 1 1 auto; }
.cv-content   { padding: 28px; min-height: calc(100vh - 0px); max-width: 100%; }

/* ── Page Shell ─────────────────────────────────────────────── */
.cv-page          { max-width: 100%; }
.cv-page-form     { max-width: 720px; margin: 0 auto; }
.cv-page-wide     { max-width: 1200px; margin: 0 auto; }
.cv-page-full     { margin: -28px; height: calc(100vh); overflow: hidden; }

.cv-page-header   { flex-wrap: wrap; }
.cv-page-title    { font-size: 1.35rem; font-weight: 600; color: var(--cv-text); line-height: 1.3; }
.cv-page-subtitle { font-size: 13px; color: var(--cv-text-muted); margin-top: 4px; }
.cv-back-btn      { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--cv-radius-sm); }

.cv-card          { border: 0; border-radius: var(--cv-radius); box-shadow: var(--cv-shadow); background: var(--cv-surface); }
.cv-card-header   { background: var(--cv-surface); border-bottom: 1px solid var(--cv-border); padding: 14px 20px; font-weight: 600; font-size: 13px; }

.cv-page-loader   { min-height: 200px; }

/* ── Sidebar Brand ──────────────────────────────────────────── */
.cv-brand {
    padding: 8px 12px;
    border-radius: var(--cv-radius-sm);
    transition: var(--cv-transition);
    color: white !important;
}
.cv-brand:hover { background: var(--cv-sidebar-hover); }
.cv-brand-icon  { color: #60a5fa; }

/* ── Nav Links ──────────────────────────────────────────────── */
.cv-nav-link {
    color: var(--cv-sidebar-text) !important;
    border-radius: var(--cv-radius-sm);
    padding: 8px 12px;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--cv-transition);
    display: flex;
    align-items: center;
    position: relative;
}
.cv-nav-link:hover   { background: var(--cv-sidebar-hover); color: #e2e8f0 !important; }
.cv-nav-link.active  {
    background: var(--cv-primary);
    color: var(--cv-sidebar-active) !important;
    box-shadow: 0 2px 8px rgb(37 99 235/.35);
}
.cv-nav-link i { font-size: 16px; width: 20px; flex-shrink: 0; }

/* Unread Badge on nav link */
.cv-nav-badge {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    animation: cv-badge-pop .25s cubic-bezier(.36,.07,.19,.97);
}
@keyframes cv-badge-pop {
    0%   { transform: translateY(-50%) scale(0); }
    70%  { transform: translateY(-50%) scale(1.2); }
    100% { transform: translateY(-50%) scale(1); }
}

/* ── User Section ───────────────────────────────────────────── */
.cv-user-section {
    border-top: 1px solid #1e293b;
    padding-top: 12px;
    margin-top: 12px;
}
.cv-lang-switcher .cv-lang-btn {
    width: 100%;
    background: rgba(255,255,255,.06);
    color: var(--cv-sidebar-text);
    border: 1px solid rgba(255,255,255,.1);
    font-size: 12px;
}
.cv-lang-switcher .cv-lang-btn:hover,
.cv-lang-switcher .cv-lang-btn:focus {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.cv-lang-switcher .dropdown-item.active {
    background: #eff6ff;
    color: #2563eb;
}
.cv-logout-btn {
    background: transparent;
    color: var(--cv-sidebar-text);
    border: none;
    padding: 6px 8px;
    border-radius: var(--cv-radius-sm);
    transition: var(--cv-transition);
}
.cv-logout-btn:hover { background: #dc2626; color: white; }

/* ── Avatar ─────────────────────────────────────────────────── */
.cv-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.cv-avatar-sm { width: 28px; height: 28px; font-size: 12px; border-radius: 7px; }
.cv-avatar-lg { width: 48px; height: 48px; font-size: 18px; border-radius: 14px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    border-radius: var(--cv-radius) !important;
    transition: var(--cv-transition);
}
.card.shadow-sm { box-shadow: var(--cv-shadow) !important; }
.card.shadow-sm:hover { box-shadow: var(--cv-shadow-md) !important; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    border-radius: var(--cv-radius-sm);
    font-weight: 500;
    font-size: 13.5px;
    transition: var(--cv-transition);
}
.btn-primary { background: var(--cv-primary); border-color: var(--cv-primary); }
.btn-primary:hover {
    background: var(--cv-primary-hover);
    border-color: var(--cv-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgb(37 99 235/.3);
}
.btn-primary:active { transform: translateY(0); }
.btn-outline-secondary { border-color: var(--cv-border); color: var(--cv-text-muted); }
.btn-outline-secondary:hover { background: var(--cv-bg); border-color: #94a3b8; color: var(--cv-text); }

/* ── Form Controls ──────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: var(--cv-radius-sm);
    border-color: var(--cv-border);
    font-size: 13.5px;
    transition: var(--cv-transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--cv-primary);
    box-shadow: 0 0 0 3px rgb(37 99 235/.12);
}

/* ── Tables ─────────────────────────────────────────────────── */
.table { font-size: 13.5px; }
.table > thead > tr > th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--cv-text-muted);
    border-bottom: 1px solid var(--cv-border);
    background: #f8fafc;
}
.table-hover > tbody > tr {
    transition: var(--cv-transition);
    cursor: default;
}
.table-hover > tbody > tr:hover { background: #f8fafc; }
.table-hover > tbody > tr.clickable:hover { background: var(--cv-primary-light); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }

/* ── Priority ───────────────────────────────────────────────── */
.cv-priority { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; display: inline-block; }
.cv-priority-1 { background:#f0fdf4; color:#16a34a; }
.cv-priority-2 { background:#fefce8; color:#ca8a04; }
.cv-priority-3 { background:#fff7ed; color:#ea580c; }
.cv-priority-4 { background:#fef2f2; color:#dc2626; }

/* ── Auth Pages ─────────────────────────────────────────────── */
.cv-auth-wrapper { background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); }
.cv-auth-card {
    border-radius: 16px !important;
    box-shadow: 0 25px 50px rgb(0 0 0/.25) !important;
    border: 1px solid rgba(255,255,255,.08) !important;
}

/* ── Stats ──────────────────────────────────────────────────── */
.cv-stat-icon { flex-shrink: 0; }

/* ── Case Messages ──────────────────────────────────────────── */
.cv-message-agent    { border-left: 3px solid var(--cv-primary) !important; }
.cv-message-customer { border-left: 3px solid #10b981 !important; }
.cv-internal-note    { border-left: 3px solid #f59e0b !important; background: #fffbeb !important; }

/* ── Chat ───────────────────────────────────────────────────── */
.cv-chat-page {
    margin: -28px;
    height: calc(100vh);
    height: 100dvh;
    overflow: hidden;
}

/* Chat route — lock outer layout; only inner panels scroll */
.cv-wrapper.cv-chat-route .cv-main {
    overflow: hidden;
}
.cv-wrapper.cv-chat-route .cv-content {
    padding: 0;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.cv-wrapper.cv-chat-route .cv-chat-page {
    margin: 0;
    flex: 1;
    min-height: 0;
    height: auto;
}

.cv-chat-shell {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--cv-surface);
}

.cv-chat-left {
    display: flex;
    flex-direction: column;
    width: 360px;
    min-width: 320px;
    max-width: 40%;
    border-right: 1px solid var(--cv-border);
    background: #fff;
    flex-shrink: 0;
    min-height: 0;
    overflow: hidden;
}

.cv-chat-right {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: #f0f2f5;
    overflow: hidden;
}

.cv-chat-left-header {
    padding: 12px 16px 8px;
    background: #fff;
    flex-shrink: 0;
}

.cv-chat-search-wrap {
    padding: 4px 16px 10px;
    background: #fff;
    flex-shrink: 0;
}

.cv-chat-filters {
    display: flex;
    gap: 8px;
    padding: 0 16px 10px;
    overflow-x: auto;
    background: #fff;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cv-chat-filters::-webkit-scrollbar { display: none; }

.cv-chat-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--cv-text);
}

.cv-chat-compose-btn,
.cv-chat-new-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--cv-transition);
    box-shadow: 0 2px 6px rgb(37 211 102 / .35);
}
.cv-chat-compose-btn:hover,
.cv-chat-new-btn:hover { background: #20bd5a; }

.cv-chat-wa-toolbar { gap: 12px; }

.cv-chat-wa-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0f2f5;
    border-radius: 10px;
    padding: 8px 14px;
}
.cv-chat-wa-search i { color: #667781; font-size: 14px; }
.cv-chat-wa-search-input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 14px;
    outline: none;
    color: var(--cv-text);
}
.cv-chat-wa-search-input::placeholder { color: #667781; }

.cv-chat-filter {
    border: none;
    background: #f0f2f5;
    color: #54656f;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 999px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--cv-transition);
}
.cv-chat-filter.active {
    background: #d9fdd3;
    color: #008069;
}
.cv-chat-filter-badge {
    background: #25d366;
    color: #fff;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* legacy tab styles (desktop fallback) */
.cv-chat-tabs { border-bottom: 1px solid var(--cv-border); }
.cv-chat-tab {
    padding: 10px 8px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    border-bottom: 2px solid transparent !important;
}
.cv-chat-tab.active {
    color: var(--cv-primary);
    border-bottom-color: var(--cv-primary) !important;
}

.cv-chat-search-icon { border-radius: 20px 0 0 20px !important; }
.cv-chat-search-input { border-radius: 0 20px 20px 0 !important; font-size: 13px; }

.cv-chat-list-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Active conversation — header/footer fixed, messages scroll */
.cv-chat-thread {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.cv-chat-welcome {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.cv-chat-row-link,
.cv-chat-row-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background .15s ease;
    min-height: 72px;
    border: none;
    border-bottom: 1px solid #f0f2f5;
    background: #fff;
    width: 100%;
    text-align: left;
    color: #111b21 !important;
    text-decoration: none !important;
}
a.cv-chat-row-link:visited,
a.cv-chat-row-link:hover,
a.cv-chat-row-link:focus {
    color: #111b21 !important;
    text-decoration: none !important;
}
.cv-chat-row-link:hover,
.cv-chat-row-btn:hover,
.cv-chat-row-link.active { background: #f5f6f6; }
.cv-chat-row-link:active,
.cv-chat-row-btn:active { background: #e9edef; }

.cv-chat-row-avatar-wrap { position: relative; flex-shrink: 0; }
.cv-avatar-round { border-radius: 50% !important; width: 50px; height: 50px; font-size: 18px; }

.cv-chat-row-body { flex: 1; min-width: 0; }
.cv-chat-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cv-chat-row-name {
    font-size: 16px;
    font-weight: 400;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cv-chat-row-name.unread { font-weight: 700; }
.cv-chat-row-time { font-size: 12px; color: #667781; flex-shrink: 0; }
.cv-chat-row-preview {
    font-size: 14px;
    color: #667781;
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cv-chat-row-preview.unread { color: #111b21; font-weight: 500; }

.cv-chat-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #25d366;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}
.cv-chat-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    color: #94a3b8;
    text-transform: uppercase;
}
.cv-avatar-contact { background: linear-gradient(135deg, #10b981, #0891b2); }
.cv-chat-row-action { font-size: 16px; opacity: .35; flex-shrink: 0; }
.cv-chat-row:hover .cv-chat-row-action { opacity: 1; }

.cv-chat-welcome-icon {
    font-size: 64px;
    opacity: .15;
    line-height: 1;
}

.cv-chat-back-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #008069;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
    padding: 0;
}
.cv-chat-thread-header {
    padding: 10px 16px !important;
    background: #f0f2f5 !important;
    border-bottom: 1px solid var(--cv-border) !important;
    flex-shrink: 0;
}

.cv-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.cv-chat-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff !important;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgb(37 99 235 / .28);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
    white-space: nowrap;
}
.cv-chat-header-btn i { font-size: 14px; }
.cv-chat-header-btn:hover {
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgb(37 99 235 / .35);
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}
.cv-chat-header-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgb(37 99 235 / .25);
}

.cv-chat-header-name { font-size: 14.5px; }
.cv-chat-header-email { font-size: 11px; }

.cv-chat-msg-row { animation: cv-msg-in .18s ease; }
.cv-chat-msg-col { max-width: 65%; }
.cv-chat-msg-col-wrap { position: relative; }
.cv-chat-msg-col-wrap:has(.cv-chat-msg-actions) { padding-top: 4px; }
.cv-chat-msg-col-admin { position: relative; }
.cv-chat-msg-actions {
    display: none;
    position: absolute;
    top: -4px;
    right: 0;
    gap: 2px;
    z-index: 2;
}
.cv-chat-msg-col-admin:hover .cv-chat-msg-actions { display: flex; }
.cv-chat-msg-col-wrap:hover .cv-chat-msg-actions { display: flex; }
.cv-chat-msg-row.justify-content-end .cv-chat-msg-actions { right: 0; left: auto; }
.cv-chat-msg-row.justify-content-start .cv-chat-msg-actions { left: 0; right: auto; }
.cv-chat-msg-action-btn {
    border: none;
    background: #fff;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #64748b;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    cursor: pointer;
}
.cv-chat-msg-action-btn:hover:not(:disabled) { background: #f1f5f9; color: #334155; }
.cv-chat-msg-action-btn:disabled { opacity: .45; cursor: default; }
.cv-chat-msg-meta {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 3px;
}
.cv-chat-msg-row.justify-content-end .cv-chat-msg-meta { text-align: right; }
.cv-chat-date-badge { font-size: 11px; }

.cv-chat-wrapper { background: var(--cv-surface); border-radius: var(--cv-radius); overflow: hidden; }

.cv-chat-header {
    background: var(--cv-surface);
    border-bottom: 1px solid var(--cv-border) !important;
    position: sticky;
    top: 0;
    z-index: 10;
}

.cv-chat-thread .cv-chat-header {
    position: static;
    flex-shrink: 0;
}

.cv-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #e8ecef;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.cv-chat-messages::-webkit-scrollbar       { width: 5px; }
.cv-chat-messages::-webkit-scrollbar-track { background: transparent; }
.cv-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* Chat bubbles (used in both split-panel and standalone) */
@keyframes cv-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cv-bubble {
    padding: 9px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    display: inline-block;
    max-width: 100%;
}
.cv-bubble-mine {
    background: #d9fdd3;
    color: #111b21;
    border-bottom-right-radius: 5px;
}
.cv-bubble-theirs {
    background: white;
    color: var(--cv-text);
    border-bottom-left-radius: 5px;
    box-shadow: var(--cv-shadow);
}

/* Chat input bar */
.cv-chat-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--cv-border);
    background: var(--cv-surface);
    flex-shrink: 0;
}
.cv-chat-upload-error {
    flex-shrink: 0;
    background: var(--cv-surface);
    border-top: 1px solid var(--cv-border);
}
.cv-message-input {
    border-radius: 24px !important;
    padding: 10px 16px !important;
    resize: none;
    max-height: 120px;
    border-color: var(--cv-border);
    overflow-y: hidden;
}
.cv-message-input:focus { border-color: var(--cv-primary); box-shadow: 0 0 0 3px rgb(37 99 235/.1) !important; }
.cv-send-btn {
    width: 40px; height: 40px;
    border-radius: 50% !important;
    background: #008069;
    border: none;
    color: white;
    display: flex; align-items: center; justify-content: center;
    transition: var(--cv-transition);
    flex-shrink: 0;
}
.cv-send-btn:hover:not(:disabled) {
    background: #006e5a;
    transform: scale(1.05);
}
.cv-send-btn:disabled { background: #94a3b8; }

.cv-chat-tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #54656f;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--cv-transition);
}
.cv-chat-tool-btn:hover:not(:disabled) {
    background: #e9edef;
    color: #008069;
}
.cv-chat-tool-btn:disabled { opacity: 0.45; }

.cv-bubble-image {
    padding: 4px;
    overflow: hidden;
}
.cv-chat-img-link {
    display: block;
    line-height: 0;
}
.cv-chat-img {
    max-width: min(280px, 70vw);
    max-height: 320px;
    border-radius: 12px;
    display: block;
    object-fit: cover;
    cursor: pointer;
}
.cv-chat-img-caption {
    padding: 6px 10px 4px;
    white-space: pre-wrap;
}
.cv-chat-file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: inherit;
    text-decoration: none;
    min-width: 180px;
    max-width: min(280px, 70vw);
}
.cv-chat-file-link:hover {
    color: inherit;
    opacity: 0.85;
}
.cv-chat-file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
}
.cv-chat-file-dl {
    flex-shrink: 0;
    opacity: 0.6;
    font-size: 14px;
}

/* Conversation list */
.cv-conv-item {
    border-bottom: 1px solid var(--cv-border);
    transition: var(--cv-transition);
}
.cv-conv-item:hover { background: var(--cv-primary-light); }
.cv-conv-item:last-child { border-bottom: none; }
.cv-conv-unread .fw-medium { font-weight: 700 !important; }

/* ── User Search Dropdown ────────────────────────────────────── */
.cv-search-dropdown { background:#fff; z-index:200; max-height:280px; overflow-y:auto; }
.cv-search-item:hover { background-color:#f1f5f9; border-radius:8px; }

/* ── Wizard ──────────────────────────────────────────────────── */
.cv-wizard-option {
    border: 2px solid var(--cv-border);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: var(--cv-transition);
    background: #fff;
}
.cv-wizard-option:hover   { border-color: #93c5fd; background: #eff6ff; }
.cv-wizard-option.selected { border-color: var(--cv-primary); background: #eff6ff; }
.cv-wizard-option-icon {
    width: 44px; height: 44px;
    background: #dbeafe;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--cv-primary);
    flex-shrink: 0;
}

/* ── Rich text editor ───────────────────────────────────────── */
.cv-rich-text { width: 100%; }
.cv-rich-toolbar .btn { padding: 4px 8px; }
.cv-rich-editor {
    min-height: 160px;
    max-height: 320px;
    overflow-y: auto;
    line-height: 1.5;
    font-size: 14px;
}
.cv-rich-editor:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}
.cv-rich-editor:focus { outline: none; border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.cv-rich-content { line-height: 1.55; font-size: 14px; word-break: break-word; }
.cv-rich-content ul, .cv-rich-content ol { margin: .35rem 0 .35rem 1.25rem; padding: 0; }
.cv-rich-content p { margin-bottom: .35rem; }
.cv-case-attachments-inline { margin-top: .5rem; }
.cv-case-attachments-inline a {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; padding: 2px 8px; margin: 2px 4px 2px 0;
    background: #f1f5f9; border-radius: 6px; text-decoration: none; color: #334155;
}
.cv-case-attachments-inline a:hover { background: #e2e8f0; }

.cv-case-attachments-block { display: flex; flex-direction: column; gap: .75rem; }
.cv-case-image-att { max-width: 100%; }
.cv-case-image-link { display: inline-block; max-width: min(100%, 420px); }
.cv-case-image-preview {
    display: block;
    max-width: 100%;
    max-height: 320px;
    width: auto;
    height: auto;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    object-fit: contain;
    background: #f8fafc;
    cursor: zoom-in;
}
.cv-case-file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 6px 10px;
    background: #f1f5f9;
    border-radius: 8px;
    text-decoration: none;
    color: #334155;
    max-width: 100%;
}
.cv-case-file-link:hover { background: #e2e8f0; color: #1e293b; }

/* ── Case Timeline ───────────────────────────────────────────── */
.cv-timeline     { position: relative; }
.cv-tl-item      { position: relative; }
.cv-tl-item::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 22px;
    bottom: 0;
    width: 1px;
    background: var(--cv-border);
}
.cv-tl-item:last-child::before { display: none; }
.cv-tl-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ── Empty State ─────────────────────────────────────────────── */
.cv-empty-state { padding: 60px 20px; }
.cv-empty-icon  { font-size: 48px; opacity: .25; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Animations ──────────────────────────────────────────────── */
.fade-in { animation: cv-fade .3s ease; }
@keyframes cv-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Chat Bottom Nav ─────────────────────────────────────────── */
.cv-chat-bottom-nav {
    display: none;
    flex-shrink: 0;
    align-items: stretch;
    justify-content: space-around;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 16px rgb(15 23 42 / .06);
}

.cv-chat-bottom-nav-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    border-radius: 12px;
    color: #64748b !important;
    text-decoration: none !important;
    font-size: 10px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
    min-width: 0;
}
.cv-chat-bottom-nav-item i { font-size: 20px; line-height: 1; }
.cv-chat-bottom-nav-item span { line-height: 1.1; }
.cv-chat-bottom-nav-item:hover { background: #f1f5f9; color: #334155 !important; }
.cv-chat-bottom-nav-item.active {
    color: #2563eb !important;
    background: #eff6ff;
}
.cv-chat-bottom-nav-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 22px);
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}

.cv-table-row { cursor: pointer; }

/* Mobile case list cards (replaces wide tables on small screens) */
.cv-case-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cv-case-mobile-card {
    width: 100%;
    text-align: left;
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    background: var(--cv-surface);
    padding: 14px 16px;
    box-shadow: var(--cv-shadow);
    transition: var(--cv-transition);
}
.cv-case-mobile-card:hover,
.cv-case-mobile-card:active {
    border-color: #93c5fd;
    background: #f8fafc;
}
.cv-case-mobile-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.cv-case-mobile-subject {
    font-weight: 600;
    font-size: 14px;
    color: var(--cv-text);
    line-height: 1.35;
    word-break: break-word;
}
.cv-case-mobile-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.cv-case-mobile-meta {
    font-size: 12px;
    color: var(--cv-text-muted);
    line-height: 1.5;
    word-break: break-word;
}
.cv-case-mobile-meta i { margin-right: 4px; opacity: 0.7; }
.cv-case-mobile-date {
    font-size: 11px;
    color: var(--cv-text-muted);
    margin-top: 6px;
}

.cv-case-row-unread {
    background: #eff6ff !important;
}
.cv-case-row-unread:hover {
    background: #dbeafe !important;
}
.cv-case-reply-badge {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    vertical-align: middle;
}
.cv-case-mobile-card-unread {
    border-color: #93c5fd;
    background: #eff6ff;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.12);
}
.cv-case-mobile-reply {
    font-weight: 500;
}
.cv-case-system-notice {
    border-color: #7dd3fc;
    background: #f0f9ff;
}
.cv-case-system-notice .badge {
    font-size: 10px;
}

.cv-case-task-list .form-check-input {
    cursor: pointer;
}
.cv-task-status-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
}

.cv-desktop-table { display: block; }
.cv-mobile-cards  { display: none; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .cv-sidebar { width: 60px; min-width: 60px; padding: 12px 8px !important; }
    .cv-sidebar .cv-brand span:last-child,
    .cv-sidebar .nav-link span,
    .cv-sidebar .cv-user-section .flex-grow-1 { display: none; }
    .cv-sidebar .cv-user-section form { display: none !important; }
    .cv-sidebar .nav-item > span.text-white-50 { display: none !important; }
    .cv-sidebar .nav-item.mt-1,
    .cv-sidebar .nav-item.mt-2 { margin-top: 0 !important; }
    .cv-sidebar .nav-link { justify-content: center; padding: 10px; }
    .cv-sidebar .nav-link i { margin: 0 !important; }
    .cv-sidebar .cv-nav-badge {
        right: 4px;
        top: 4px;
        transform: none;
        min-width: 16px;
        height: 16px;
        font-size: 9px;
    }

    .cv-page-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .cv-page-actions {
        width: 100%;
    }
    .cv-page-actions .btn {
        flex: 1;
    }
    .cv-page-title {
        font-size: 1.15rem;
    }

    .cv-desktop-table { display: none !important; }
    .cv-mobile-cards  { display: block; }

    .cv-pagination-mobile {
        justify-content: center !important;
    }

    /* Chat route — full screen like WhatsApp */
    .cv-wrapper.cv-chat-route .cv-sidebar { display: none !important; }
    .cv-wrapper.cv-chat-route .cv-main { width: 100%; }
    .cv-wrapper.cv-chat-route .cv-content { padding: 0; }

    .cv-chat-page {
        margin: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
    }

    .cv-chat-left {
        width: 100%;
        min-width: 0;
        max-width: none;
        flex: 1;
        border-right: none;
    }

    .cv-chat-right {
        display: none !important;
        flex: 1;
        width: 100%;
    }

    .cv-chat-welcome { display: none !important; }

    .cv-chat-shell.cv-chat-active .cv-chat-left { display: none !important; }
    .cv-chat-shell.cv-chat-active .cv-chat-right {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        inset: 0;
        z-index: 200;
        width: 100vw;
        height: 100dvh;
        min-height: 0;
        animation: cv-chat-slide-in .2s ease;
    }

    @keyframes cv-chat-slide-in {
        from { transform: translateX(100%); }
        to   { transform: translateX(0); }
    }

    .cv-chat-shell.cv-chat-active .cv-chat-back-btn { display: inline-flex !important; }

    .cv-chat-title { font-size: 28px; }

    .cv-chat-left-header {
        padding: 16px 16px 8px;
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
    }

    .cv-chat-header {
        padding: 10px 12px !important;
        padding-top: calc(10px + env(safe-area-inset-top, 0px)) !important;
    }

    .cv-chat-messages {
        padding: 10px 12px !important;
        gap: 6px;
        background: #e8ecef;
    }

    .cv-chat-msg-col { max-width: 85%; }
    .cv-chat-msg-avatar { display: none; }

    .cv-chat-footer {
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
        background: #f0f2f5 !important;
    }

    .cv-message-input {
        font-size: 16px !important;
        padding: 11px 14px !important;
        background: #fff !important;
    }

    .cv-send-btn {
        width: 44px;
        height: 44px;
        background: #008069;
    }

    .cv-chat-row-link,
    .cv-chat-row-btn {
        min-height: 76px;
        padding: 10px 16px;
    }

    .cv-bubble-mine {
        background: #d9fdd3;
        color: #111b21;
    }

    .cv-chat-bottom-nav { display: flex; }

    .cv-chat-list-scroll {
        padding-bottom: 8px;
    }

    .cv-chat-shell.cv-chat-active .cv-chat-bottom-nav { display: none; }
}

@media (max-width: 768px) {
    .cv-content { padding: 12px; }
    .cv-wrapper.cv-chat-route .cv-content { padding: 0; }
}

@media (min-width: 992px) {
    .cv-chat-back-btn { display: none !important; }
    .cv-chat-thread-header { background: #fff !important; }
    .cv-chat-messages { background: #f0f2f5; }
    .cv-bubble-mine {
        background: var(--cv-primary);
        color: white;
    }
    .cv-send-btn { background: var(--cv-primary); }
    .cv-send-btn:hover:not(:disabled) { background: var(--cv-primary-hover); }
    .cv-chat-compose-btn {
        background: #eff6ff;
        color: var(--cv-primary);
        box-shadow: none;
    }
    .cv-chat-compose-btn:hover { background: #dbeafe; }
    .cv-chat-filter.active {
        background: #eff6ff;
        color: var(--cv-primary);
    }
}

@media (max-width: 480px) {
    .cv-chat-header-email { display: none; }
    .cv-chat-header-btn span { display: none; }
    .cv-chat-header-btn { padding: 10px; width: 40px; height: 40px; justify-content: center; }
}
