/* ============================================
   ChatFlow SaaS - Main Stylesheet
   Purple + White + Green + Orange Theme
   ============================================ */

:root {
    --primary: #7C3AED;
    --primary-light: #8B5CF6;
    --primary-dark: #6D28D9;
    --primary-bg: #F5F3FF;
    --primary-border: #DDD6FE;

    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F97316;
    --warning-light: #FED7AA;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #3B82F6;
    --info-light: #DBEAFE;

    --sidebar-width: 260px;
    --sidebar-bg: #1E1B4B;
    --sidebar-text: rgba(255,255,255,0.75);
    --sidebar-active: #7C3AED;
    --sidebar-hover: rgba(255,255,255,0.08);

    --bg: #F8F7FF;
    --card-bg: #FFFFFF;
    --text-primary: #1E1B4B;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;

    --shadow-sm: 0 1px 3px rgba(124,58,237,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 6px rgba(124,58,237,0.07), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 25px rgba(124,58,237,0.1), 0 4px 10px rgba(0,0,0,0.06);
    --shadow-lg: 0 20px 40px rgba(124,58,237,0.15), 0 8px 16px rgba(0,0,0,0.08);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
.dark-mode {
    --bg: #0F0E1A;
    --card-bg: #1A1830;
    --text-primary: #F1F0FF;
    --text-secondary: #A0A0C0;
    --border: #2D2B50;
    --border-light: #252340;
    --sidebar-bg: #0D0C1A;
}

/* ============ BASE ============ */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ============ LAYOUT ============ */
.admin-layout, .tenant-layout {
    display: flex;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: var(--transition-slow);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    min-height: 72px;
    overflow: hidden;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(124,58,237,0.4);
}

.brand-name {
    color: white;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    white-space: nowrap;
    transition: var(--transition);
}

.brand-badge {
    background: linear-gradient(135deg, var(--primary), #A855F7);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
    letter-spacing: 1px;
    white-space: nowrap;
}

.tenant-badge {
    background: linear-gradient(135deg, var(--success), #34D399);
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .brand-badge,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .admin-info {
    display: none;
}

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

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.3);
    padding: 14px 10px 6px;
    white-space: nowrap;
    transition: var(--transition);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
    transform: translateX(2px);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(124,58,237,0.4);
}

.nav-item.active i { color: white; }

.nav-badge {
    margin-left: auto;
    background: var(--warning);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.live-badge {
    background: var(--success);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.sidebar-footer {
    padding: 16px 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 70px;
    overflow: hidden;
}

.admin-avatar, .tenant-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 15px;
    flex-shrink: 0;
}

.tenant-avatar {
    background: linear-gradient(135deg, var(--success), #34D399);
}

.admin-info { overflow: hidden; }

.admin-name {
    color: white;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-role {
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    white-space: nowrap;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: var(--transition-slow);
    background: var(--bg);
}

.main-content.expanded {
    margin-left: 72px;
}

/* ============ TOP NAVBAR ============ */
.top-navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.sidebar-toggle {
    background: none;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

.sidebar-toggle:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.navbar-breadcrumb {
    flex: 1;
    font-size: 14px;
    color: var(--text-secondary);
}

.navbar-breadcrumb span { color: var(--text-primary); font-weight: 600; }
.navbar-breadcrumb .separator { margin: 0 8px; color: var(--text-muted); }

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-btn {
    background: none;
    border: 1px solid var(--border);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    position: relative;
}

.navbar-btn:hover {
    background: var(--primary-bg);
    border-color: var(--primary-border);
    color: var(--primary);
}

.notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--card-bg);
}

.avatar-sm {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.avatar-sm:hover { transform: scale(1.05); }

.online-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse-online 2s infinite;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); animation: none; }

@keyframes pulse-online {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

/* ============ PAGE CONTENT ============ */
.page-content {
    padding: 28px;
    max-width: 1600px;
}

/* ============ PAGE HEADER ============ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header-left h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 4px;
    letter-spacing: -0.5px;
}

.page-header-left p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 14px;
}

.page-header-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* ============ CARDS ============ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.card-body { padding: 20px; }

/* ============ STAT CARDS ============ */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-slow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.purple::before { background: linear-gradient(90deg, var(--primary), #A855F7); }
.stat-card.green::before { background: linear-gradient(90deg, var(--success), #34D399); }
.stat-card.orange::before { background: linear-gradient(90deg, var(--warning), #FBBF24); }
.stat-card.blue::before { background: linear-gradient(90deg, var(--info), #60A5FA); }

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.stat-icon.purple { background: var(--primary-bg); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.blue { background: var(--info-light); color: var(--info); }

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

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    margin-top: 10px;
}

.stat-change.up { background: var(--success-light); color: var(--success); }
.stat-change.down { background: var(--danger-light); color: var(--danger); }

/* ============ BUTTONS ============ */
.btn {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 13px;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #A855F7);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(124,58,237,0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    box-shadow: 0 6px 16px rgba(124,58,237,0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #34D399);
    color: white;
    border-color: var(--success);
    box-shadow: 0 4px 12px rgba(16,185,129,0.25);
}

.btn-success:hover { color: white; box-shadow: 0 6px 16px rgba(16,185,129,0.35); }

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #FBBF24);
    color: white;
    border-color: var(--warning);
    box-shadow: 0 4px 12px rgba(249,115,22,0.25);
}

.btn-warning:hover { color: white; }

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

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

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

.btn-outline-secondary:hover {
    background: var(--bg);
    color: var(--text-primary);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
}

/* ============ TABLE SECTION ============ */
.table-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--card-bg);
}

.table-header-left h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 2px;
    color: var(--text-primary);
}

.table-header-left p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.table-header-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.table-filter-bar {
    padding: 14px 20px;
    background: var(--border-light);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-input {
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
    padding: 0 12px;
    min-width: 180px;
    transition: var(--transition);
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.data-table thead th {
    background: var(--border-light);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--primary-bg); }

.data-table .actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 4px;
}

/* ============ BADGES ============ */
.badge {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-secondary { background: var(--border-light); color: var(--text-secondary); }

/* ============ FORMS ============ */
.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control, .form-select {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 10px 14px;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
    background: var(--card-bg);
    color: var(--text-primary);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============ ALERTS ============ */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 500;
}

.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger { background: var(--danger-light); color: var(--danger); }
.alert-warning { background: var(--warning-light); color: #B45309; }

.alert-floating {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    min-width: 320px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============ MODAL ============ */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    background: var(--card-bg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 18px 22px;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 22px; }

/* ============ CHAT SYSTEM ============ */
.chat-layout {
    display: flex;
    height: calc(100vh - 120px);
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.chat-sidebar {
    width: 320px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    flex-shrink: 0;
}

.chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-search {
    flex: 1;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    font-size: 13px;
    background: var(--bg);
    color: var(--text-primary);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.chat-item:hover { background: var(--primary-bg); }
.chat-item.active { background: var(--primary-bg); border-left: 3px solid var(--primary); }

.chat-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    position: relative;
}

.chat-item-avatar .online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid var(--card-bg);
}

.chat-item-info { flex: 1; min-width: 0; }

.chat-item-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.chat-item-time { font-size: 11px; color: var(--text-muted); }
.chat-item-badge {
    width: 18px;
    height: 18px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.chat-main-header {
    padding: 14px 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-visitor-info { display: flex; align-items: center; gap: 12px; }

.chat-visitor-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success), #34D399);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
}

.chat-visitor-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.chat-visitor-page {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.message {
    display: flex;
    gap: 10px;
    max-width: 70%;
    animation: messageIn 0.2s ease;
}

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

.message.sent { align-self: flex-end; flex-direction: row-reverse; }

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.message.received .message-avatar { background: linear-gradient(135deg, var(--success), #34D399); }
.message.sent .message-avatar { background: linear-gradient(135deg, var(--primary), #A855F7); }

.message-content { }

.message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

.message.received .message-bubble {
    background: var(--card-bg);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, var(--primary), #A855F7);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.message.received .message-time { text-align: left; }

/* Chat Input */
.chat-input-area {
    padding: 16px 20px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    border: 1px solid var(--border);
    border-radius: 21px;
    padding: 10px 16px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    resize: none;
    transition: var(--transition);
    background: var(--bg);
    color: var(--text-primary);
    overflow-y: auto;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 15px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(124,58,237,0.35);
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(124,58,237,0.45);
}

/* Chat Info Panel */
.chat-info-panel {
    width: 280px;
    border-left: 1px solid var(--border);
    background: var(--card-bg);
    overflow-y: auto;
    flex-shrink: 0;
}

.info-panel-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
}

.info-panel-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.info-row-label { color: var(--text-muted); }
.info-row-value { color: var(--text-primary); font-weight: 600; text-align: right; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }

/* ============ WIDGET EMBED ============ */
.widget-embed-box {
    background: #1E1B4B;
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
}

.widget-embed-code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #A5B4FC;
    word-break: break-all;
    margin: 0;
}

.widget-embed-code .keyword { color: #F472B6; }
.widget-embed-code .string { color: #86EFAC; }
.widget-embed-code .attr { color: #FCD34D; }

.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: white;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    transition: var(--transition);
}

.copy-btn:hover { background: rgba(255,255,255,0.2); }

/* ============ PLANS / PRICING ============ */
.plan-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    position: relative;
    transition: var(--transition-slow);
    background: var(--card-bg);
}

.plan-card.featured {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124,58,237,0.1);
}

.plan-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.plan-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary), #A855F7);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.plan-name {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.plan-price {
    font-size: 42px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -2px;
    line-height: 1;
    margin: 16px 0 4px;
}

.plan-price span {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0;
}

.plan-period {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    text-align: left;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.plan-features li:last-child { border-bottom: none; }
.plan-features li i { color: var(--success); font-size: 12px; }

/* ============ ANALYTICS CHARTS ============ */
.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
}

/* ============ LOGIN PAGE ============ */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1E1B4B 0%, #4C1D95 50%, #7C3AED 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(124,58,237,0.3) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    border-radius: 50%;
}

.auth-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16,185,129,0.2) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    border-radius: 50%;
}

.auth-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    animation: authCardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    box-shadow: 0 8px 24px rgba(124,58,237,0.4);
}

.auth-logo-text {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.auth-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 30px;
}

/* ============ WIDGET PREVIEW ============ */
.widget-preview-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
}

.widget-bubble {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(124,58,237,0.45);
    transition: var(--transition);
}

.widget-bubble:hover { transform: scale(1.1); }

.widget-chat-box {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 340px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: var(--transition-slow);
    transform-origin: bottom right;
}

.widget-chat-box.hidden {
    transform: scale(0.8);
    opacity: 0;
    pointer-events: none;
}

.widget-header {
    background: linear-gradient(135deg, var(--primary), #A855F7);
    padding: 16px 18px;
    color: white;
}

.widget-header-title { font-size: 15px; font-weight: 700; }
.widget-header-sub { font-size: 12px; opacity: 0.8; }

.widget-messages {
    height: 280px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg);
}

.widget-input-row {
    padding: 12px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.widget-input {
    flex: 1;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 0 14px;
    font-size: 13px;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.widget-send {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.widget-send:hover { transform: scale(1.1); }

/* ============ VISITOR TRACKING ============ */
.visitor-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.visitor-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); }

.visitor-avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warning), #FBBF24);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    width: 80px;
    height: 80px;
    background: var(--primary-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 32px;
    color: var(--primary);
}

.empty-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-text {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* ============ DATATABLES OVERRIDE ============ */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--card-bg);
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius-sm) !important;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
}

div.dt-buttons > .dt-button {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm) !important;
    padding: 7px 14px;
    border: 1px solid var(--border) !important;
    background: var(--card-bg) !important;
    color: var(--text-secondary) !important;
    box-shadow: none !important;
    transition: var(--transition) !important;
}

div.dt-buttons > .dt-button:hover {
    background: var(--primary-bg) !important;
    color: var(--primary) !important;
    border-color: var(--primary-border) !important;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .main-content.expanded { margin-left: 0; }
    .page-content { padding: 16px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 22px; }
    .chat-layout { flex-direction: column; height: auto; }
    .chat-sidebar { width: 100%; height: 300px; border-right: none; border-bottom: 1px solid var(--border); }
    .chat-info-panel { display: none; }
    .auth-card { padding: 28px 22px; }
    .page-header { flex-direction: column; }
    .table-header { flex-direction: column; align-items: flex-start; }
    .top-navbar { padding: 0 16px; }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
}

/* ============ SCROLLBAR GLOBAL ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-border); }

/* ============ ANIMATIONS ============ */
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.slide-up { animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.stagger > * { animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }

/* ============ TICKET STATUS ============ */
.ticket-priority-high { color: var(--danger); }
.ticket-priority-medium { color: var(--warning); }
.ticket-priority-low { color: var(--success); }

/* ============ MISC ============ */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.text-primary-color { color: var(--primary); }
.text-success-color { color: var(--success); }
.text-warning-color { color: var(--warning); }

.bg-primary-light { background: var(--primary-bg); }
.bg-success-light { background: var(--success-light); }
.bg-warning-light { background: var(--warning-light); }

.fw-800 { font-weight: 800; }
.fw-700 { font-weight: 700; }

.cursor-pointer { cursor: pointer; }
