/* ═══════════════════════════════════════════════════════════
   LiveChat Admin — Enterprise Theme
   ═══════════════════════════════════════════════════════════ */

/* ── Font ─────────────────────────────────────────────── */
@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url('/assets/fonts/inter-regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-style: normal; font-display: swap; src: url('/assets/fonts/inter-medium.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('/assets/fonts/inter-semibold.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-style: normal; font-display: swap; src: url('/assets/fonts/inter-bold.woff2') format('woff2'); }

/* ── Design Tokens ────────────────────────────────────── */
:root {
    --lc-primary: #6366f1;
    --lc-primary-light: #818cf8;
    --lc-primary-dark: #4f46e5;
    --lc-primary-bg: rgba(99, 102, 241, 0.08);
    --lc-nav-bg: #1e1e2d;
    --lc-nav-hover: rgba(255, 255, 255, 0.06);
    --lc-body-bg: #f1f3f9;
    --lc-card-bg: #ffffff;
    --lc-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --lc-card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
    --lc-card-radius: 12px;
    --lc-text: #1f2937;
    --lc-text-muted: #6b7280;
    --lc-border: #e5e7eb;
    --lc-success: #10b981;
    --lc-warning: #f59e0b;
    --lc-danger: #ef4444;
    --lc-info: #06b6d4;
}

/* ── Global Overrides ─────────────────────────────────── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--lc-body-bg);
    color: var(--lc-text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; }

/* ── Bootstrap Overrides ──────────────────────────────── */

/* Navbar */
.navbar {
    background: var(--lc-nav-bg) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.6rem 1rem;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.3px;
}

.navbar-nav .nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    color: rgba(255, 255, 255, 0.65);
}

.navbar-nav .nav-link:hover {
    background: var(--lc-nav-hover);
    color: #fff;
}

.navbar-nav .nav-link.active {
    background: var(--lc-primary);
    color: #fff !important;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--lc-card-radius);
    box-shadow: var(--lc-card-shadow);
    background: var(--lc-card-bg);
}

.card-header {
    background: var(--lc-card-bg);
    border-bottom: 1px solid var(--lc-border);
    font-weight: 600;
    border-radius: var(--lc-card-radius) var(--lc-card-radius) 0 0 !important;
}

.card-footer {
    background: #f9fafb;
    border-top: 1px solid var(--lc-border);
}

/* Buttons */
.btn-primary {
    background: var(--lc-primary);
    border-color: var(--lc-primary);
    border-radius: 8px;
    font-weight: 500;
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--lc-primary-dark);
    border-color: var(--lc-primary-dark);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-outline-primary {
    color: var(--lc-primary);
    border-color: var(--lc-primary);
    border-radius: 8px;
    font-weight: 500;
}

.btn-outline-primary:hover {
    background: var(--lc-primary);
    border-color: var(--lc-primary);
}

.btn-outline-secondary { border-radius: 8px; font-weight: 500; }
.btn-outline-danger { border-radius: 8px; font-weight: 500; }
.btn-outline-danger:hover { background: var(--lc-danger); border-color: var(--lc-danger); }
.btn-sm { border-radius: 6px; }

/* Tables */
.table {
    font-size: 0.875rem;
    --bs-table-hover-bg: #f8f9ff;
    --bs-table-striped-bg: transparent;
}

.table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--lc-text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--lc-border);
    padding: 0.75rem;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #f3f4f6;
}

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

/* Badges */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    border-radius: 6px;
    padding: 0.3em 0.65em;
}

.badge.bg-primary { background: var(--lc-primary) !important; }
.badge.bg-success { background: var(--lc-success) !important; }
.badge.bg-warning { background: var(--lc-warning) !important; color: #fff !important; }
.badge.bg-danger { background: var(--lc-danger) !important; }

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--lc-border);
    font-size: 0.875rem;
    padding: 0.5rem 0.85rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--lc-primary-light);
    box-shadow: 0 0 0 3px var(--lc-primary-bg);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--lc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Alerts */
