/* =============================================================
   JokoUI — RoC Desk Design System
   =============================================================
   Custom component classes built with Tailwind's @apply directive.
   This file defines the "JokoUI" design language: clean, modern,
   card-based, with a dark-mode aware color palette.
   ============================================================= */

/* ----- Root Variables ----- */
:root {
    --jk-primary: #6366f1;
    --jk-primary-hover: #4f46e5;
    --jk-primary-light: #e0e7ff;
    --jk-secondary: #0ea5e9;
    --jk-success: #10b981;
    --jk-warning: #f59e0b;
    --jk-danger: #ef4444;
    --jk-info: #06b6d4;
    --jk-surface: #ffffff;
    --jk-surface-alt: #f8fafc;
    --jk-border: #e2e8f0;
    --jk-text: #1e293b;
    --jk-text-muted: #64748b;
    --jk-sidebar-bg: #170130;
    --jk-sidebar-text: #cbd5e1;
    --jk-sidebar-active: #6366f1;
    --jk-radius: 12px;
    --jk-radius-sm: 8px;
    --jk-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --jk-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --jk-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --jk-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================================
   LAYOUT
   ============================================================= */

.jk-page {
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--jk-surface-alt);
    color: var(--jk-text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
}

.jk-content {
    padding: 2rem;
    max-width: 1440px;
    margin: 0 auto;
}

/* Auth pages (login, forgot password, etc.) — no padding, no max-width constraint */
.jk-main.full-width .jk-content {
    padding: 0;
    max-width: 100%;
}

.jk-main.full-width .jk-topbar {
    display: none;
}

/* ----- Sidebar ----- */
.jk-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    background: var(--jk-sidebar-bg);
    color: var(--jk-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom Sleek Scrollbar for Sidebar */
.jk-sidebar::-webkit-scrollbar {
    width: 4px;
}
.jk-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.jk-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.jk-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.jk-sidebar--collapsed {
    width: 72px;
}

.jk-sidebar-brand {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: sticky;
    top: 0;
    background: var(--jk-sidebar-bg);
    z-index: 50;
}

.jk-sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--jk-primary), var(--jk-secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: #fff;
    flex-shrink: 0;
}

.jk-sidebar-brand-text {
    font-weight: 700;
    font-size: 1.125rem;
    color: #f1f5f9;
    letter-spacing: -0.025em;
}

.jk-sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
/* Scrollbar handled by sidebar parent */

.jk-sidebar-section {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.3);
    padding: 1.25rem 0.75rem 0.5rem;
    white-space: nowrap;
}

.jk-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--jk-radius-sm);
    color: var(--jk-sidebar-text);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: var(--jk-transition);
    white-space: nowrap;
}

.jk-sidebar--collapsed .jk-sidebar-link {
    justify-content: center;
    padding: 0.625rem 0;
}

.jk-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #f1f5f9;
}

.jk-sidebar-link.active {
    background: var(--jk-sidebar-active);
    color: #ffffff;
}

.jk-sidebar-link-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* ----- Main Area ----- */
.jk-main {
    margin-left: 260px;
    min-height: 100vh;
    min-height: 100dvh;
    transition: margin-left 0.3s ease;
    min-width: 0;
    max-width: 100%;
}

.jk-main.full-width {
    margin-left: 0;
}

/* ----- Top Navbar ----- */
.jk-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 2rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--jk-border);
}

.jk-topbar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--jk-text);
    letter-spacing: -0.025em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.jk-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* =============================================================
   CARDS
   ============================================================= */

.jk-card {
    background: var(--jk-surface);
    border: 1px solid var(--jk-border);
    border-radius: var(--jk-radius);
    box-shadow: var(--jk-shadow);
    transition: var(--jk-transition);
    overflow: hidden;
}

.jk-card:hover {
    box-shadow: var(--jk-shadow-md);
}

.jk-card-clickable {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.jk-card-clickable:hover {
    box-shadow: var(--jk-shadow-lg);
    transform: translateY(-2px);
    border-color: var(--jk-primary);
}

.jk-card-body {
    padding: 1.5rem;
}

.jk-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--jk-border);
    font-weight: 600;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* =============================================================
   BUTTONS
   ============================================================= */

.jk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--jk-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--jk-transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.jk-btn:focus-visible {
    outline: 2px solid var(--jk-primary);
    outline-offset: 2px;
}

.jk-btn-primary {
    background: var(--jk-primary);
    color: #ffffff;
    border-color: var(--jk-primary);
}

.jk-btn-primary:hover {
    background: var(--jk-primary-hover);
    border-color: var(--jk-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.jk-btn-secondary {
    background: transparent;
    color: var(--jk-text);
    border-color: var(--jk-border);
}

.jk-btn-secondary:hover {
    background: var(--jk-surface-alt);
    border-color: #cbd5e1;
}

.jk-btn-success {
    background: var(--jk-success);
    color: #ffffff;
    border-color: var(--jk-success);
}

.jk-btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.jk-btn-danger {
    background: var(--jk-danger);
    color: #ffffff;
    border-color: var(--jk-danger);
}

.jk-btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.jk-btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
}

.jk-btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
}

