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

/* ═══════════════════════════════════════════
   THEME SYSTEM
   ═══════════════════════════════════════════ */
html, [data-theme="light"] {
    --bg-body: #EEEEF3;
    --bg-layout: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-header: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F1F3F9;
    --bg-input: #F1F5F9;
    --bg-input-focus: #FFFFFF;
    --bg-messages: #F4F6F8;
    --bg-empty: #F8FAFC;
    --bg-modal: #FFFFFF;
    --bg-modal-overlay: rgba(15,23,42,0.55);
    --bg-form: #F8FAFC;
    --bg-qr-area: #F8FAFC;

    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-heading: #0F172A;

    --border: #E2E8F0;
    --border-hover: #CBD5E1;
    --border-focus: var(--primary, #f514b9);

    --accent: var(--primary, #f514b9);
    --accent-hover: var(--primary1, #7c0366);
    --accent-gradient: linear-gradient(135deg, var(--primary, #f514b9), var(--primary1, #7c0366));
    --accent-glow: rgba(245, 20, 185, 0.2);
    --accent-light-bg: #FDF2F8;
    --accent-light-text: #db2777;

    --msg-user-bg: linear-gradient(135deg, var(--primary, #f514b9), var(--primary1, #7c0366));
    --msg-user-text: #fff;
    --msg-user-time: rgba(255,255,255,0.7);
    --msg-user-shadow: rgba(245, 20, 185, 0.25);
    --msg-admin-bg: #FFFFFF;
    --msg-admin-text: #0F172A;
    --msg-admin-border: #E2E8F0;
    --msg-admin-time: #94A3B8;
    --msg-admin-tag: var(--primary, #f514b9);
    --msg-admin-shadow: rgba(0,0,0,0.04);

    --avatar-bg: #FDF2F8;
    --avatar-text: #db2777;
    --badge-bg: #EF4444;
    --badge-text: #fff;
    --status-on-bg: rgba(34,197,94,0.15);
    --status-on-text: #15803D;
    --status-off-bg: rgba(239,68,68,0.12);
    --status-off-text: #B91C1C;

    --del-bg: #FEF2F2;
    --del-text: #DC2626;
    --del-border: #FECACA;
    --del-hover-bg: #EF4444;

    --qr-bg: #EEF2FF;
    --qr-text: #4F46E5;
    --qr-border: #C7D2FE;

    --scroll-thumb: #CBD5E1;
    --scroll-hover: #94A3B8;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.1);
    --shadow-layout: 0 20px 50px rgba(0,0,0,0.12);

    --date-sep-bg: #E2E8F0;
    --date-sep-text: #64748B;
}

[data-theme="dark"] {
    --bg-body: #080C16;
    --bg-layout: #111827;
    --bg-sidebar: #0F1525;
    --bg-header: rgba(15,21,37,0.95);
    --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-input-focus: rgba(255,255,255,0.1);
    --bg-messages: #070B14;
    --bg-empty: #0B0F19;
    --bg-modal: #1A2035;
    --bg-modal-overlay: rgba(0,0,0,0.7);
    --bg-form: rgba(255,255,255,0.03);
    --bg-qr-area: rgba(255,255,255,0.03);

    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-heading: #F1F5F9;

    --border: rgba(255,255,255,0.07);
    --border-hover: rgba(255,255,255,0.14);
    --border-focus: #818CF8;

    --accent: #818CF8;
    --accent-hover: #6366F1;
    --accent-gradient: linear-gradient(135deg, #6366F1, #8B5CF6);
    --accent-glow: rgba(99,102,241,0.25);
    --accent-light-bg: rgba(99,102,241,0.12);
    --accent-light-text: #A5B4FC;

    --msg-user-bg: linear-gradient(135deg, #6366F1, #7C3AED);
    --msg-user-text: #fff;
    --msg-user-time: rgba(255,255,255,0.65);
    --msg-user-shadow: rgba(99,102,241,0.25);
    --msg-admin-bg: rgba(255,255,255,0.06);
    --msg-admin-text: #E2E8F0;
    --msg-admin-border: rgba(255,255,255,0.08);
    --msg-admin-time: #64748B;
    --msg-admin-tag: #A5B4FC;
    --msg-admin-shadow: rgba(0,0,0,0.2);

    --avatar-bg: rgba(99,102,241,0.15);
    --avatar-text: #A5B4FC;
    --badge-bg: #EF4444;
    --badge-text: #fff;
    --status-on-bg: rgba(34,197,94,0.15);
    --status-on-text: #4ADE80;
    --status-off-bg: rgba(239,68,68,0.12);
    --status-off-text: #F87171;

    --del-bg: rgba(239,68,68,0.08);
    --del-text: #F87171;
    --del-border: rgba(239,68,68,0.18);
    --del-hover-bg: #EF4444;

    --qr-bg: rgba(99,102,241,0.1);
    --qr-text: #A5B4FC;
    --qr-border: rgba(99,102,241,0.2);

    --scroll-thumb: rgba(255,255,255,0.08);
    --scroll-hover: rgba(255,255,255,0.16);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.5);
    --shadow-layout: 0 20px 60px rgba(0,0,0,0.7);

    --date-sep-bg: rgba(255,255,255,0.06);
    --date-sep-text: #64748B;
}

/* ═══════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════ */
.admin-body *, .admin-body *::before, .admin-body *::after,
.chat-container *, .chat-container *::before, .chat-container *::after,
.chat-widget-btn-wrapper *, .chat-widget-btn-wrapper *::before, .chat-widget-btn-wrapper *::after { box-sizing: border-box; }

body.admin-body { height: 100%; width: 100%; font-family: 'Inter', system-ui, sans-serif; overflow: hidden; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }

/* ═══════════════════════════════════════════
   CUSTOMER WIDGET (unchanged, hardcoded)
   ═══════════════════════════════════════════ */
.chat-widget-btn {
    position: fixed; bottom: 30px; right: 30px; width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #8B5CF6); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(99,102,241,0.5); transition: transform 0.3s ease; z-index: 1000; border: none;
}
.chat-widget-btn:hover { transform: scale(1.08) translateY(-4px); }
.chat-container {
    position: fixed; bottom: 105px; right: 30px; width: 380px; height: 540px;
    background: #fff; border-radius: 20px; box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    display: flex; flex-direction: column; overflow: hidden;
    opacity: 0; pointer-events: none; transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1); z-index: 999;
}
.chat-container.open { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* ═══════════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════════ */
.admin-body {
    background: var(--bg-body);
    display: flex; align-items: center; justify-content: center;
    height: 100vh; width: 100vw; padding: 16px;
    transition: background 0.3s ease;
}
.admin-layout {
    display: flex; width: 100%; max-width: 1440px; height: 100%; max-height: 920px;
    background: var(--bg-layout);
    border-radius: 20px; box-shadow: var(--shadow-layout); overflow: hidden;
    border: 1px solid var(--border);
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */
.admin-sidebar {
    width: 360px; min-width: 320px; flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: background 0.3s, border-color 0.3s;
}
.admin-header {
    padding: 16px 18px 14px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    transition: background 0.3s, border-color 0.3s;
}
.header-top {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.header-top h2 {
    font-size: 18px; font-weight: 800; color: var(--text-heading);
    display: flex; align-items: center; gap: 8px; transition: color 0.3s;
}
.header-top h2 i { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 6px; }

/* Theme toggle button */
.btn-theme {
    width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; cursor: pointer; transition: all 0.2s;
}
.btn-theme:hover { background: var(--accent-light-bg); color: var(--accent); border-color: var(--accent); }

/* Auto Reply button */
.btn-auto-reply {
    background: var(--accent-gradient); color: #fff; border: none;
    padding: 7px 14px; border-radius: 10px; cursor: pointer;
    font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px;
    box-shadow: 0 4px 10px var(--accent-glow); transition: all 0.2s;
}
.btn-auto-reply:hover { transform: translateY(-1px); box-shadow: 0 6px 16px var(--accent-glow); }

/* Search */
.conv-search-box { position: relative; margin-bottom: 10px; }
.conv-search-box input {
    width: 100%; padding: 9px 12px 9px 36px;
    border: 1px solid var(--border); border-radius: 10px;
    font-size: 13px; background: var(--bg-input); color: var(--text-primary);
    outline: none; transition: all 0.2s; font-family: inherit;
}
.conv-search-box input:focus {
    background: var(--bg-input-focus); border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.conv-search-box input::placeholder { color: var(--text-muted); }
.conv-search-box i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 13px;
}

/* Stats row */
.header-stats {
    display: flex; justify-content: space-between; align-items: center;
}
.stat-badge {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    background: var(--bg-input); padding: 4px 10px; border-radius: 8px;
}
.header-delete-actions { display: flex; gap: 4px; }
.btn-delete-compact {
    background: var(--del-bg); color: var(--del-text); border: 1px solid var(--del-border);
    padding: 4px 10px; border-radius: 8px; cursor: pointer;
    font-size: 11px; font-weight: 700; transition: all 0.2s; font-family: inherit;
}
.btn-delete-compact:hover { background: var(--del-hover-bg); color: #fff; border-color: transparent; }

/* ═══════════════════════════════════════════
   CONVERSATION LIST
   ═══════════════════════════════════════════ */
.conversation-list {
    flex: 1; overflow-y: auto; padding: 10px;
    display: flex; flex-direction: column; gap: 4px;
}
.conversation-item {
    padding: 12px; border-radius: 12px; cursor: pointer;
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-card); border: 1px solid transparent;
    transition: all 0.2s ease;
    animation: fadeIn 0.3s ease;
}
.conversation-item:hover {
    background: var(--bg-card-hover); border-color: var(--border-hover);
    transform: translateX(2px);
}
.conversation-item.active {
    background: var(--accent-gradient); border-color: transparent;
    box-shadow: 0 6px 20px var(--accent-glow);
}
.conversation-item.active .conv-id,
.conversation-item.active .conv-time,
.conversation-item.active .conv-msg,
.conversation-item.active .conv-platform { color: #fff !important; opacity: 0.95; }
.conversation-item.active .conv-avatar { background: rgba(255,255,255,0.2); color: #fff; }

.conv-avatar {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--avatar-bg); color: var(--avatar-text);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 14px; flex-shrink: 0;
    transition: all 0.2s;
}
.conv-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.conv-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-id {
    font-weight: 700; font-size: 13px; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: flex; align-items: center; gap: 5px;
    flex: 1; min-width: 0; transition: color 0.2s;
}
.conv-platform {
    font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
    background: var(--accent-light-bg); color: var(--accent-light-text);
    flex-shrink: 0;
}
.conv-time {
    font-size: 11px; color: var(--text-muted); font-weight: 600; flex-shrink: 0;
    transition: color 0.2s;
}
.conv-bottom { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.conv-msg {
    font-size: 12px; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; transition: color 0.2s;
}
.conv-badge {
    background: var(--badge-bg); color: var(--badge-text);
    font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 12px;
    flex-shrink: 0; min-width: 20px; text-align: center;
    animation: pulseGlow 2s infinite;
}
.btn-delete-conv {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.2s ease;
    margin-left: 4px;
}
.conversation-item:hover .btn-delete-conv {
    opacity: 1;
}
.btn-delete-conv:hover {
    background: var(--del-bg);
    color: var(--del-text);
}

/* ═══════════════════════════════════════════
   CHAT AREA
   ═══════════════════════════════════════════ */
.admin-chat-area {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-layout); position: relative; min-width: 0;
    transition: background 0.3s;
}
.admin-chat-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-header); transition: all 0.3s;
}
.admin-chat-header h3 {
    font-size: 15px; font-weight: 700; color: var(--text-heading); margin: 0;
    display: flex; align-items: center; gap: 8px; transition: color 0.3s;
}
.btn-refresh {
    background: var(--bg-input); border: 1px solid var(--border); color: var(--text-secondary);
    padding: 6px 14px; border-radius: 8px; font-size: 12px; cursor: pointer;
    font-weight: 600; transition: all 0.2s; font-family: inherit;
}
.btn-refresh:hover { background: var(--accent-light-bg); color: var(--accent); border-color: var(--accent); }

/* Empty State */
.empty-state {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted); gap: 12px; background: var(--bg-empty);
    transition: all 0.3s;
}
.empty-state .empty-icon {
    width: 80px; height: 80px; border-radius: 20px;
    background: var(--accent-light-bg); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; animation: floatUp 3s ease-in-out infinite;
}
.empty-state h2 { font-size: 16px; font-weight: 700; color: var(--text-secondary); text-align: center; max-width: 360px; }
.empty-state p { font-size: 13px; color: var(--text-muted); }

/* ═══════════════════════════════════════════
   MESSAGES
   ═══════════════════════════════════════════ */
.chat-messages {
    flex: 1; padding: 20px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--bg-messages); transition: background 0.3s;
}
.message {
    max-width: 78%; padding: 10px 14px; border-radius: 16px;
    font-size: 14px; line-height: 1.5; word-wrap: break-word;
    position: relative; animation: msgIn 0.3s ease;
    display: flex; flex-direction: column;
}
.message .msg-content {
    word-break: break-word;
}
.message.user {
    align-self: flex-end; background: var(--msg-user-bg); color: var(--msg-user-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px var(--msg-user-shadow);
}
.message.admin {
    align-self: flex-start; background: var(--msg-admin-bg); color: var(--msg-admin-text) !important;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--msg-admin-border);
    box-shadow: 0 2px 6px var(--msg-admin-shadow);
}
.message.admin, .message.admin * {
    color: var(--msg-admin-text) !important;
}
.message.user, .message.user * {
    color: var(--msg-user-text) !important;
}

.msg-sender-tag, .admin-info {
    display: none !important;
}

.message-time {
    display: block !important; font-size: 10px !important; margin-top: 4px !important;
    font-weight: 500 !important; opacity: 0.8;
}
.message.user .message-time { color: var(--msg-user-time) !important; text-align: right !important; }
.message.admin .message-time { color: var(--msg-admin-time) !important; text-align: left !important; }

/* Date Separator */
.date-separator {
    display: flex; align-items: center; gap: 12px;
    margin: 8px 0; align-self: center;
}
.date-separator::before, .date-separator::after {
    content: ''; flex: 1; height: 1px; background: var(--date-sep-bg);
}
.date-separator span {
    font-size: 11px; font-weight: 700; color: var(--date-sep-text);
    padding: 3px 12px; background: var(--bg-messages); border-radius: 10px;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════
   INPUT AREA
   ═══════════════════════════════════════════ */
.chat-input-area {
    padding: 14px 20px; background: var(--bg-header);
    border-top: 1px solid var(--border);
    display: flex; gap: 10px; align-items: center;
    transition: all 0.3s;
}
.chat-input-area input {
    flex: 1; padding: 11px 18px; border-radius: 24px;
    font-size: 14px; background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border); outline: none;
    transition: all 0.2s; font-family: inherit;
}
.chat-input-area input:focus {
    background: var(--bg-input-focus); border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.chat-input-area input::placeholder { color: var(--text-muted); }
.chat-input-area button.btn-send {
    width: 42px; height: 42px; font-size: 15px;
    background: var(--accent-gradient); color: #fff; border: none;
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 10px var(--accent-glow); transition: all 0.2s;
}
.chat-input-area button.btn-send:hover { transform: scale(1.06); }

.btn-upload-image {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--bg-input); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; cursor: pointer; border: 1px solid var(--border);
    transition: all 0.2s;
}
.btn-upload-image:hover { background: var(--accent-light-bg); color: var(--accent); border-color: var(--accent); }

/* Quick Replies */
.quick-replies {
    display: flex; gap: 6px; padding: 10px 20px;
    overflow-x: auto; background: var(--bg-qr-area);
    border-top: 1px solid var(--border); transition: all 0.3s;
}
.quick-replies button {
    padding: 5px 14px; background: var(--qr-bg); color: var(--qr-text);
    border: 1px solid var(--qr-border); border-radius: 16px;
    font-size: 12px; font-weight: 700; cursor: pointer;
    white-space: nowrap; transition: all 0.2s; font-family: inherit;
}
.quick-replies button:hover {
    background: var(--accent-gradient); color: #fff; border-color: transparent;
}

/* Image Preview */
.chat-image-preview {
    padding: 10px 20px; background: var(--bg-qr-area);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.chat-image-preview img { max-height: 80px; border-radius: 8px; }
.chat-image-preview .remove-preview {
    cursor: pointer; font-size: 20px; color: var(--del-text);
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--del-bg); display: flex; align-items: center; justify-content: center;
}

/* ═══════════════════════════════════════════
   AUTO REPLY MODAL
   ═══════════════════════════════════════════ */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-modal-overlay); backdrop-filter: blur(6px);
    z-index: 9999; justify-content: center; align-items: center;
}
.modal-overlay.show { display: flex; }
.modal-container {
    background: var(--bg-modal); width: 94%; max-width: 680px;
    border-radius: 20px; padding: 24px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    max-height: 88vh; overflow-y: auto;
    border: 1px solid var(--border);
    animation: modalIn 0.3s ease;
    transition: background 0.3s, border-color 0.3s;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 18px;
}
.modal-header h3 {
    margin: 0; font-size: 18px; font-weight: 800; color: var(--text-heading);
    display: flex; align-items: center; gap: 10px;
}
.modal-header h3 i { color: var(--accent); }
.btn-modal-close {
    border: none; background: var(--bg-input); width: 34px; height: 34px;
    border-radius: 50%; font-size: 18px; cursor: pointer;
    color: var(--text-muted); display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.btn-modal-close:hover { background: var(--del-bg); color: var(--del-text); }

.modal-form {
    background: var(--bg-form); padding: 18px; border-radius: 14px;
    margin-bottom: 22px; border: 1px solid var(--border);
}
.modal-form h4 { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--text-heading); }
.modal-form label { font-size: 12px; font-weight: 700; color: var(--text-secondary); display: block; margin-bottom: 6px; }
.modal-form input, .modal-form textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: 10px; font-size: 13px; outline: none;
    background: var(--bg-input); color: var(--text-primary);
    transition: all 0.2s; font-family: inherit;
}
.modal-form input:focus, .modal-form textarea:focus {
    border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-input-focus);
}
.modal-form input::placeholder, .modal-form textarea::placeholder { color: var(--text-muted); }
.modal-form .form-group { margin-bottom: 12px; }
.btn-add-rule {
    background: var(--accent-gradient); color: #fff; border: none;
    padding: 10px 20px; border-radius: 10px; cursor: pointer;
    font-weight: 700; font-size: 13px; box-shadow: 0 4px 10px var(--accent-glow);
    transition: all 0.2s; font-family: inherit;
}
.btn-add-rule:hover { transform: translateY(-1px); }

.rules-list-title { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--text-heading); }
.rule-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px; margin-bottom: 8px; transition: all 0.2s;
}
.rule-card:hover { border-color: var(--border-hover); }
.rule-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.rule-keywords { font-weight: 700; font-size: 13px; color: var(--text-heading); display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.rule-keywords i { color: #F59E0B; }
.rule-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.status-badge {
    padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 700;
}
.status-badge.on { background: var(--status-on-bg); color: var(--status-on-text); }
.status-badge.off { background: var(--status-off-bg); color: var(--status-off-text); }
.btn-toggle-rule, .btn-delete-rule, .btn-edit-rule {
    border: none; padding: 4px 10px; border-radius: 6px;
    font-size: 11px; cursor: pointer; font-weight: 600;
    transition: all 0.2s; font-family: inherit;
}
.btn-toggle-rule { background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-toggle-rule:hover { background: var(--accent-light-bg); color: var(--accent); }
.btn-edit-rule { background: var(--accent-light-bg); color: var(--accent); border: 1px solid var(--border); }
.btn-edit-rule:hover { background: var(--accent); color: #fff; }
.btn-delete-rule { background: var(--del-bg); color: var(--del-text); }
.btn-delete-rule:hover { background: var(--del-hover-bg); color: #fff; }
.rule-content {
    font-size: 13px; color: var(--text-secondary);
    background: var(--bg-form); padding: 8px 12px; border-radius: 8px;
    white-space: pre-wrap; line-height: 1.5;
}

/* ═══════════════════════════════════════════
   LIGHTBOX
   ═══════════════════════════════════════════ */
.chat-lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 99999;
    display: none; align-items: center; justify-content: center;
}
.chat-lightbox .lightbox-content { max-width: 90%; max-height: 90%; border-radius: 8px; }
.chat-lightbox .close-lightbox {
    position: absolute; top: 20px; right: 30px;
    color: #fff; font-size: 36px; cursor: pointer; z-index: 100000;
}

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes pulseGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); } 50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); } }
@keyframes floatUp { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ═══════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════ */
.mobile-back-btn {
    display: none; background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-secondary); padding: 6px 12px; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    align-items: center; gap: 4px; font-family: inherit;
}

@media (max-width: 768px) {
    .admin-body { padding: 0; }
    .admin-layout { border-radius: 0; height: 100vh; max-height: 100vh; position: relative; }
    .admin-sidebar { width: 100%; height: 100%; }
    .admin-chat-area {
        position: absolute; top: 0; left: 0; width: 100%; height: 100%;
        z-index: 50; display: none;
    }
    .admin-layout.mobile-chat-open .admin-chat-area { display: flex; }
    .mobile-back-btn { display: inline-flex; }
    .header-top h2 { font-size: 16px; }
    .conv-avatar { width: 38px; height: 38px; border-radius: 10px; font-size: 13px; }
    .conversation-item { padding: 10px; }
    .chat-messages { padding: 14px; }
    .message { max-width: 85%; font-size: 13px; }
    .chat-input-area { padding: 10px 14px; }
    .modal-container { width: 96%; padding: 16px; }
}
@media (min-width: 769px) {
    .mobile-back-btn { display: none !important; }
}

/* Empty conv list */
.conv-empty {
    text-align: center; color: var(--text-muted); padding: 40px 20px;
    font-size: 13px; display: flex; flex-direction: column;
    align-items: center; gap: 8px;
}
.conv-empty i { font-size: 28px; opacity: 0.5; }