.alert { border-radius: var(--lc-card-radius); border: none; font-size: 0.875rem; }
.alert-success { background: rgba(16, 185, 129, 0.1); color: #065f46; }
.alert-warning { background: rgba(245, 158, 11, 0.1); color: #92400e; }
.alert-danger { background: rgba(239, 68, 68, 0.1); color: #991b1b; }

/* Dropdown */
.dropdown-menu {
    border: none;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    font-size: 0.875rem;
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.45rem 0.85rem;
    font-weight: 500;
}

.dropdown-menu-dark {
    background: var(--lc-nav-bg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.dropdown-menu-dark .dropdown-item { color: rgba(255,255,255,0.7); }
.dropdown-menu-dark .dropdown-item:hover { background: var(--lc-nav-hover); color: #fff; }
.dropdown-menu-dark .dropdown-item.active { background: var(--lc-primary); color: #fff; }

/* Offcanvas */
.offcanvas {
    border: none !important;
}

/* Toast / Snackbar */
.toast { border-radius: 10px; }

/* ═══════════════════════════════════════════════════════════
   LiveChat Custom Components
   ═══════════════════════════════════════════════════════════ */

/* ── Console Layout ───────────────────────────────────── */
.lc-console {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: calc(100vh - 100px);
    gap: 0;
    border-radius: var(--lc-card-radius);
    overflow: hidden;
    box-shadow: var(--lc-card-shadow);
    background: var(--lc-card-bg);
}

@media (min-width: 992px) {
    .lc-console {
        grid-template-columns: 300px 1fr;
        grid-template-rows: 1fr;
    }
}

.lc-console-sidebar {
    border-right: 1px solid var(--lc-border);
    background: #fafbfc;
}

@media (min-width: 992px) {
    .lc-console-sidebar {
        overflow-y: auto;
    }
}

.lc-console-sidebar .offcanvas-body {
    display: block;
}

.lc-console-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--lc-card-bg);
}

/* ── Chat List ────────────────────────────────────────── */
.lc-chat-list-section {
    padding: 12px;
}

.lc-chat-list-section h6 {
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    color: var(--lc-text-muted);
}

.lc-chat-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 2px;
    transition: all 0.15s;
}

.lc-chat-item:hover {
    background: #eef0f5;
}

.lc-chat-item.active {
    background: var(--lc-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.lc-chat-item.active .lc-chat-meta {
    color: rgba(255, 255, 255, 0.7);
}

.lc-chat-item.active .lc-status-pending,
.lc-chat-item.active .lc-status-active {
    background: rgba(255, 255, 255, 0.2);
}

.lc-chat-item-unread strong {
    font-weight: 700;
}

.lc-unread-badge {
    background: var(--lc-danger);
    color: #fff !important;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    vertical-align: middle;
}

.lc-chat-meta {
    font-size: 12px;
    color: var(--lc-text-muted);
    margin-top: 2px;
}

/* ── Chat Messages ────────────────────────────────────── */
.lc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fc;
}

.lc-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 80%;
}

.lc-message-row-visitor { align-self: flex-start; }
.lc-message-row-operator { align-self: flex-end; }

.lc-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--lc-primary);
}

.lc-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lc-msg-avatar-visitor {
    background: #d1d5db;
    color: #6b7280;
    font-size: 1rem;
}

.lc-message {
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 0.9rem;
}

.lc-message-visitor {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #eee;
    border-bottom-left-radius: 4px;
}

.lc-message-operator {
    align-self: flex-end;
    background: var(--lc-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.lc-message-system {
    align-self: center;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #e0e7ff;
    text-align: center;
    max-width: 85%;
}

.lc-message-system .lc-message-time {
    color: #6366f1;
    opacity: 0.65;
    margin-top: 4px;
}

.lc-message-time {
    font-size: 0.68rem;
    opacity: 0.6;
    margin-top: 4px;
}

.lc-message-emoji {
    font-size: 44px;
    line-height: 1.1;
    background: transparent !important;
    border: none !important;
    padding: 4px 0;
}

/* ── Chat Detail (History) ────────────────────────────── */
.lc-chat-detail {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 90px);
}

.lc-chat-detail-body {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--lc-border);
    border-radius: var(--lc-card-radius);
    overflow: hidden;
    display: flex;
}

.lc-chat-detail-body > [class*="col-"] {
    display: flex;
    flex-direction: column;
}

.lc-chat-detail-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    background: #f8f9fc;
}

.lc-chat-detail-messages .lc-message-visitor {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #eee;
    color: var(--lc-text);
    border-bottom-left-radius: 4px;
}

.lc-chat-detail-messages .lc-message-operator {
    align-self: flex-end;
    background: var(--lc-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.lc-chat-detail-messages .lc-message-system {
    align-self: center;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #e0e7ff;
    text-align: center;
    max-width: 85%;
}

.lc-message-system .lc-message-time {
    color: #6366f1;
    opacity: 0.65;
    margin-top: 4px;
}

.lc-chat-detail-sidebar {
    overflow-y: auto;
    padding: 15px;
    background: #fafbfc;
    height: 100%;
}

/* ── Emoji Picker ─────────────────────────────────────── */
.lc-emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 320px;
    max-height: 280px;
    background: var(--lc-card-bg);
    border: 1px solid var(--lc-border);
    border-radius: var(--lc-card-radius);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 6px;
}

.lc-emoji-tabs {
    display: flex;
    border-bottom: 1px solid var(--lc-border);
    padding: 4px 4px 0;
    gap: 2px;
    flex-shrink: 0;
}

.lc-emoji-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 6px 2px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: background 0.15s;
}

.lc-emoji-tab:hover { background: #f5f5f5; }
.lc-emoji-tab.active { border-bottom-color: var(--lc-primary); background: var(--lc-primary-bg); }

.lc-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}

.lc-emoji-item {
    background: none;
    border: none;
    font-size: 22px;
    padding: 4px;
    cursor: pointer;
    border-radius: 6px;
    line-height: 1;
    text-align: center;
    transition: background 0.1s;
}

.lc-emoji-item:hover { background: #f0f0f0; }

.lc-emoji-trigger {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 4px 6px;
    opacity: 0.5;
    transition: opacity 0.15s;
    line-height: 1;
}

.lc-emoji-trigger:hover { opacity: 1; }

/* ── Typing Indicator ─────────────────────────────────── */
.lc-typing-indicator {
    padding: 6px 20px;
    font-size: 0.8rem;
    color: var(--lc-text-muted);
    font-style: italic;
    background: #f8f9fc;
}

.lc-typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-right: 6px;
    vertical-align: middle;
}

.lc-typing-dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: lc-dot-bounce 1.4s infinite ease-in-out;
}