.jk-btn-block {
    width: 100%;
}

/* =============================================================
   FORM INPUTS
   ============================================================= */

.jk-input,
.jk-select,
.jk-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--jk-text);
    background: var(--jk-surface);
    border: 1px solid var(--jk-border);
    border-radius: var(--jk-radius-sm);
    transition: var(--jk-transition);
    font-family: inherit;
}

.jk-input:focus,
.jk-select:focus,
.jk-textarea:focus {
    outline: none;
    border-color: var(--jk-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.jk-input::placeholder,
.jk-textarea::placeholder {
    color: #94a3b8;
}

.jk-textarea {
    resize: vertical;
    min-height: 90px;
}

.jk-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.jk-file-input {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.875rem;
    color: var(--jk-text-muted);
    border: 2px dashed var(--jk-border);
    border-radius: var(--jk-radius-sm);
    cursor: pointer;
    transition: var(--jk-transition);
}

.jk-file-input:hover {
    border-color: var(--jk-primary);
    background: var(--jk-primary-light);
}

.jk-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--jk-text);
    margin-bottom: 0.375rem;
}

.jk-form-group {
    margin-bottom: 1.25rem;
}

.jk-form-error {
    font-size: 0.75rem;
    color: var(--jk-danger);
    margin-top: 0.25rem;
}

/* =============================================================
   BADGES
   ============================================================= */

.jk-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 9999px;
    white-space: nowrap;
}

.jk-badge-open {
    background: #dbeafe;
    color: #1d4ed8;
}

.jk-badge-investigating {
    background: #fef3c7;
    color: #b45309;
}

.jk-badge-pending {
    background: #fce7f3;
    color: #be185d;
}

.jk-badge-resolved {
    background: #d1fae5;
    color: #065f46;
}

.jk-badge-closed {
    background: #e2e8f0;
    color: #475569;
}

.jk-badge-wa {
    background: #dcfce7;
    color: #15803d;
}

.jk-badge-email {
    background: #e0e7ff;
    color: #4338ca;
}

.jk-badge-web {
    background: #f0f9ff;
    color: #0369a1;
}

.jk-badge-sla-ok {
    background: #d1fae5;
    color: #065f46;
}

.jk-badge-sla-warn {
    background: #fef3c7;
    color: #92400e;
}

.jk-badge-sla-breach {
    background: #fee2e2;
    color: #991b1b;
}

/* =============================================================
   CHAT PANEL — Full Chat App Layout
   ============================================================= */

/* --- Panel Container --- */
.jk-chat-panel {
    display: flex;
    flex-direction: column;
    background: var(--jk-surface);
    border: 1px solid var(--jk-border);
    border-radius: var(--jk-radius);
    box-shadow: var(--jk-shadow);
    overflow: hidden;
    max-height: calc(100vh - 220px);
    max-height: calc(100dvh - 220px);
    min-height: 500px;
}

/* --- Panel Header --- */
.jk-chat-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #f1f5f9;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.jk-chat-panel__header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1 1 0;
}

.jk-chat-panel__header-info > div {
    min-width: 0;
}

.jk-chat-panel__header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9375rem;
    color: #fff;
    flex-shrink: 0;
}

.jk-chat-panel__header-name {
    font-weight: 700;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jk-chat-panel__header-meta {
    font-size: 0.75rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Panel Body (scrollable messages area) --- */
.jk-chat-panel__body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

/* --- Message List --- */
.jk-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem 0.75rem;
    background:
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.03) 0%, transparent 50%),
        #f0f2f5;
    min-height: 100%;
}

/* --- Single Message Row --- */
.jk-msg {
    display: flex;
    gap: 0.5rem;
    max-width: 85%;
    min-width: 0;
    animation: jk-msg-in 0.2s ease;
}

@keyframes jk-msg-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.jk-msg--in {
    align-self: flex-start;
}

.jk-msg--out {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* --- Avatar --- */
.jk-msg__avatar {
    flex-shrink: 0;
    padding-top: 1.25rem;
}

.jk-msg__avatar-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.jk-msg__avatar--client {
    background: #cbd5e1;
    color: #334155;
}

.jk-msg__avatar--staff {
    background: var(--jk-primary-light);
    color: var(--jk-primary-hover);
}

/* --- Message Content Wrapper --- */
.jk-msg__content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- Sender Info Row --- */
.jk-msg__info {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0 0.25rem;
    margin-bottom: 0.125rem;
}

.jk-msg__name {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--jk-text-muted);
}

.jk-msg--out .jk-msg__info {
    flex-direction: row-reverse;
}

.jk-msg__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.1875rem;
    font-size: 0.5625rem;
    font-weight: 700;
    padding: 0.0625rem 0.3125rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.jk-msg__badge--wa {
    background: #dcfce7;
    color: #15803d;
}

.jk-msg__badge--email {
    background: #e0e7ff;
    color: #4338ca;
}

.jk-msg__time {
    font-size: 0.625rem;
    color: #94a3b8;
}

.jk-msg__bubble {
    padding: 0.625rem 0.875rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: normal;
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
    min-width: 0;
}

.jk-msg__bubble--in {
    background: #ffffff;
    color: var(--jk-text);
    border-top-left-radius: 4px;
}

