/* =============================================================
   Admin Portal — Premium Dark Glassmorphism Theme
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-input: rgba(255, 255, 255, 0.06);
    --bg-sidebar: rgba(10, 10, 30, 0.95);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(108, 92, 231, 0.5);
    --text-primary: #f0f0f5;
    --text-secondary: #8888a8;
    --text-muted: #5a5a7a;
    --accent: #6C5CE7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.25);
    --success: #00d28c;
    --success-bg: rgba(0, 210, 140, 0.12);
    --warning: #ffc048;
    --warning-bg: rgba(255, 192, 72, 0.12);
    --danger: #ff4757;
    --danger-bg: rgba(255, 71, 87, 0.12);
    --info: #54a0ff;
    --info-bg: rgba(84, 160, 255, 0.12);
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: #fff; }

/* ── Layout ── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    backdrop-filter: blur(20px);
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.sidebar-brand h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-brand small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav .nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 12px 16px 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.sidebar-nav a:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: var(--accent-glow);
    color: var(--accent-light);
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-nav a .icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: default;
}

.sidebar-footer .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #e056a0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
}

.sidebar-footer .user-meta { flex: 1; overflow: hidden; }
.sidebar-footer .user-meta .name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-meta .role { font-size: 0.7rem; color: var(--text-muted); }

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Top Header ── */
.top-header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: rgba(10, 10, 26, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.top-header .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
}

/* ── Page Container ── */
.page-content {
    flex: 1;
    padding: 28px 32px;
    animation: pageIn 0.4s ease;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Stats Cards Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover { background: var(--bg-card-hover); border-color: var(--border-active); }
.stat-card:hover::before { opacity: 1; }

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Card Component ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    transition: all var(--transition);
}

.card:hover { border-color: rgba(255,255,255,0.12); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); color: #fff; }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(255,71,87,0.2); }
.btn-danger:hover { background: rgba(255,71,87,0.2); }

.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(0,210,140,0.2); }
.btn-success:hover { background: rgba(0,210,140,0.2); }

.btn-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(255,192,72,0.2); }
.btn-warning:hover { background: rgba(255,192,72,0.2); }

.btn-sm { padding: 6px 14px; font-size: 0.78rem; }
.btn-lg { padding: 14px 28px; font-size: 0.95rem; }

/* ── Form Elements ── */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 11px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: all var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255,255,255,0.08);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 100px; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238888a8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* ── Tables ── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }

td .keyword-text { color: var(--text-primary); font-weight: 600; }
td .reply-preview { color: var(--text-secondary); max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

.table-actions {
    display: flex;
    gap: 6px;
}

/* ── Status Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active { background: var(--success-bg); color: var(--success); }
.badge-waiting { background: var(--warning-bg); color: var(--warning); }
.badge-with-agent { background: var(--info-bg); color: var(--info); }
.badge-closed { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-active .badge-dot { background: var(--success); }
.badge-waiting .badge-dot { background: var(--warning); animation: pulse 1.5s infinite; }
.badge-with-agent .badge-dot { background: var(--info); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 { font-size: 1rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 20px;
    min-width: 280px;
    box-shadow: var(--shadow);
    animation: toastIn 0.35s ease, toastOut 0.3s ease 3.7s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Live Chat Layout & Fixed Scrollbar UX ── */
.chat-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 0;
    height: calc(100vh - var(--header-height) - 56px);
    min-height: 520px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
}

