* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #222;
    background: #f5f6fa;
}

header {
    background: #1a1a2e;
    color: #fff;
    padding: 0 24px;
}
nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    gap: 12px;
}
.nav-left  { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.nav-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.logo { color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; white-space: nowrap; margin-right: 12px; }
.nav-link { color: #ccc; text-decoration: none; font-size: 13px; padding: 4px 10px; border-radius: 4px; white-space: nowrap; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.btn-index { padding: 4px 10px; font-size: 12px; background: #2d2d4e; color: #ccc; border: 1px solid #555; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.btn-index:hover { background: #3d3d6e; color: #fff; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

/* Page header */
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 20px; flex: 1; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.badge-pending  { background: #fff3cd; color: #856404; }
.badge-approved { background: #d1e7dd; color: #0a5c36; }
.badge-rejected { background: #f8d7da; color: #842029; }

/* Filter tabs */
.filter-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
    padding: 6px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: #555;
    background: #e9ecef;
    font-size: 13px;
}
.tab.active { background: #1a1a2e; color: #fff; }

/* Queue table */
.queue-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.queue-table th { background: #f0f0f5; padding: 10px 12px; text-align: left; font-size: 12px; text-transform: uppercase; color: #666; }
.queue-table td { padding: 10px 12px; border-top: 1px solid #f0f0f5; vertical-align: middle; }
.queue-table tr:hover td { background: #fafafa; }
.date { color: #888; white-space: nowrap; font-size: 12px; }
.ticket-id { font-family: monospace; font-size: 12px; color: #555; }
.question-preview { max-width: 400px; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary  { background: #0d6efd; color: #fff; }
.btn-approve  { background: #198754; color: #fff; padding: 10px 24px; font-size: 15px; }
.btn-reject   { background: #dc3545; color: #fff; padding: 10px 24px; font-size: 15px; }
.btn-confirm  { background: #0d6efd; color: #fff; margin-top: 10px; padding: 8px 20px; }
.btn-skip     { background: #6c757d; color: #fff; padding: 10px 24px; font-size: 15px; }
.btn-delete     { background: #fff; color: #dc3545; border: 1px solid #dc3545; padding: 10px 24px; font-size: 15px; }
.btn-secondary  { background: #fff; color: #6c757d; border: 1px solid #6c757d; padding: 10px 24px; font-size: 15px; }
.btn-secondary:hover { background: #f8f9fa; }
.btn-back     { background: #6c757d; color: #fff; margin-bottom: 12px; }

/* Review page */
.review-page { max-width: 820px; }
.review-nav { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.queue-counter { font-size: 13px; color: #555; }
.queue-empty { color: #198754; font-weight: 600; }
.review-header { margin-bottom: 24px; }
.review-header h1 { font-size: 22px; margin: 8px 0; }
.meta { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; color: #666; margin-top: 6px; }
.meta span strong { color: #222; }
.item-id { color: #888; font-size: 16px; }

.review-section { margin-bottom: 20px; }
.review-section h2 { font-size: 15px; margin-bottom: 8px; color: #444; display: flex; align-items: center; gap: 12px; }
.content-box {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 14px 16px;
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 14px;
}
.question-box { border-left: 4px solid #0d6efd; }
.answer-box   { border-left: 4px solid #198754; }
.history-box  { border-left: 4px solid #adb5bd; background: #f8f9fa; font-size: 13px; }
.history-msg  { padding: 4px 0; border-bottom: 1px solid #eee; }
.history-msg:last-child { border-bottom: none; }

.toggle-btn {
    font-size: 12px;
    padding: 2px 10px;
    border: 1px solid #adb5bd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    color: #555;
}

/* Review actions */
.review-actions { display: flex; gap: 16px; align-items: flex-start; margin-top: 24px; flex-wrap: wrap; }
.approve-form { display: flex; }

.reject-block { display: flex; flex-direction: column; gap: 12px; }
.reject-form { background: #fff; border: 1px solid #dee2e6; border-radius: 8px; padding: 16px; width: 500px; }
.reject-form label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.reject-form textarea {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.screenshots-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.screenshot-thumb {
    width: 180px;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    cursor: zoom-in;
    transition: opacity .15s;
}
.screenshot-thumb:hover { opacity: .85; }

.already-processed {
    margin-top: 20px;
    padding: 12px 16px;
    background: #e9ecef;
    border-radius: 8px;
    color: #555;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.stats { display: flex; gap: 8px; }

.flash-messages { margin-bottom: 16px; }
.flash { padding: 10px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 6px; }
.flash-error   { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.flash-success { background: #d1e7dd; color: #0a5c36; border: 1px solid #badbcc; }

/* ─── Login page ──────────────────────────────────────────────────────────── */
.login-page { background: #f0f0f8; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; border-radius: 10px; box-shadow: 0 2px 16px rgba(0,0,0,.10); padding: 40px 36px; width: 340px; }
.login-logo { font-size: 13px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.login-title { font-size: 22px; font-weight: 700; color: #1a1a2e; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #444; }
.form-group input, .form-group select { width: 100%; padding: 9px 11px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; font-family: inherit; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: #1a1a2e; }
.btn-login { width: 100%; background: #1a1a2e; color: #fff; border: none; border-radius: 7px; padding: 11px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 4px; }
.btn-login:hover { background: #2d2d4e; }

/* ─── Nav user info ───────────────────────────────────────────────────────── */
.nav-user { display: flex; align-items: center; gap: 8px; }
.nav-username { color: #ccc; font-size: 13px; }
.nav-logout { color: #aaa; font-size: 12px; text-decoration: none; border: 1px solid #555; border-radius: 4px; padding: 2px 8px; }
.nav-logout:hover { color: #fff; border-color: #aaa; }

/* Role badges */
.badge-role-admin     { background: #cfe2ff; color: #084298; }
.badge-role-moderator { background: #fff3cd; color: #856404; }
.badge-role-user      { background: #e2e3e5; color: #41464b; }

/* ─── Users page ──────────────────────────────────────────────────────────── */
.users-layout { display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap; }
.users-table-wrap { flex: 1; min-width: 400px; }
.add-user-form { background: #fff; border: 1px solid #dee2e6; border-radius: 8px; padding: 24px; width: 280px; }
.add-user-form h2 { font-size: 16px; margin-bottom: 18px; }
.inline-form { display: flex; align-items: center; gap: 6px; }
.role-select { padding: 3px 6px; border-radius: 4px; border: 1px solid #ccc; font-size: 13px; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.text-muted { color: #aaa; font-size: 12px; }

/* ─── Chat layout ─────────────────────────────────────────────────────────── */
.chat-layout {
    display: flex;
    height: calc(100vh - 52px - 48px);
    gap: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    overflow: hidden;
}

/* Sidebar */
.chat-sidebar {
    width: 220px;
    min-width: 180px;
    background: #f0f0f5;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    gap: 8px;
}
.btn-new-chat {
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.btn-new-chat:hover { background: #2d2d4e; }
.sidebar-empty { font-size: 12px; color: #aaa; text-align: center; padding: 20px 0; }
#chat-list { overflow-y: auto; flex: 1; }
.chat-item {
    display: flex;
    align-items: center;
    padding: 7px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #444;
    gap: 4px;
}
.chat-item:hover { background: #e2e2ec; }
.chat-item.active { background: #1a1a2e; color: #fff; }
.chat-item.active .chat-item-del { color: #aaa; }
.chat-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-del {
    background: none;
    border: none;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}
.chat-item-del:hover { color: #dc3545; }

/* Main chat area */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-topbar {
    padding: 10px 16px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fafafa;
}
.lang-toggle { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 13px; margin-left: auto; }
.lang-toggle select { padding: 2px 6px; border-radius: 4px; border: 1px solid #ccc; font-size: 13px; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fb;
}
.chat-empty { color: #aaa; font-size: 13px; text-align: center; margin: auto; }

.msg-wrap { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-ai   { justify-content: flex-start; }
.msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.msg-user .msg-bubble { background: #1a1a2e; color: #fff; border-bottom-right-radius: 3px; }
.msg-ai   .msg-bubble { background: #fff; border: 1px solid #dee2e6; border-bottom-left-radius: 3px; }
.msg-typing { color: #aaa; font-size: 20px; letter-spacing: 4px; padding: 6px 14px; }

/* Markdown inside AI bubbles */
.msg-ai .msg-bubble p  { margin: 0 0 8px; }
.msg-ai .msg-bubble p:last-child { margin-bottom: 0; }
.msg-ai .msg-bubble ul, .msg-ai .msg-bubble ol { margin: 6px 0 8px 18px; }
.msg-ai .msg-bubble li { margin-bottom: 3px; }
.msg-ai .msg-bubble strong { font-weight: 700; }
.msg-ai .msg-bubble em { font-style: italic; }
.msg-ai .msg-bubble a { color: #0d6efd; text-decoration: underline; }
.msg-ai .msg-bubble a:hover { color: #0a58ca; }
.msg-ai .msg-bubble code { background: #f0f0f5; padding: 1px 5px; border-radius: 3px; font-family: monospace; font-size: 13px; }
.msg-ai .msg-bubble pre  { background: #f0f0f5; border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 8px 0; }
.msg-ai .msg-bubble pre code { background: none; padding: 0; }

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
    background: #fff;
    align-items: flex-end;
}
.chat-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.chat-input-area textarea {
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
}
.chat-input-area textarea:focus { outline: none; border-color: #1a1a2e; }
.btn-send {
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    height: fit-content;
}
.btn-send:hover { background: #2d2d4e; }
.btn-send:disabled { opacity: .5; cursor: default; }
.btn-finish {
    background: #fff;
    color: #198754;
    border: 1px solid #198754;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-finish:hover { background: #d1e7dd; }
.btn-finish:disabled { opacity: .5; cursor: default; }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    font-size: .9rem;
}
.pagination-info { color: #666; }
.pagination-controls, .pagination-perpage { display: flex; gap: 4px; align-items: center; }
.pagination-perpage { color: #666; }
.btn-page {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #fff;
    color: #333;
    text-decoration: none;
    font-size: .85rem;
    line-height: 1.5;
}
.btn-page:hover { background: #f0f0f0; }
.btn-page-active { background: #0d6efd; color: #fff; border-color: #0d6efd; pointer-events: none; }
.btn-page-disabled { color: #aaa; border-color: #eee; pointer-events: none; background: #fafafa; }

/* ─── Stats toolbar ──────────────────────────────────────────────────────── */
.stats-toolbar {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.moderator-filter-form {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
}
.moderator-filter-form select {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}