.jk-msg__bubble--out {
    background: #d9fdd3;
    color: #1a2e1a;
    border-top-right-radius: 4px;
}

.jk-msg__bubble--escalate {
    background: #bae6fd !important;
    /* Tailwind sky-200 */
    color: #0c4a6e !important;
    /* Tailwind sky-900 */
}

.jk-msg__text {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
}

.jk-msg__text a {
    word-break: break-all;
}

/* --- Attachments inside bubble --- */
.jk-msg__file {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    font-size: 0.8125rem;
    text-decoration: none;
    color: inherit;
    transition: var(--jk-transition);
}

.jk-msg__file:hover {
    background: rgba(0, 0, 0, 0.08);
}

.jk-msg__file small {
    color: #94a3b8;
    font-size: 0.6875rem;
}

/* --- Audio Player in Chat --- */
.jk-msg__audio-player {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    max-width: 300px;
    padding: 0.5rem 0.625rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    margin-top: 0.25rem;
}

.jk-msg__audio-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6366f1;
    color: #fff;
    border-radius: 50%;
    margin-top: 2px;
}

.jk-msg__audio-body {
    flex: 1;
    min-width: 0;
}

.jk-msg__audio-control {
    width: 100%;
    height: 36px;
    border-radius: 6px;
}

.jk-msg__audio-control::-webkit-media-controls-panel {
    background: transparent;
}

.jk-msg__audio-meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    color: #94a3b8;
    margin-top: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jk-msg__audio-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.jk-msg__bubble--out .jk-msg__audio-player {
    background: rgba(255, 255, 255, 0.15);
}

.jk-msg__bubble--out .jk-msg__audio-meta {
    color: rgba(255, 255, 255, 0.6);
}

/* --- Image Thumbnails in Chat --- */
.jk-msg__files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.jk-msg__img-thumb {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.jk-msg__img-thumb:hover {
    border-color: #6366f1;
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* --- Lightbox Overlay --- */
.jk-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.jk-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.jk-lightbox__img {
    max-width: 90vw;
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease-out;
    transform-origin: center center;
}

.jk-lightbox__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.15s;
}

.jk-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.jk-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.15s;
}

.jk-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.jk-lightbox__nav--prev { left: 1rem; }
.jk-lightbox__nav--next { right: 1rem; }

.jk-lightbox__counter {
    position: absolute;
    bottom: 5.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 500;
}

.jk-lightbox__filename {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8125rem;
    font-weight: 500;
    max-width: 60vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jk-lightbox__main {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: calc(100% - 100px);
    padding: 3rem 4rem;
}

/* --- Thumbnail Strip --- */
.jk-lightbox__strip {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.jk-lightbox__strip::-webkit-scrollbar {
    height: 4px;
}

.jk-lightbox__strip::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.jk-lightbox__strip-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    transition: opacity 0.15s, border-color 0.15s, transform 0.15s;
    flex-shrink: 0;
}

.jk-lightbox__strip-thumb:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.jk-lightbox__strip-thumb.active {
    opacity: 1;
    border-color: #6366f1;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.5);
}

/* --- Zoom Controls --- */
.jk-lightbox__zoom-controls {
    position: absolute;
    top: 1rem;
    right: 3.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
    z-index: 10;
}

.jk-lightbox__zoom-controls button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.jk-lightbox__zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.jk-lightbox__zoom-controls span {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
    user-select: none;
}

/* --- Empty State --- */
.jk-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: #94a3b8;
    min-height: 300px;
}

.jk-chat-empty p {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-top: 0.75rem;
}

.jk-chat-empty small {
    font-size: 0.8125rem;
    opacity: 0.7;
}

/* --- Panel Footer / Reply Bar --- */
.jk-chat-panel__footer {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border-top: none;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 10;
}

.jk-reply-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.625rem;
}

.jk-reply-bar__attach {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #64748b;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    background: #f1f5f9;
    border: 1px solid transparent;
}

.jk-reply-bar__attach:hover {
    background: #eef2ff;
    color: var(--jk-primary);
    border-color: rgba(99, 102, 241, 0.2);
    transform: scale(1.08);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
}

.jk-reply-bar__attach:active {
    transform: scale(0.95);
}

.jk-reply-bar__input-wrap {
    flex: 1;
    min-width: 0;
}

.jk-reply-bar__input {
    width: 100%;
    padding: 0.6875rem 1.125rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--jk-text);
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 22px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    max-height: 120px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

.jk-reply-bar__input:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--jk-primary);
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.02),
        0 0 0 3px rgba(99, 102, 241, 0.1);
}

.jk-reply-bar__input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.jk-reply-bar__file-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.5rem;
    padding: 0.3125rem 0.75rem;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #4338ca;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    max-width: 100%;
    border: 1px solid rgba(99, 102, 241, 0.15);
    animation: jk-file-tag-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes jk-file-tag-in {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.jk-reply-bar__file-tag svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.jk-reply-bar__file-tag span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jk-reply-bar__file-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: #6366f1;
    padding: 0 0 0 0.125rem;
    line-height: 1;
    opacity: 0.6;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

.jk-reply-bar__file-remove:hover {
    opacity: 1;
    background: rgba(99, 102, 241, 0.15);
    color: var(--jk-danger);
}

.jk-reply-bar__send {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.3);
    padding: 0;
}

