:root {
    /* Palette Tươi Trẻ */
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); /* Tím mộng mơ */
    --primary-color: #6366f1;
    --bg-body: #f3f4f6;
    --bg-white: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-light: #e5e7eb;
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --radius-l: 16px;
    --radius-m: 12px;
    --radius-s: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; outline: none; }
body { margin: 0; font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg-body); color: var(--text-main); height: 100vh; overflow: hidden; }

/* LAYOUT */
.app-layout { display: flex; height: 100%; width: 100%; }

/* SIDEBAR (WHITE THEME) */
.sidebar {
    width: 280px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 50;
    flex-shrink: 0;
    /* FIX BUG Lòi header */
    overflow: hidden; 
    white-space: nowrap;
}

.sidebar.collapsed {
    width: 0;
    border: none;
    padding: 0; /* Đảm bảo không còn padding làm lòi nội dung */
}

.sidebar-header { padding: 20px; display: flex; align-items: center; justify-content: space-between; font-weight: 800; color: var(--primary-color); font-size: 18px; letter-spacing: -0.5px; }
.count-badge { background: #eff6ff; color: var(--primary-color); padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: bold; }

.sidebar-content { flex: 1; overflow-y: auto; padding: 10px; }
.empty-text { text-align: center; color: var(--text-muted); font-size: 13px; margin-top: 30px; }

/* File Item Sidebar */
.file-item { display: flex; align-items: center; padding: 10px; border-radius: var(--radius-s); margin-bottom: 5px; cursor: pointer; transition: 0.2s; color: var(--text-main); font-weight: 500; font-size: 14px; }
.file-item:hover { background: #f9fafb; }
.file-item.selected { background: #eef2ff; color: var(--primary-color); }
.file-item input { margin-right: 12px; accent-color: var(--primary-color); cursor: pointer; transform: scale(1.1); }
.file-item span { overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-light); background: var(--bg-white); }
.tool-row { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; font-size: 14px; font-weight: 500; cursor: pointer; }

/* MAIN AREA */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* TOP NAV */
.top-nav { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: transparent; }
.nav-left { display: flex; align-items: center; gap: 20px; }

.icon-btn { background: white; border: 1px solid var(--border-light); border-radius: var(--radius-s); padding: 8px; cursor: pointer; color: var(--text-main); transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.icon-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* TABS STYLE PILL */
.tab-group { display: flex; background: #e5e7eb; padding: 4px; border-radius: var(--radius-m); gap: 4px; }
.tab-pill { border: none; background: transparent; padding: 6px 16px; border-radius: var(--radius-s); font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.tab-pill.active { background: white; color: var(--text-main); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* CONTENT VIEW */
.view-content { display: none; flex: 1; flex-direction: column; padding: 0 24px 24px 24px; height: calc(100% - 64px); }
.view-content.active { display: flex; }

/* TOOLBAR CARD */
.toolbar-card { background: white; border-radius: var(--radius-l); padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow-soft); margin-bottom: 16px; flex-wrap: wrap; gap: 15px; }

.chapter-info { display: flex; align-items: center; gap: 20px; }
.input-box { display: flex; align-items: center; gap: 10px; background: #f9fafb; padding: 6px 12px; border-radius: var(--radius-s); border: 1px solid var(--border-light); }
.input-box label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.input-box input { width: 50px; border: none; background: transparent; font-size: 16px; font-weight: 700; text-align: center; color: var(--primary-color); }
.next-hint { font-size: 13px; color: var(--text-muted); }

.action-group { display: flex; align-items: center; gap: 12px; }

/* BUTTONS */
.btn-gradient { background: var(--primary-gradient); color: white; border: none; padding: 10px 24px; border-radius: var(--radius-m); font-weight: 600; cursor: pointer; transition: 0.3s; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.btn-gradient:hover { transform: translateY(-1px); box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4); }
.full-width { width: 100%; }

.btn-outline { background: white; border: 1px solid var(--border-light); color: var(--text-main); padding: 9px 20px; border-radius: var(--radius-m); font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn-outline:hover { border-color: #d1d5db; background: #f9fafb; }

.btn-ghost { background: transparent; border: none; color: var(--text-muted); padding: 8px 16px; font-weight: 600; cursor: pointer; font-size: 13px; transition: 0.2s; border-radius: var(--radius-m); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text-main); }

.btn-danger-soft { background: #fef2f2; color: #dc2626; border: none; padding: 8px 16px; border-radius: var(--radius-s); font-weight: 600; cursor: pointer; font-size: 13px; }
.btn-danger-soft:hover { background: #fee2e2; }

/* EDITOR AREA */
.editor-wrapper { flex: 1; background: white; border-radius: var(--radius-l); padding: 6px; box-shadow: var(--shadow-soft); overflow: hidden; display: flex; flex-direction: column; }
#editor { width: 100%; height: 100%; padding: 24px; border: none; resize: none; font-size: 16px; line-height: 1.6; border-radius: var(--radius-m); color: #374151; font-family: inherit; }
#editor::placeholder { color: #9ca3af; }

/* MANAGER TABLE */
.manager-card { background: white; border-radius: var(--radius-l); box-shadow: var(--shadow-soft); flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.manager-header { padding: 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-light); }
.manager-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-main); }

.file-table-header { display: flex; background: #f9fafb; padding: 12px 20px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.file-list-body { flex: 1; overflow-y: auto; padding: 0; }

.file-row { display: flex; padding: 14px 20px; border-bottom: 1px solid #f3f4f6; align-items: center; transition: 0.1s; }
.file-row:hover { background: #f9fafb; }

.th-check, .col-check { width: 40px; }
.th-name, .col-name { flex: 1; }
.th-action, .col-action { width: 100px; text-align: center; }

.col-name { font-weight: 500; font-size: 14px; color: var(--text-main); }
.action-btns { display: flex; gap: 8px; justify-content: center; }
.mini-btn { border: none; background: transparent; cursor: pointer; font-size: 16px; padding: 6px; border-radius: 6px; transition: 0.2s; }
.btn-dl { color: var(--primary-color); background: #eef2ff; }
.btn-del { color: #ef4444; background: #fef2f2; }
.mini-btn:hover { transform: scale(1.1); }

/* Toast */
#toast { position: fixed; bottom: 30px; right: 30px; background: #1f2937; color: white; padding: 12px 24px; border-radius: 50px; opacity: 0; transition: 0.3s; pointer-events: none; z-index: 100; font-size: 14px; font-weight: 500; box-shadow: 0 10px 25px rgba(0,0,0,0.15); transform: translateY(20px); }
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 768px) {
    .sidebar { position: absolute; height: 100%; box-shadow: 5px 0 25px rgba(0,0,0,0.1); }
    .toolbar-card { gap: 10px; padding: 15px; }
    .action-group { width: 100%; justify-content: space-between; margin-top: 10px; }
    .btn-gradient { flex: 1; }
    .view-content { padding: 0 15px 15px 15px; }
}