.lc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.lc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lc-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Chat Input ───────────────────────────────────────── */
.lc-input-area {
    border-top: 1px solid var(--lc-border);
    padding: 15px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--lc-card-bg);
}

.lc-input-area textarea {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 120px;
}

/* ── Empty State ──────────────────────────────────────── */
.lc-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--lc-text-muted);
    font-size: 1rem;
}

.lc-empty-state i { color: var(--lc-primary-light); }

/* ── Status Badges ────────────────────────────────────── */
.lc-status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
}

.lc-status-active {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
}

.lc-status-closed {
    background: rgba(107, 114, 128, 0.15);
    color: #4b5563;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ── Icon Picker ──────────────────────────────────────── */
.lc-icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lc-icon-option {
    cursor: pointer;
    width: 56px;
    height: 56px;
    border: 2px solid var(--lc-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lc-text-muted);
    background: #fff;
    transition: all 0.15s;
}

.lc-icon-option:hover {
    border-color: var(--lc-primary-light);
    color: var(--lc-primary);
}

.lc-icon-option input {
    display: none;
}

.lc-icon-option.active {
    border-color: var(--lc-primary);
    background: var(--lc-primary-bg);
    color: var(--lc-primary);
}

.lc-icon-option-svg {
    display: inline-flex;
    width: 24px;
    height: 24px;
}

.lc-icon-option-svg svg {
    width: 100%;
    height: 100%;
}

/* ── Avatar ───────────────────────────────────────────── */
.lc-avatar,
img.lc-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    object-fit: cover;
    color: #fff;
    font-weight: 600;
    vertical-align: middle;
    flex-shrink: 0;
    overflow: hidden;
    text-transform: uppercase;
    line-height: 1;
}