.jk-reply-bar__send:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.4);
}

.jk-reply-bar__send:active:not(:disabled) {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.jk-reply-bar__send:disabled {
    background: #e2e8f0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

/* --- Voice Recorder --- */
.jk-reply-bar__mic {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.jk-reply-bar__mic:hover:not(:disabled) {
    background: linear-gradient(135deg, #16a34a, #15803d);
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(34, 197, 94, 0.4);
}

.jk-reply-bar__mic:disabled {
    background: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.7;
}

.jk-reply-bar__recording {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 999px;
}

.jk-reply-bar__rec-dot {
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    flex-shrink: 0;
    animation: jk-pulse-rec 1s ease-in-out infinite;
}

@keyframes jk-pulse-rec {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.jk-reply-bar__rec-send {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.jk-reply-bar__rec-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* --- Message Actions (Delete, Edit, React) --- */
.jk-msg__bubble {
    position: relative;
}

.jk-msg__action-trigger {
    position: absolute;
    top: 2px;
    right: -28px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    z-index: 2;
}

.jk-msg__bubble:hover .jk-msg__action-trigger {
    opacity: 1;
}

.jk-msg__action-trigger:hover {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.6);
}

.jk-msg__bubble--out .jk-msg__action-trigger {
    color: rgba(0, 0, 0, 0.35);
    right: auto;
    left: -28px;
}

.jk-msg__bubble--out .jk-msg__action-trigger:hover {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.7);
}

.jk-msg__bubble--out .jk-msg__action-menu {
    right: auto;
    left: -28px;
}

.jk-msg__action-menu {
    position: absolute;
    top: 28px;
    right: 4px;
    min-width: 140px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 20;
    overflow: hidden;
    padding: 0.25rem 0;
}

.jk-msg__quick-react {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.jk-msg__react-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s, transform 0.15s;
}

.jk-msg__react-btn:hover {
    background: #f1f5f9;
    transform: scale(1.2);
}

.jk-msg__action-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    font-size: 0.8125rem;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.jk-msg__action-item:hover {
    background: #f8fafc;
}

.jk-msg__action-item--danger {
    color: #ef4444;
}

.jk-msg__action-item--danger:hover {
    background: #fef2f2;
}

/* Inline edit */
.jk-msg__edit-wrap {
    padding: 0.25rem 0;
}

.jk-msg__edit-input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.8125rem;
    resize: vertical;
    outline: none;
    color: #1e293b;
}

.jk-msg__edit-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.jk-msg__edit-cancel {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    color: #64748b;
}

.jk-msg__edit-cancel:hover {
    background: #f8fafc;
}

.jk-msg__edit-save {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    border: none;
    background: #6366f1;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.jk-msg__edit-save:hover {
    background: #4f46e5;
}

/* Edited tag */
.jk-msg__edited-tag {
    font-size: 0.625rem;
    font-style: italic;
    opacity: 0.5;
    margin-left: 0.375rem;
}

/* Reactions */
.jk-msg__reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.375rem;
}

.jk-msg__reaction-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.125rem 0.375rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s, border-color 0.15s;
}

.jk-msg__reaction-badge:hover {
    background: rgba(0, 0, 0, 0.12);
    transform: scale(1.15);
    border-color: rgba(0, 0, 0, 0.1);
}

.jk-msg__bubble--out .jk-msg__reaction-badge {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Escalate Selection Mode --- */
.jk-escalate-select-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-basis: 100%;
    padding: 8px 16px;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-top: 1px solid #c7d2fe;
    margin: 8px -1.25rem -0.875rem;
    gap: 8px;
    min-height: 38px;
}

/* Checkbox hidden by default, shown when parent #chat-thread has .escalate-selecting */
.jk-msg__select-check {
    display: none;
    align-items: flex-start;
    padding-top: 10px;
    cursor: pointer;
    flex-shrink: 0;
    z-index: 5;
}

.escalate-selecting .jk-msg__select-check {
    display: flex;
}

.jk-msg__select-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4f46e5;
}

/* --- Inline Delivery Status Indicators --- */
.jk-msg__status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    margin-left: 0.375rem;
    vertical-align: middle;
}

.jk-msg__status--success {
    color: #22c55e;
}

.jk-msg__status--pending {
    color: #f59e0b;
}

.jk-msg__status--failed {
    color: #ef4444;
    cursor: pointer;
    position: relative;
}

.jk-msg__error-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    right: -4px;
    background: #ffffff;
    border: 1px solid #fecaca;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 400;
    width: 240px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    z-index: 60;
    overflow: hidden;
}

.jk-msg__error-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 10px;
    border: 6px solid transparent;
    border-top-color: #fecaca;
}

.jk-msg__error-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.375rem 0.625rem;
    background: #fef2f2;
    border-bottom: 1px solid #fecaca;
    font-weight: 700;
    font-size: 0.8875rem;
    color: #dc2626;
}

.jk-msg__error-popup-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #dc2626;
    opacity: 0.6;
    line-height: 1;
    padding: 0;
}