.chat-sessions-panel {
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.015);
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.chat-sessions-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-sessions-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.chat-sessions-list {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.chat-sessions-list::-webkit-scrollbar,
.chat-messages-area::-webkit-scrollbar {
    width: 6px;
}

.chat-sessions-list::-webkit-scrollbar-track,
.chat-messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-sessions-list::-webkit-scrollbar-thumb,
.chat-messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.chat-sessions-list::-webkit-scrollbar-thumb:hover,
.chat-messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.session-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.session-item:hover { background: var(--bg-card-hover); }
.session-item.active { background: var(--accent-glow); border-left-color: var(--accent); }

.session-item .session-name { font-weight: 600; font-size: 0.88rem; color: var(--text-primary); margin-bottom: 4px; }
.session-item .session-preview { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .session-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

.chat-conversation-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

#conversation-panel {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-conv-header {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
    z-index: 5;
}

.chat-conv-header .visitor-info h4 { font-size: 1rem; font-weight: 700; color: #ffffff; }
.chat-conv-header .visitor-info small { color: var(--text-muted); font-size: 0.78rem; display: flex; align-items: center; gap: 6px; margin-top: 2px; }

.chat-messages-area {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
    scroll-behavior: smooth;
    background: radial-gradient(circle at 50% 50%, rgba(108, 92, 231, 0.03) 0%, transparent 80%);
}

.chat-msg {
    max-width: 72%;
    display: flex;
    flex-direction: column;
    animation: msgIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-msg.visitor {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg.agent {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg.bot {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg .msg-sender-tag {
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 4px;
}

.chat-msg.visitor .msg-sender-tag { color: var(--info); }
.chat-msg.agent .msg-sender-tag { color: var(--accent-light); justify-content: flex-end; }
.chat-msg.bot .msg-sender-tag { color: var(--text-muted); }

.chat-msg .msg-bubble {
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.6;
    word-break: break-word;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.15px;
}

.chat-msg.visitor .msg-bubble {
    background: rgba(84, 160, 255, 0.12);
    border: 1px solid rgba(84, 160, 255, 0.25);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-msg.agent .msg-bubble {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.chat-msg.bot .msg-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-bottom-left-radius: 4px;
    font-style: normal;
}

.chat-msg .msg-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 5px;
    padding: 0 6px;
}

.chat-msg.agent .msg-meta {
    text-align: right;
}

.chat-input-bar {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    z-index: 10;
}

.chat-input-bar input {
    flex: 1;
    padding: 14px 20px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.92rem;
    line-height: 1.4;
    outline: none;
    transition: all var(--transition);
}

.chat-input-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255, 255, 255, 0.08);
}

.no-session-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 12px;
    height: 100%;
}

.no-session-selected .icon { font-size: 3.5rem; opacity: 0.35; }
.no-session-selected p { font-size: 0.95rem; font-weight: 500; }

/* ── Copy Box (API Key / Embed) ── */
.copy-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

.copy-box code {
    flex: 1;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    color: var(--accent-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: all;
}

.copy-box .btn-copy {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font);
}
.copy-box .btn-copy:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ── Color Picker ── */
.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker-wrap input[type="color"] {
    width: 42px;
    height: 42px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    padding: 2px;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; margin-bottom: 16px; }

/* ── Login & Register Pages ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    padding: 20px;
}

.auth-card {
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: pageIn 0.5s ease;
}

.auth-card .auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-card .auth-logo .logo-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
}

.auth-card .auth-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-card .auth-logo p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

.auth-card .form-group { margin-bottom: 16px; }

.auth-card .form-control {
    padding: 13px 16px;
}

.auth-card .btn-primary {
    width: 100%;
    padding: 13px;
    font-size: 0.95rem;
    justify-content: center;
}

.auth-card .auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-card .auth-footer a { color: var(--accent-light); font-weight: 500; }

.auth-card .error-msg {
    background: var(--danger-bg);
    border: 1px solid rgba(255,71,87,0.2);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    text-align: center;
}

/* ── Search Box ── */
.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 38px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: all var(--transition);
}

.search-box input:focus { border-color: var(--accent); }

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

/* ── Mobile Back Button ── */
.mobile-back-btn {
    display: none;
}

/* ── Responsive Overhaul ── */
@media (max-width: 1024px) {
    .chat-layout { grid-template-columns: 260px 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .page-content { padding: 14px 12px; }
    
    .top-header {
        height: auto;
        min-height: 56px;
        padding: 10px 14px;
        gap: 8px;
        flex-wrap: wrap;
    }
    .top-header h1 {
        font-size: 1.15rem;
    }

    /* Full-screen tabbed mobile chat layout */
    .mobile-back-btn {
        display: inline-flex !important;
    }
    .chat-layout {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 120px);
        min-height: 520px;
        position: relative;
        overflow: hidden;
        border-radius: var(--radius);
    }
    .chat-sessions-panel {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-right: none;
        display: flex;
        flex-direction: column;
    }
    .chat-conversation-panel {
        display: none !important;
        width: 100% !important;
        height: 100% !important;
    }
    .chat-layout.in-conversation .chat-sessions-panel {
        display: none !important;
    }
    .chat-layout.in-conversation .chat-conversation-panel {
        display: flex !important;
    }
    
    .chat-conv-header {
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: wrap;
    }
    .chat-conv-header .visitor-info h4 {
        font-size: 0.95rem;
    }
    .chat-messages-area {
        padding: 14px 10px;
        gap: 12px;
    }
    .chat-msg {
        max-width: 88%;
    }
    .chat-msg .msg-bubble {
        padding: 10px 14px;
        font-size: 0.88rem;
    }
    .chat-input-bar {
        padding: 10px 12px;
        gap: 8px;
    }
    .chat-input-bar input {
        padding: 10px 12px;
        font-size: 0.88rem;
    }
    .chat-input-bar button {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .form-row { flex-direction: column; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 24px 16px; }
    .chat-conv-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
