:root {
    --bg-color: #f4f6fa;
    --sidebar-bg: #1e1b4b;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --text-color: #1f2937;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-color); }
.app-container { display: flex; min-height: 100vh; }

/* SIDEBAR & MAIN CONTENT */
.sidebar { width: 260px; background-color: var(--sidebar-bg); color: #fff; padding: 20px; display: flex; flex-direction: column; gap: 20px; flex-shrink: 0; }
.logo { font-size: 20px; font-weight: bold; display: flex; align-items: center; gap: 10px; }
.btn-google { background: white; color: #444; border: none; padding: 10px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: bold; }
.user-info { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.1); padding: 8px; border-radius: 6px; }
.user-info img { width: 35px; height: 35px; border-radius: 50%; }
.btn-logout { background: none; border: none; color: var(--danger); cursor: pointer; margin-left: auto; font-weight: bold; }
.menu { display: flex; flex-direction: column; gap: 10px; }
.menu-item { color: #cbd5e1; text-decoration: none; padding: 12px; border-radius: 8px; display: flex; align-items: center; gap: 10px; }
.menu-item.active { background-color: var(--primary-color); color: #fff; }

.main-content { flex-grow: 1; padding: 24px; display: flex; flex-direction: column; gap: 24px; overflow-x: hidden; }
.topbar { background: var(--card-bg); padding: 15px 20px; border-radius: 10px; border: 1px solid var(--border-color); }
.voice-selector select { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border-color); outline: none; font-weight: 500; color: #374151; }

.section-card { background: var(--card-bg); border-radius: 12px; padding: 24px; border: 1px solid var(--border-color); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }

.learning-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 15px; width: 100%; }
.btn-toggle-box { background: #f1f5f9; color: #475569; border: 1px solid var(--border-color); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all 0.2s ease; flex-shrink: 0; }
.btn-toggle-box:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }

#learning-content-wrapper { max-height: 4500px; opacity: 1; transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease; overflow: hidden; }
#learning-content-wrapper.collapsed-learning { max-height: 0 !important; opacity: 0 !important; pointer-events: none; }

.btn-primary { background-color: var(--primary-color); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: bold; }
.btn-secondary { background-color: #94a3b8; color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: bold; }
.btn-outline-success { border: 2px solid var(--success); color: var(--success); background: transparent; padding: 8px 16px; border-radius: 8px; font-weight: bold; cursor: pointer; }
.btn-outline-success:hover { background: var(--success); color: white; }

/* TABLE */
.table-responsive { overflow-x: auto; }
.sprint-table { width: 100%; border-collapse: collapse; text-align: left; }
.sprint-table th, .sprint-table td { padding: 14px; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.sprint-table th { background-color: #fafafa; color: #6b7280; font-weight: 600; }
.dot-check { display: inline-block; width: 24px; height: 24px; border-radius: 50%; text-align: center; line-height: 24px; font-size: 12px; }
.dot-check.done { background-color: #d1fae5; color: var(--success); font-weight: bold; }
.dot-check.lock { background-color: #fee2e2; color: var(--danger); }

.btn-action { padding: 4px 8px; border: none; border-radius: 4px; cursor: pointer; margin-right: 5px; color: white; font-size: 12px; }
.btn-edit { background-color: #f59e0b; }
.btn-delete { background-color: var(--danger); }

/* WORKSPACE EDITORS & LINE HEIGHT FORMATTING */
.day-tabs { display: flex; background: #f3f4f6; padding: 5px; border-radius: 8px; margin-bottom: 20px; overflow-x: auto; }
.tab-btn { flex: 1; padding: 10px; border: none; background: transparent; cursor: pointer; font-weight: 500; border-radius: 6px; min-width: 100px; }
.tab-btn.active { background: white; color: var(--primary-color); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.workspace-split { display: flex; gap: 20px; margin-top: 15px; }
.editor-column { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.editor-label { font-weight: bold; margin-bottom: 8px; }
.editor-toolbar { background: #f8fafc; border: 1px solid var(--border-color); border-bottom: none; padding: 8px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; gap: 5px; flex-wrap: wrap; }
.editor-toolbar button { background: white; border: 1px solid #cbd5e1; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-weight: bold; }

/* FIX: Tối ưu khoảng cách dòng và khoảng cách đoạn văn bản */
.editor-content { border: 1px solid var(--border-color); min-height: 350px; max-height: 600px; overflow-y: auto; padding: 20px; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; background: white; outline: none; position: relative; line-height: 1.8; color: #2d3748; font-size: 15px; }
.editor-content h1, .editor-content h2, .editor-content h3, .editor-content h4 { color: #1e1b4b; margin-top: 18px; margin-bottom: 12px; font-weight: 700; line-height: 1.4; }
.editor-content h1 { font-size: 26px; border-bottom: 2px solid #e2e8f0; padding-bottom: 6px; }
.editor-content h2 { font-size: 21px; }
.editor-content h3 { font-size: 18px; }
.editor-content h4 { font-size: 16px; color: var(--primary-color); }
.editor-content p { margin-bottom: 14px; text-align: justify; }
.editor-content ul, .editor-content ol { margin-left: 20px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.editor-content li { margin-bottom: 2px; }
.editor-content [placeholder]:empty:before { content: attr(placeholder); color: #94a3b8; }

.btn-complete-day { width: 100%; background-color: var(--primary-color); color: white; border: none; padding: 15px; border-radius: 8px; margin-top: 20px; font-weight: bold; font-size: 16px; cursor: pointer; }
.btn-complete-day:disabled { background-color: #cbd5e1; cursor: not-allowed; color: #94a3b8; }

/* MODALS POPUP */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); display: flex; justify-content: center; align-items: center; z-index: 2000; transition: 0.2s; }
.modal-box { background: white; padding: 24px; border-radius: 12px; width: 450px; max-width: 90%; display: flex; flex-direction: column; gap: 15px; animation: scaleUp 0.2s ease-out; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.btn-close-x { background: none; border: none; font-size: 24px; cursor: pointer; color: #6b7280; }
.modal-body label { display: block; font-weight: 600; margin-bottom: 8px; }
.modal-body input { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; outline: none; font-size: 15px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border-color); padding-top: 12px; }

@keyframes scaleUp { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* LOA MINI TEXT TO SPEECH */
.tts-popover { position: absolute; background: #1e1b4b; color: white; border: none; padding: 6px 10px; border-radius: 20px; font-size: 13px; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.2); z-index: 9999; display: flex; align-items: center; gap: 5px; }
.tts-popover:hover { background: var(--primary-color); transform: scale(1.05); }
.hidden { display: none !important; }

/* PAGINATION UX */
.pagination-container { display: flex; justify-content: center; align-items: center; margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border-color); }
.pagination-list { display: flex; list-style: none; gap: 6px; align-items: center; overflow-x: auto; padding: 5px 0; max-width: 100%; scrollbar-width: none; }
.pagination-list::-webkit-scrollbar { display: none; }
.pagination-item { display: flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--border-color); background: white; color: #475569; font-size: 14px; font-weight: 600; cursor: pointer; user-select: none; transition: all 0.2s ease; }
.pagination-item:hover:not(.disabled):not(.ellipsis) { border-color: var(--primary-color); color: var(--primary-color); background: #f5f3ff; }
.pagination-item.active { background: var(--primary-color); color: white; border-color: var(--primary-color); box-shadow: 0 3px 8px rgba(79, 70, 229, 0.3); }
.pagination-item.disabled { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; cursor: not-allowed; }
.pagination-item.ellipsis { border: none; background: transparent; cursor: default; color: #94a3b8; }

/* Giao diện khung đàm thoại giọng nói */
.ai-voice-chat-container { background: #ffffff; border: 1px solid var(--border-color); border-radius: 12px; margin: 24px 0; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.voice-chat-header { background: #1e1b4b; color: #ffffff; padding: 14px 20px; font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
#btn-reset-voice-session { background: rgba(255,255,255,0.15); border: none; color: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; transition: background 0.2s; }
#btn-reset-voice-session:hover { background: rgba(255,255,255,0.3); }

.voice-chat-body { display: flex; padding: 20px; gap: 20px; background: #f8fafc; align-items: center; }
.voice-status-wrapper { display: flex; flex-direction: column; align-items: center; text-align: center; width: 160px; flex-shrink: 0; }
.mic-pulse-btn { width: 64px; height: 64px; border-radius: 50%; border: none; background: var(--primary-color); color: white; font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative; transition: all 0.3s ease; }
.mic-pulse-btn:hover { transform: scale(1.05); background: var(--primary-hover); }

/* Animation hiệu ứng sóng khi mic hoạt động hoặc AI đang nói */
.mic-pulse-btn.listening { background: var(--danger); animation: pulseRed 1.5s infinite; }
.mic-pulse-btn.speaking { background: var(--success); animation: pulseGreen 1.5s infinite; }

@keyframes pulseRed { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); } 100% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); } }
@keyframes pulseGreen { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); } 100% { box-shadow: 0 0 0 15px rgba(16, 185, 129, 0); } }

.voice-status-text { font-size: 12px; color: #64748b; margin-top: 8px; font-weight: 600; line-height: 1.3; }
.transcript-display-box { flex-grow: 1; background: white; border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; min-height: 90px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.transcript-line { font-size: 14px; line-height: 1.5; }

/* CSS Khối chấm điểm / Chữa bài mới đẹp mắt */
.ai-report-wrapper { margin-top: 20px; padding: 20px; border-radius: 8px; background: #f8fafc; border: 1px dashed #cbd5e1; }
.ai-score-badge { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; padding: 6px 16px; border-radius: 20px; color: white; margin-bottom: 15px; }
.ai-score-badge.high { background: linear-gradient(135deg, #10b981, #059669); }
.ai-score-badge.mid { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ai-score-badge.low { background: linear-gradient(135deg, #ef4444, #dc2626); }

.ai-correct-block { margin: 12px 0; padding: 14px; border-radius: 8px; font-size: 14px; line-height: 1.6; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.ai-correct-block.error-msg { background: #fef2f2; border-left: 5px solid #ef4444; color: #991b1b; }
.ai-correct-block.success-msg { background: #f0fdf4; border-left: 5px solid #10b981; color: #166534; }

/* HỘP HƯỚNG DẪN PROMPT */
.guide-box-container { background: #fdfdfd; border: 1px dashed #cbd5e1; border-left: 4px solid var(--primary-color); border-radius: 8px; margin-bottom: 20px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.guide-header-toggle { background: #f8fafc; padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; border-bottom: 1px solid #f1f5f9; }
.guide-badge { font-weight: 700; font-size: 14px; color: var(--primary-color); display: flex; align-items: center; gap: 6px; }
#guide-toggle-icon { font-size: 13px; color: #64748b; font-weight: 600; }
.guide-body-content { max-height: 500px; opacity: 1; padding: 15px; transition: max-height 0.3s ease-in-out, opacity 0.2s ease, padding 0.3s ease; overflow-y: auto; }
.guide-body-content.collapsed-guide { max-height: 0 !important; opacity: 0 !important; padding-top: 0 !important; padding-bottom: 0 !important; overflow: hidden; pointer-events: none; }
.guide-flow { display: flex; flex-direction: column; gap: 14px; }
.flow-step { background: #fff; border: 1px solid #f1f5f9; padding: 12px; border-radius: 6px; }
.flow-step h5 { font-size: 14px; font-weight: 700; margin-bottom: 6px; color: #1e1b4b; display: flex; align-items: center; gap: 8px; }
.step-num { background: var(--primary-color); color: white; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; justify-content: center; align-items: center; font-size: 11px; }
.flow-step ul { list-style-type: none; padding-left: 5px; display: flex; flex-direction: column; gap: 4px; }
.flow-step ul li { font-size: 13px; position: relative; padding-left: 14px; }
.flow-step ul li::before { content: "•"; color: var(--primary-color); font-weight: bold; position: absolute; left: 2px; }
.flow-step p { font-size: 13px !important; color: #475569; line-height: 1.5 !important; margin: 0 !important; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin-bottom: 6px; }
.guide-grid span { font-size: 12px; background: #f1f5f9; padding: 4px 8px; border-radius: 4px; font-family: monospace; }

.skills-checklist-container { background: #f8fafc; border: 1px solid var(--border-color); border-radius: 10px; padding: 18px; margin: 20px 0 10px 0; }
.skills-title { font-size: 14px; font-weight: 600; color: #475569; margin-bottom: 12px; }
.skills-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.skill-checkbox-label { display: flex; align-items: center; gap: 10px; background: white; border: 1.5px solid #cbd5e1; padding: 12px 15px; border-radius: 8px; cursor: pointer; user-select: none; transition: all 0.2s ease-in-out; }
.skill-checkbox-label:hover { border-color: var(--primary-color); background: #f0fdf4; }
.skill-checkbox { display: none; }
.skill-custom-box { width: 20px; height: 20px; border: 2px solid #cbd5e1; border-radius: 5px; display: flex; align-items: center; justify-content: center; transition: all 0.15s ease; }
.skill-custom-box i { font-size: 11px; color: white; display: none; }
.skill-text { font-size: 14px; font-weight: 600; color: #334155; display: flex; align-items: center; gap: 6px; }
.skill-checkbox:checked + .skill-custom-box { background-color: var(--success); border-color: var(--success); }
.skill-checkbox:checked + .skill-custom-box i { display: block; }
.skill-checkbox:checked ~ .skill-text { color: #065f46; }
.skill-checkbox-label:has(.skill-checkbox:checked) { border-color: var(--success); background-color: #ecfdf5; box-shadow: 0 2px 6px rgba(16, 185, 129, 0.15); }
.btn-outline-success:disabled { border-color: #cbd5e1; color: #94a3b8; background: transparent; cursor: not-allowed; }
.workspace-actions { display: flex; gap: 15px; margin-top: 15px; }
#btn-finish-prepare { flex: 1; padding: 12px; font-weight: bold; cursor: pointer; }
.btn-complete-day { flex: 1; margin-top: 0 !important; }

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; }
    .workspace-split { flex-direction: column; }
    .pagination-list { gap: 4px; }
    .pagination-item { min-width: 32px; height: 32px; font-size: 13px; }
    .workspace-actions { flex-direction: column; gap: 10px; }
    #btn-finish-prepare, .btn-complete-day { width: 100%; }
    .skills-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .skill-checkbox-label { padding: 10px; }
    .skill-text { font-size: 13px; }
    .voice-selector select{ width: 100%; }
    .voice-chat-body { flex-direction: column; }
    .voice-status-wrapper { width: 100%; }
}