.jk-msg__error-popup-close:hover {
    opacity: 1;
}

.jk-msg__error-popup-body {
    padding: 0.5rem 0.625rem;
    color: #64748b;
    line-height: 1.4;
    word-break: break-word;
    font-family: ui-monospace, monospace;
    font-size: 0.6235rem;
}

@keyframes jk-status-spin {
    to {
        transform: rotate(360deg);
    }
}

.jk-msg__status--pending svg {
    animation: jk-status-spin 1s linear infinite;
}

/* --- Tablet/Desktop Responsive Chat Header (in split panel) --- */
@media (min-width: 769px) and (max-width: 1280px) {
    .jk-chat-panel__header {
        padding: 0.625rem 0.875rem;
        gap: 0.375rem;
    }

    .jk-chat-panel__header-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8125rem;
    }

    .jk-chat-panel__header-info {
        gap: 0.5rem;
    }

    .jk-chat-panel__header-name {
        font-size: 0.8125rem;
    }

    .jk-chat-panel__header-meta {
        font-size: 0.6875rem;
    }
}

/* --- Mobile Responsive Chat --- */
@media (max-width: 1024px) {
    .jk-chat-panel {
        max-height: none;
        min-height: auto;
    }

    .jk-chat-panel__body {
        max-height: 60vh;
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    .jk-chat-panel {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .jk-chat-panel__header {
        padding: 0.5rem 0.75rem;
        gap: 0.375rem;
    }

    .jk-chat-panel__header-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }

    .jk-chat-panel__header-info {
        gap: 0.5rem;
    }

    .jk-chat-panel__header-name {
        font-size: 0.8125rem;
    }

    .jk-chat-panel__header-meta {
        font-size: 0.625rem;
    }

    .jk-msg {
        max-width: 92%;
    }

    .jk-chat-messages {
        padding: 0.75rem 0.5rem;
    }

    .jk-chat-panel__body {
        max-height: 55vh;
        min-height: 250px;
    }

    .jk-msg__avatar {
        display: none;
    }

    .jk-reply-bar__input {
        font-size: 1rem;
    }
}

/* =============================================================
   TABLE
   ============================================================= */

.jk-table-wrapper {
    overflow-x: auto;
    border-radius: var(--jk-radius);
    border: 1px solid var(--jk-border);
    background: var(--jk-surface);
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.jk-table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.jk-table thead {
    background: var(--jk-surface-alt);
}

.jk-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--jk-text-muted);
    border-bottom: 1px solid var(--jk-border);
    white-space: nowrap;
}

.jk-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--jk-text);
    vertical-align: middle;
}

.jk-table tbody tr {
    transition: var(--jk-transition);
}

.jk-table tbody tr:hover {
    background: #f8fafc;
}

.jk-table tbody tr:last-child td {
    border-bottom: none;
}

.jk-table-link {
    color: var(--jk-primary);
    text-decoration: none;
    font-weight: 600;
}

.jk-table-link:hover {
    text-decoration: underline;
}

/* =============================================================
   SPLIT PANEL
   ============================================================= */

.jk-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .jk-split {
        grid-template-columns: 1fr;
    }
}

/* =============================================================
   ALERTS / TOASTS
   ============================================================= */

.jk-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--jk-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.jk-alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.jk-alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.jk-alert-info {
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #bae6fd;
}

/* =============================================================
   CATEGORY GRID
   ============================================================= */

.jk-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.jk-category-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: var(--jk-transition);
    cursor: pointer;
}

.jk-category-card:hover {
    box-shadow: var(--jk-shadow-lg);
    transform: translateY(-3px);
    border-color: var(--jk-primary);
}

/* Disable conflicting hover on inner <a> to prevent overflow:hidden clipping */
.jk-category-card .jk-card-clickable {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.jk-category-card .jk-card-clickable:hover {
    box-shadow: none;
    transform: none;
    border-color: transparent;
}

.jk-category-card .jk-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.jk-category-action {
    margin-top: auto;
    padding-top: 0.875rem;
    border-top: 1px solid var(--jk-border);
}

.jk-category-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.875rem;
    background: var(--jk-primary-light);
    color: var(--jk-primary);
    transition: var(--jk-transition);
    flex-shrink: 0;
}

.jk-card-clickable:hover .jk-category-icon {
    background: var(--jk-primary);
    color: #fff;
    transform: scale(1.04);
}

.jk-category-name {
    font-weight: 700;
    font-size: 0.9375rem;
    margin-bottom: 0.3rem;
    color: var(--jk-text);
    letter-spacing: -0.015em;
    line-height: 1.35;
}

.jk-category-desc {
    font-size: 0.8rem;
    color: var(--jk-text-muted);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.jk-category-card .jk-card-body {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.jk-category-card .jk-card-body .jk-category-action {
    margin-top: auto;
    padding-top: 0.875rem;
    border-top: 1px solid var(--jk-border);
}

/* =============================================================
   UTILITIES
   ============================================================= */

.jk-divider {
    border: none;
    border-top: 1px solid var(--jk-border);
    margin: 1.5rem 0;
}

.jk-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--jk-text-muted);
}

.jk-empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.jk-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

