/* =====================================================
   Admin panel styles — đồng bộ tông màu với landing page
   ===================================================== */
:root {
    --bg-primary: #08090d;
    --bg-secondary: #0e1017;
    --bg-card: #12141c;
    --bg-input: #1a1d28;
    --text-primary: #eef0f6;
    --text-secondary: #8b8fa7;
    --text-tertiary: #5c6080;
    --accent-blue: #6366f1;
    --accent-blue-light: #818cf8;
    --accent-green: #10b981;
    --accent-green-light: #34d399;
    --accent-orange: #f59e0b;
    --accent-orange-light: #fbbf24;
    --accent-red: #ef4444;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --radius: 12px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

[hidden] { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ===== Buttons ===== */
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: all 0.3s var(--ease);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-hover); }

/* ===== Login view ===== */
.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at top, rgba(99, 102, 241, 0.08), transparent 60%);
}

.login-card {
    width: min(400px, 100%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.login-card h1 { font-size: 24px; font-weight: 800; }
.login-sub { color: var(--text-tertiary); font-size: 14px; margin-bottom: 8px; }

.login-card label,
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.field-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.login-card input,
.form-grid input,
.form-grid select,
.form-grid textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}
.login-card input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus { border-color: var(--accent-blue); }

.login-error,
.form-error {
    color: var(--accent-red);
    font-size: 13px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 8px;
    padding: 10px 12px;
}

/* ===== Panel view ===== */
.panel-view {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.panel-title h1 { font-size: 26px; font-weight: 800; }
.panel-user { color: var(--text-tertiary); font-size: 14px; }
.panel-user strong { color: var(--accent-blue-light); }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}
.filter-tabs { display: flex; gap: 6px; }
.filter-tab {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}
.filter-tab.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

#search-box {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    min-width: 220px;
}
#search-box:focus { border-color: var(--accent-blue); }

/* ===== Table ===== */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow-x: auto;
}
.plugin-table { width: 100%; border-collapse: collapse; }
.plugin-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.plugin-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}
.plugin-table tr:last-child td { border-bottom: none; }
.plugin-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.cell-icon { font-size: 22px; }
.cell-name { font-weight: 600; max-width: 280px; }
.cell-mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--text-secondary); }
.empty-row { text-align: center; color: var(--text-tertiary); padding: 40px; }
.muted { color: var(--text-tertiary); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-autocad { background: rgba(16, 185, 129, 0.14); color: var(--accent-green-light); }
.badge-excel { background: rgba(245, 158, 11, 0.14); color: var(--accent-orange-light); }

.price-free { color: var(--accent-green-light); font-weight: 600; }
.price-paid { color: var(--accent-orange-light); font-weight: 600; }

.cell-actions { white-space: nowrap; }
.btn-mini {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 13px;
    margin-right: 6px;
    transition: all 0.2s;
}
.btn-mini:hover { color: var(--text-primary); border-color: var(--border-hover); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
}
.modal-card {
    width: min(640px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 28px;
    position: relative;
}
.modal-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 20px; }
.modal-x {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
}
.modal-x:hover { color: var(--text-primary); }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid textarea { resize: vertical; }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.modal-footer .form-error { margin-right: auto; }

/* ===== Form OK message ===== */
.form-ok {
    color: var(--accent-green-light);
    font-size: 13px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 8px;
    padding: 10px 12px;
    margin-right: auto;
}
.modal-sm { width: min(440px, 100%); }

/* ===== Dashboard stat cards ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent-blue);
}
.stat-card.stat-acad::before { background: var(--accent-green); }
.stat-card.stat-excel::before { background: var(--accent-orange); }
.stat-card.stat-free::before { background: var(--accent-green-light); }
.stat-card.stat-paid::before { background: var(--accent-orange-light); }
.stat-card.stat-hidden::before { background: var(--text-tertiary); }
.stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-value { font-size: 26px; font-weight: 800; }

/* ===== Toolbar additions ===== */
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 9px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}
.toolbar-select:focus { border-color: var(--accent-blue); }

/* ===== Sortable headers ===== */
.plugin-table th.sortable { cursor: pointer; user-select: none; }
.plugin-table th.sortable:hover { color: var(--text-secondary); }
.plugin-table th.sort-asc::after { content: ' ▲'; font-size: 10px; color: var(--accent-blue-light); }
.plugin-table th.sort-desc::after { content: ' ▼'; font-size: 10px; color: var(--accent-blue-light); }