.lc-avatar-initials {
    letter-spacing: 0;
}

.lc-avatar-preview {
    flex-shrink: 0;
    width: 96px;
    height: 96px;
}

.lc-avatar-dropzone {
    border: 2px dashed var(--lc-border);
    border-radius: var(--lc-card-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: #fafbfc;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.lc-avatar-dropzone:hover {
    border-color: var(--lc-primary-light);
    background: var(--lc-primary-bg);
}

.lc-avatar-dropzone.dragover {
    border-color: var(--lc-primary);
    background: var(--lc-primary-bg);
    transform: scale(1.01);
}

.lc-avatar-dropzone-content {
    color: var(--lc-text-muted);
    font-size: 0.875rem;
    pointer-events: none;
}

.lc-avatar-dropzone-icon {
    font-size: 2rem;
    color: var(--lc-primary-light);
    display: block;
    margin-bottom: 4px;
}

/* ── Online Indicator ─────────────────────────────────── */
.lc-online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--lc-success);
    margin-right: 4px;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.lc-offline-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    margin-right: 4px;
}

/* ── Canned Responses ─────────────────────────────────── */
.lc-canned-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--lc-card-bg);
    border: 1px solid var(--lc-border);
    border-radius: 10px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    display: none;
    z-index: 100;
}

.lc-canned-dropdown.visible { display: block; }

.lc-canned-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.875rem;
}

.lc-canned-item:hover { background: var(--lc-primary-bg); }

.lc-canned-shortcut {
    font-weight: 600;
    color: var(--lc-primary);
    margin-right: 8px;
}

/* ── Pending Blink ────────────────────────────────────── */
.lc-chat-item[data-status="pending"] {
    animation: lc-pending-blink 1.5s ease-in-out infinite;
    border: 2px solid transparent;
}

@keyframes lc-pending-blink {
    0%, 100% { border-color: transparent; }
    50% { border-color: var(--lc-warning); }
}

/* ── Dashboard Stats ──────────────────────────────────── */
.lc-stat-card {
    text-align: center;
    padding: 24px 16px;
}

.lc-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--lc-primary);
    letter-spacing: -0.5px;
}

.lc-stat-label {
    font-size: 0.75rem;
    color: var(--lc-text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.lc-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 1.1rem;
}

/* ── Mobile Toolbar ───────────────────────────────────── */
.lc-mobile-toolbar {
    display: none;
}

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */

/* ── Mobile + Tablet Portrait (< 992px) ──────────────── */
@media (max-width: 991.98px) {
    .lc-console {
        height: calc(100vh - 56px - 1rem);
        border-radius: 0;
        box-shadow: none;
    }

    @supports (height: 100dvh) {
        .lc-console {
            height: calc(100dvh - 56px - 1rem);
        }
    }

    .lc-mobile-toolbar {
        display: flex;
        align-items: center;
        padding: 8px 12px;
        border-bottom: 1px solid var(--lc-border);
        background: #fafbfc;
        min-height: 44px;
    }

    .lc-console-main {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .lc-console-sidebar {
        border-right: none;
        width: 300px;
    }

    .lc-message { max-width: 85%; }

    .lc-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 12px;
    }

    .lc-input-area {
        flex-shrink: 0;
        padding: 8px 10px;
        gap: 6px;
    }

    .lc-input-area textarea { font-size: 16px; }
    .lc-input-area .btn { min-width: 44px; min-height: 44px; }

    .lc-emoji-picker {
        width: calc(100vw - 20px);
        max-width: 355px;
        left: 50%;
        transform: translateX(-50%);
    }

    .lc-emoji-grid { grid-template-columns: repeat(7, 1fr); }
    .lc-emoji-item { min-width: 44px; min-height: 44px; }
    .lc-chat-item { padding: 14px 12px; }
}

/* ── Phone only (< 768px) ────────────────────────────── */
@media (max-width: 767.98px) {
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }
}