.jk-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--jk-primary);
    border-radius: 50%;
    animation: jk-spin 0.6s linear infinite;
}

@keyframes jk-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Fade-in for HTMX swaps */
.htmx-added {
    animation: jk-fade-in 0.3s ease;
}

@keyframes jk-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================================
   DOCS PAGE — Grid helpers (responsive via media queries below)
   ============================================================= */

.docs-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); }
.docs-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }

/* =============================================================
   RESPONSIVE — Sidebar overlay (tablet & mobile)
   ============================================================= */

/* Tablet + Mobile: sidebar overlays content (≤1024px) */
@media (max-width: 1024px) {
    .jk-sidebar {
        transform: translateX(-100%);
    }

    .jk-sidebar.open {
        transform: translateX(0);
    }

    .jk-main {
        margin-left: 0 !important;
    }
}

/* Mobile-specific adjustments (≤768px) */
@media (max-width: 768px) {
    .jk-content {
        padding: 1rem;
    }

    .jk-topbar {
        padding: 0.75rem 1rem;
    }

    .jk-split {
        grid-template-columns: 1fr;
    }

    .jk-category-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .jk-table-wrapper {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .jk-table th,
    .jk-table td {
        padding: 0.5rem 0.625rem;
        font-size: 0.8125rem;
    }

    .jk-table th {
        font-size: 0.6875rem;
    }

    .jk-topbar-title {
        font-size: 1rem;
        max-width: 180px;
    }

    .jk-topbar-actions {
        gap: 0.375rem;
    }

    .jk-card-body {
        padding: 1rem;
    }

    .jk-card-header {
        padding: 1rem;
        font-size: 0.8125rem;
    }

    .jk-btn {
        padding: 0.4375rem 0.75rem;
        font-size: 0.8125rem;
    }

    .jk-btn-sm {
        padding: 0.3125rem 0.625rem;
        font-size: 0.75rem;
    }

    .jk-category-grid {
        grid-template-columns: 1fr;
    }

    /* ── Docs pages: collapse main 2-col layout to single column ── */
    #docs-pdf-root {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important;
    }
    /* All direct children stretch to full width */
    #docs-pdf-root > * {
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }
    #docs-toc-sidebar {
        position: static !important;
        top: auto !important;
        margin-bottom: 1rem;
        order: -1;
    }
    /* Hide desktop TOC card-header — mobile button replaces it */
    #docs-toc-sidebar > .jk-card-header {
        display: none !important;
    }
    /* TOC nav body: hidden when collapsed, scrollable when open */
    #docs-toc-sidebar > .jk-card-body {
        max-height: 55vh;
        overflow-y: auto;
    }
    #docs-toc-sidebar.toc-collapsed > .jk-card-body {
        display: none !important;
    }
    /* Inner grids collapse to 1 column */
    .docs-hero {
        padding: 1.25rem !important;
    }
    .docs-grid-2,
    .docs-grid-3 {
        grid-template-columns: 1fr !important;
    }
}

/* --- Extra small screens (very small phones) --- */
@media (max-width: 480px) {
    .jk-content {
        padding: 0.75rem;
    }

    .jk-topbar {
        padding: 0.625rem 0.75rem;
    }

    .jk-topbar-title {
        font-size: 0.875rem;
        max-width: 140px;
    }

    /* Docs: hide PDF button text label — keep only icon */
    #pdf-btn .lang-id,
    #pdf-btn .lang-en {
        display: none !important;
    }

    /* Docs: reduce hero padding further */
    .docs-hero {
        padding: 1rem !important;
    }

    .jk-table th,
    .jk-table td {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .jk-table th {
        font-size: 0.625rem;
        letter-spacing: 0.02em;
    }

    .jk-table-link {
        font-size: 0.6875rem;
    }

    /* --- Ultra-compact chat header --- */
    .jk-chat-panel__header {
        padding: 0.375rem 0.5rem;
        gap: 0.25rem;
    }

    .jk-escalate-select-bar {
        margin: 4px -0.5rem -0.375rem;
        padding: 6px 8px;
        gap: 4px;
        flex-wrap: wrap;
        min-height: unset;
    }

    .jk-escalate-select-bar span[style*="font-size:13px"] {
        font-size: 11px !important;
    }

    .jk-chat-panel__header-avatar {
        width: 24px;
        height: 24px;
        font-size: 0.6875rem;
    }

    .jk-chat-panel__header-name {
        font-size: 0.75rem;
    }

    .jk-chat-panel__header-meta {
        font-size: 0.5625rem;
    }

    /* --- Ultra-compact bubbles --- */
    .jk-msg__bubble {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
        line-height: 1.4;
        border-radius: 8px;
    }

    .jk-msg__name {
        font-size: 0.5625rem;
    }

    .jk-msg__time {
        font-size: 0.5rem;
    }

    .jk-msg__badge {
        font-size: 0.4375rem;
        padding: 0 0.1875rem;
    }

    .jk-msg__file {
        font-size: 0.6875rem;
        padding: 0.1875rem 0.375rem;
    }

    .jk-msg__file small {
        font-size: 0.5625rem;
    }

    .jk-msg__audio-player {
        max-width: 240px;
    }

    .jk-msg__audio-icon {
        width: 26px;
        height: 26px;
    }

    .jk-msg__audio-icon svg {
        width: 14px;
        height: 14px;
    }

    .jk-msg__audio-control {
        height: 30px;
    }

    .jk-msg__img-thumb {
        width: 80px;
        height: 80px;
    }

    .jk-chat-panel__body {
        max-height: 50vh;
        min-height: 200px;
    }

    /* --- Ultra-compact reply bar --- */
    .jk-chat-panel__footer {
        padding: 0.5rem 0.625rem;
    }

    .jk-reply-bar__input {
        font-size: 0.8125rem;
        padding: 0.5rem 0.75rem;
        border-radius: 18px;
    }

    .jk-reply-bar__send {
        width: 36px;
        height: 36px;
    }

    .jk-reply-bar__mic {
        width: 36px;
        height: 36px;
    }

    .jk-reply-bar__attach {
        width: 36px;
        height: 36px;
    }

    .jk-card-body {
        padding: 0.75rem;
    }

    .jk-card-header {
        padding: 0.75rem;
        font-size: 0.75rem;
    }
}