/* ===== Drag handle / reorder ===== */
.col-drag { width: 28px; text-align: center; }
.col-check { width: 36px; text-align: center; }
.drag-handle { cursor: grab; color: var(--text-tertiary); font-size: 16px; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
.plugin-table tr.dragging { opacity: 0.4; }
.plugin-table tr.drag-over td { box-shadow: inset 0 2px 0 var(--accent-blue); }
.plugin-table tr.row-selected { background: rgba(99, 102, 241, 0.08); }

/* ===== Thumbnail in table ===== */
.cell-thumb {
    width: 38px; height: 38px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}
.cell-icon-emoji { font-size: 22px; }

/* ===== Status badges ===== */
.badge-visible { background: rgba(16, 185, 129, 0.14); color: var(--accent-green-light); }
.badge-hidden { background: rgba(148, 163, 184, 0.16); color: var(--text-secondary); }

/* ===== Bulk action bar ===== */
.bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.bulk-count { font-size: 14px; color: var(--text-secondary); }
.bulk-count strong { color: var(--accent-blue-light); }
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}
.page-size, .page-nav { display: flex; align-items: center; gap: 8px; }
.page-size span, .page-info { font-size: 13px; color: var(--text-secondary); }
.page-nav button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Thumbnail uploader (modal) ===== */
.thumb-uploader { display: flex; gap: 16px; align-items: flex-start; }
.thumb-preview {
    width: 92px; height: 92px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px dashed var(--border-hover);
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.thumb-preview img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { font-size: 12px; color: var(--text-tertiary); text-align: center; padding: 4px; }
.thumb-controls { display: flex; flex-direction: column; gap: 8px; }
.upload-status { font-size: 12px; }
.upload-status.ok { color: var(--accent-green-light); }
.upload-status.err { color: var(--accent-red); }

/* ===== Checkbox row in form ===== */
.checkbox-row {
    flex-direction: row !important;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.checkbox-row input { width: 18px; height: 18px; }

@media (max-width: 900px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
    .panel-header, .panel-toolbar { flex-direction: column; align-items: stretch; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .thumb-uploader { flex-direction: column; }
}

/* ===== Modal rộng cho trang soạn bài ===== */
.modal-lg { width: min(880px, 100%); }

/* ===== Badge tag + trạng thái bài viết (bảng blog) ===== */
.badge-soft {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.14);
    color: var(--accent-blue-light);
    margin: 1px;
}
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-on { background: rgba(16, 185, 129, 0.14); color: var(--accent-green-light); }
.status-off { background: rgba(148, 163, 184, 0.16); color: var(--text-secondary); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== Trình soạn: chuyển chế độ Soạn thảo / Mã HTML ===== */
.editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}
.editor-mode-toggle {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
}
.mode-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    background: none;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.mode-btn.active {
    background: var(--accent-blue);
    color: #fff;
}

/* Textarea Mã HTML thô */
.html-source {
    width: 100%;
    min-height: 320px;
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    line-height: 1.6;
    color: #e2e8f0;
    background: #0b0d14;
    border: 1px solid var(--border-color);
    border-radius: 0 0 10px 10px;
    padding: 14px 16px;
    resize: vertical;
    tab-size: 2;
}
.html-source:focus { outline: none; border-color: var(--accent-blue); }

/* ===== Quill — chỉnh cho nền tối ===== */
.ql-toolbar.ql-snow {
    border-color: var(--border-color);
    border-radius: 10px 10px 0 0;
    background: rgba(255, 255, 255, 0.03);
}
.ql-container.ql-snow {
    border-color: var(--border-color);
    border-radius: 0 0 10px 10px;
    background: #0b0d14;
    font-family: var(--font-main, inherit);
    font-size: 15px;
}
.ql-editor {
    min-height: 320px;
    color: #e2e8f0;
    line-height: 1.7;
}
.ql-editor.ql-blank::before { color: var(--text-tertiary); font-style: normal; }
.ql-snow .ql-stroke { stroke: var(--text-secondary); }
.ql-snow .ql-fill { fill: var(--text-secondary); }
.ql-snow .ql-picker { color: var(--text-secondary); }
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar button:hover .ql-stroke { stroke: var(--accent-blue-light); }
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent-blue-light); }
.ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent-blue-light); }
.ql-snow .ql-picker-options {
    background: var(--bg-card);
    border-color: var(--border-color);
}
/* Bảng/ảnh/blockquote xem trước ngay trong editor */
.ql-editor img { max-width: 100%; border-radius: 8px; }
.ql-editor table { border-collapse: collapse; width: 100%; }
.ql-editor td, .ql-editor th { border: 1px solid var(--border-color); padding: 6px 10px; }
.ql-editor blockquote { border-left: 3px solid var(--accent-blue); padding-left: 14px; color: var(--text-secondary); }