/* =============================================================
   CASE DETAIL — MOBILE RESPONSIVE
   ============================================================= */

@media (max-width: 768px) {
    /* --- Ticket Header Card --- */
    .jk-detail-header .jk-card-body {
        padding: 0.75rem !important;
    }

    /* Compact status & source badges */
    .jk-detail-badges > div {
        padding: 0.25rem 0.625rem !important;
        font-size: 0.6875rem !important;
        gap: 0.25rem !important;
    }

    .jk-detail-badges > div svg {
        width: 0.875rem;
        height: 0.875rem;
    }

    /* Meta row: stack vertically on mobile */
    .jk-detail-meta {
        flex-direction: column;
        gap: 0.25rem !important;
    }

    .jk-detail-meta > div {
        display: flex;
        justify-content: space-between;
        width: 100%;
        padding: 0.125rem 0;
        border-bottom: 1px solid #f1f5f9;
    }

    .jk-detail-meta > div:last-child {
        border-bottom: none;
    }

    /* Subject title smaller */
    .jk-detail-subject {
        font-size: 1rem !important;
    }

    /* Requester info line */
    .jk-detail-requester {
        font-size: 0.75rem !important;
    }

    /* Chat panel header buttons compact */
    .jk-chat-panel__header .jk-btn-sm {
        padding: 0.1875rem 0.375rem;
        font-size: 0.625rem;
    }

    .jk-chat-panel__header .jk-btn-sm svg {
        width: 0.75rem;
        height: 0.75rem;
        margin-right: 0.125rem;
    }

    /* Split panel gap reduction */
    .jk-split {
        gap: 0.75rem;
    }

    /* RCA form compact */
    .jk-rca-section .jk-form-group {
        margin-bottom: 0.75rem;
    }

    .jk-rca-section .jk-label {
        font-size: 0.75rem;
    }

    .jk-rca-section .jk-textarea {
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    /* Even tighter on very small screens */
    .jk-detail-header .jk-card-body {
        padding: 0.5rem !important;
    }

    .jk-detail-subject {
        font-size: 0.875rem !important;
        line-height: 1.3;
    }

    .jk-detail-requester {
        font-size: 0.6875rem !important;
    }

    .jk-detail-badges .jk-badge-pill {
        padding: 0.1875rem 0.5rem;
        font-size: 0.625rem;
    }

    .jk-detail-meta {
        font-size: 0.625rem !important;
    }

    /* Chat header even more compact */
    .jk-chat-panel__header .jk-btn-sm {
        padding: 0.125rem 0.25rem;
        font-size: 0.5625rem;
    }
}

/* ===================================================================
   Case List — Mobile Card Layout
   On screens ≤ 768px the table rows become stacked cards.
   =================================================================== */

@media (max-width: 768px) {
    /* Table wrapper — remove border so cards float freely */
    .jk-case-list-wrapper {
        border: none;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    /* Remove min-width so table doesn't force horizontal scroll */
    .jk-case-list-table {
        min-width: 0 !important;
        display: block;
    }

    .jk-case-list-table thead {
        display: none;
    }

    .jk-case-list-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .jk-case-list-table tbody tr {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto auto auto auto;
        gap: 0.125rem 0.5rem;
        padding: 0.625rem 0.75rem;
        border-radius: 0.75rem;
        border: 1px solid #e2e8f0;
        background: #fff;
        position: relative;
    }

    .jk-case-list-table tbody tr.bg-rose-50 {
        box-shadow: inset 0 0 0 1px rgba(244,63,94,0.15), 0 2px 8px rgba(244,63,94,0.10);
    }

    /* Hide all cells by default, then show the ones we want */
    .jk-case-list-table tbody td {
        display: none;
        padding: 0;
        border: none;
    }

    /* Row 1: checkbox + ticket# + status badge */
    .jk-case-list-table tbody td.jk-col-checkbox {
        display: flex;
        align-items: center;
        grid-row: 1;
        grid-column: 1;
    }

    .jk-case-list-table tbody td.jk-col-ticket {
        display: flex;
        align-items: center;
        grid-row: 1;
        grid-column: 2;
        font-weight: 600;
    }

    .jk-case-list-table tbody td.jk-col-status {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        grid-row: 1;
        grid-column: 3;
    }

    /* Row 2: subject spanning full width */
    .jk-case-list-table tbody td.jk-col-subject {
        display: block;
        grid-row: 2;
        grid-column: 1 / -1;
        padding-top: 0.25rem;
    }

    .jk-case-list-table tbody td.jk-col-subject a {
        max-width: 100% !important;
        font-size: 0.8125rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Row 3: requester info (name + phone/email) */
    .jk-case-list-table tbody td.jk-col-requester {
        display: flex !important;
        align-items: center;
        gap: 0.375rem;
        grid-row: 3;
        grid-column: 1 / -1;
        padding-top: 0.25rem;
        font-size: 0.75rem;
        color: #475569;
        overflow: hidden;
        min-width: 0;
    }

    .jk-col-requester__name {
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 45%;
        flex-shrink: 1;
        min-width: 0;
    }

    .jk-col-requester__contact {
        color: #64748b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 45%;
        flex-shrink: 1;
        min-width: 0;
    }

    .jk-col-requester__contact::before {
        content: "•";
        margin-right: 0.375rem;
        color: #cbd5e1;
    }

    /* Row 4: unit/company */
    .jk-col-requester__unit {
        display: none;
    }

    .jk-case-list-table tbody td.jk-col-requester .jk-col-requester__unit {
        display: block;
        grid-row: 4;
        grid-column: 1 / -1;
        font-size: 0.6875rem;
        font-weight: 500;
        color: #4f46e5;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* When unit exists, requester cell becomes a 2-line block */
    .jk-case-list-table tbody td.jk-col-requester:has(.jk-col-requester__unit) {
        flex-wrap: wrap;
    }

    .jk-case-list-table tbody td.jk-col-requester .jk-col-requester__unit {
        width: 100%;
        flex-basis: 100%;
        padding-top: 0.0625rem;
    }

    /* Row 5: source + date */
    .jk-case-list-table tbody td.jk-col-source {
        display: inline-flex !important;
        grid-row: 5;
        grid-column: 1 / 2;
        padding-top: 0.375rem;
    }

    .jk-case-list-table tbody td.jk-col-source .jk-badge {
        font-size: 0.625rem;
        padding: 0.125rem 0.375rem;
    }

    .jk-case-list-table tbody td.jk-col-created {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        grid-row: 5;
        grid-column: 2 / -1;
        padding-top: 0.375rem;
        font-size: 0.6875rem;
        color: #94a3b8;
    }

    .jk-case-list-table tbody td.jk-col-created br {
        display: none;
    }

    .jk-case-list-table tbody td.jk-col-created span {
        margin-left: 0.25rem;
    }

    /* Badges inside cards */
    .jk-case-list-table .jk-badge {
        font-size: 0.6875rem;
        padding: 0.125rem 0.5rem;
    }

    /* Status filter bar — smaller pills on mobile */
    .jk-status-filter-bar {
        gap: 0.375rem !important;
    }

    .jk-status-filter-bar button {
        padding: 0.25rem 0.625rem;
        font-size: 0.6875rem;
    }

    /* Pagination compact */
    .jk-case-list-table + .px-6 {
        padding: 0.75rem;
    }

    /* Live indicator — smaller on mobile */
    #live-indicator {
        bottom: 10px !important;
        right: 10px !important;
        padding: 4px 10px !important;
        font-size: 10px !important;
        border-radius: 8px !important;
    }

    /* Bulk action bar — compact on mobile */
    .jk-bulk-bar {
        left: 0.5rem !important;
        right: 0.5rem !important;
        transform: none !important;
        width: auto !important;
        border-radius: 1rem;
        font-size: 0.75rem;
    }

    .jk-bulk-bar .px-5 {
        padding: 0.5rem 0.75rem;
    }

    .jk-bulk-bar .px-4 {
        padding: 0.5rem 0.625rem;
    }
}

/* =============================================================
   CONFIDENTIAL TICKET STYLES
   ============================================================= */

/* Masked confidential row in table */
.jk-confidential-masked {
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 8px,
        rgba(245, 158, 11, 0.03) 8px,
        rgba(245, 158, 11, 0.03) 16px
    );
}

.jk-confidential-masked td {
    user-select: none;
}

/* Confidential management panel in case detail */
.jk-confidential-panel {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
    border-radius: var(--jk-radius);
    padding: 1rem 1.25rem;
}

.jk-confidential-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.jk-confidential-panel__title {
    font-weight: 600;
    font-size: 0.875rem;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.jk-confidential-panel__users {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.jk-confidential-panel__chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    background: #ffffff;
    border: 1px solid #fbbf24;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #78350f;
}

.jk-confidential-panel__chip button {
    color: #dc2626;
    font-size: 0.625rem;
    line-height: 1;
    padding: 0.125rem;
    border-radius: 9999px;
    transition: var(--jk-transition);
}

.jk-confidential-panel__chip button:hover {
    background: #fecaca;
}

/* Confidential badge */
.jk-badge-confidential {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fbbf24;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
}