/* ═══════════════════════════════════════════════════
   NV LEARN – GLOBAL STYLES
   Ngọc Việt Group · AI Training Platform
════════════════════════════════════════════════════ */

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

:root {
  --primary:       #4285F4;
  --primary-dark:  #2563EB;
  --primary-light: #EEF4FF;
  --success:       #34A853;
  --warning:       #FBBC05;
  --danger:        #EA4335;
  --purple:        #9333EA;
  --orange:        #F97316;

  --bg:            #F8F9FA;
  --surface:       #FFFFFF;
  --surface2:      #F1F3F4;
  --border:        #E8EAED;
  --text:          #202124;
  --text-muted:    #5F6368;
  --text-light:    #9AA0A6;

  --sidebar-w:     260px;
  --topbar-h:      64px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);

  --font:          'Inter', system-ui, sans-serif;
  --transition:    .2s ease;
}

html { font-family: var(--font); font-size: 15px; color: var(--text); }
body { background: var(--bg); min-height: 100vh; overflow-x: hidden; }

a { cursor: pointer; text-decoration: none; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ─── SCREENS ─── */
.screen { min-height: 100vh; }
.screen.active { display: block; }

/* ════════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════════ */
#screen-login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #4285F4 100%);
}

.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-blob {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: .25;
}
.blob1 { width: 500px; height: 500px; background: #fff; top: -150px; right: -100px; }
.blob2 { width: 400px; height: 400px; background: #FBBC05; bottom: -100px; left: -80px; }
.blob3 { width: 300px; height: 300px; background: #34A853; top: 40%; left: 30%; }

.login-card {
  position: relative; background: rgba(255,255,255,.95);
  backdrop-filter: blur(20px);
  border-radius: 24px; padding: 40px;
  width: 440px; max-width: calc(100vw - 32px);
  box-shadow: 0 32px 64px rgba(0,0,0,.2);
  animation: slideUp .5s ease;
}
@keyframes slideUp { from { opacity:0; transform: translateY(24px); } to { opacity:1; transform: translateY(0); } }

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-logo { display: flex; align-items: center; justify-content: center; }
.brand-logo.small svg { border-radius: 8px; }
.brand-name { font-size: 1.3rem; font-weight: 800; color: var(--text); line-height: 1; }
.brand-sub { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

.login-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; }
.login-desc { color: var(--text-muted); margin-bottom: 24px; font-size: .9rem; }

.tab-switch {
  display: flex; background: var(--surface2); border-radius: var(--radius-sm);
  padding: 4px; margin-bottom: 20px;
}
.tab-btn {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 8px 12px; border-radius: 6px; font-size: .85rem;
  font-family: var(--font); font-weight: 500; color: var(--text-muted);
  transition: var(--transition);
}
.tab-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.hint-text { font-size: .8rem; color: var(--text-muted); margin-top: 8px; }

.error-msg {
  background: #FEE2E2; border: 1px solid #FECACA; color: #DC2626;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: .85rem; margin-bottom: 16px;
}

.login-demo { margin-top: 20px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .82rem; color: var(--text-muted); }
.demo-chip {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 12px; font-size: .8rem; cursor: pointer; font-family: var(--font);
  transition: var(--transition);
}
.demo-chip:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ════════════════════════════════════════════════════
   APP SHELL
════════════════════════════════════════════════════ */
#screen-app { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; transition: transform var(--transition);
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.sidebar-brand-text { font-weight: 700; font-size: 1.1rem; flex: 1; }
.sidebar-close { display: none; background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .9rem; font-weight: 500;
  cursor: pointer; transition: var(--transition); user-select: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border-radius: var(--radius-sm); padding: 10px 12px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: #fff; font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .75rem; color: var(--text-muted); }
.btn-logout {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  color: var(--text-muted); padding: 4px; border-radius: 6px; transition: var(--transition);
}
.btn-logout:hover { background: #FEE2E2; color: var(--danger); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 99; backdrop-filter: blur(2px);
}

/* ─── TOPBAR ─── */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}
.topbar {
  height: var(--topbar-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.hamburger { display: none; background: none; border: none; cursor: pointer; font-size: 1.3rem; padding: 4px; }
.topbar-title { font-weight: 600; font-size: 1rem; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border-radius: 20px;
  padding: 8px 16px; width: 240px;
}
.search-box input { background: none; border: none; outline: none; font-size: .85rem; font-family: var(--font); width: 100%; color: var(--text); }
.notification-bell { font-size: 1.2rem; cursor: pointer; padding: 8px; border-radius: 50%; transition: var(--transition); }
.notification-bell:hover { background: var(--surface2); }

/* ─── PAGES ─── */
.page-content { flex: 1; padding: 28px 32px; }
.page { display: none; animation: fadeIn .25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: .9rem; }

/* ─── STATS GRID ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  border-left: 4px solid var(--border); transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.blue { border-color: var(--primary); }
.stat-card.green { border-color: var(--success); }
.stat-card.purple { border-color: var(--purple); }
.stat-card.orange { border-color: var(--orange); }
.stat-icon { font-size: 1.8rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* ─── SECTIONS ─── */
.section { margin-bottom: 36px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 1.1rem; font-weight: 700; }
.section-link { font-size: .85rem; color: var(--primary); font-weight: 500; cursor: pointer; }
.section-link:hover { text-decoration: underline; }

/* ─── COURSE CARDS ─── */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.course-grid.large { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.course-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  cursor: pointer; transition: transform .2s, box-shadow .2s;
  display: flex; flex-direction: column;
}
.course-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.course-thumb {
  height: 160px; background: linear-gradient(135deg, #4285F4, #764ba2);
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.course-thumb-emoji { font-size: 3.5rem; filter: drop-shadow(0 4px 8px rgba(0,0,0,.2)); }
.course-thumb-img { width: 100%; height: 100%; object-fit: cover; }
.course-group-badge {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(4px);
  border-radius: 20px; padding: 3px 10px;
  font-size: .72rem; font-weight: 600; color: var(--text);
}

.course-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.course-title { font-size: .95rem; font-weight: 700; margin-bottom: 6px; line-height: 1.4; }
.course-desc { font-size: .82rem; color: var(--text-muted); line-height: 1.5; flex: 1; }
.course-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: .78rem; color: var(--text-muted);
}
.course-progress-wrap { margin-top: 12px; }
.progress-bar-full { background: var(--surface2); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); border-radius: 4px; transition: width .6s ease; }
.progress-label { font-size: .75rem; color: var(--text-muted); margin-top: 4px; display: block; }

/* ─── FILTER BAR ─── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.filter-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 18px;
  font-size: .85rem; font-family: var(--font); cursor: pointer;
  transition: var(--transition); font-weight: 500; color: var(--text-muted);
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ─── MY LEARNING LIST ─── */
.my-course-row {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 24px;
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 16px; cursor: pointer; transition: transform .2s;
}
.my-course-row:hover { transform: translateX(4px); }
.my-course-thumb {
  width: 72px; height: 72px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #4285F4, #764ba2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; flex-shrink: 0;
}
.my-course-info { flex: 1; }
.my-course-title { font-weight: 700; margin-bottom: 4px; }
.my-course-meta { font-size: .82rem; color: var(--text-muted); margin-bottom: 10px; }

/* ─── COURSE DETAIL ─── */
.course-detail-layout { display: flex; gap: 0; min-height: calc(100vh - var(--topbar-h) - 56px); margin: -28px -32px; }
.course-sidebar {
  width: 300px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.course-sidebar-header { padding: 20px; border-bottom: 1px solid var(--border); }
.btn-back {
  background: none; border: none; cursor: pointer; font-size: .85rem;
  color: var(--primary); font-family: var(--font); padding: 0; margin-bottom: 12px;
  display: block; font-weight: 500;
}
.btn-back:hover { text-decoration: underline; }
.course-sidebar-title { font-size: .95rem; font-weight: 700; line-height: 1.4; margin-bottom: 12px; }
.module-list { flex: 1; overflow-y: auto; padding: 12px; }

.module-item { margin-bottom: 8px; }
.module-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface2);
  border-radius: var(--radius-sm); cursor: pointer; user-select: none;
  font-size: .88rem; font-weight: 600;
}
.module-header:hover { background: var(--border); }
.module-toggle { transition: transform .2s; }
.module-toggle.open { transform: rotate(90deg); }
.lesson-list-inner { padding: 4px 0; }
.lesson-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 20px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s;
  font-size: .85rem;
}
.lesson-item:hover { background: var(--surface2); }
.lesson-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.lesson-check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: .7rem; flex-shrink: 0; }
.lesson-check.done { background: var(--success); border-color: var(--success); color: #fff; }

.course-main { flex: 1; overflow-y: auto; padding: 28px; background: var(--bg); }
.lesson-player { }
.lesson-placeholder { text-align: center; padding: 80px 40px; }
.placeholder-icon { font-size: 4rem; margin-bottom: 16px; }

.lesson-content-header { margin-bottom: 20px; }
.lesson-content-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.lesson-content-desc { color: var(--text-muted); font-size: .9rem; line-height: 1.6; }

.drive-embed-wrap {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px;
}
.drive-embed-wrap iframe { width: 100%; height: 500px; border: none; display: block; }

.drive-fallback {
  text-align: center; padding: 48px 24px;
  background: var(--surface); border-radius: var(--radius); margin-bottom: 20px;
  border: 2px dashed var(--border);
}

.lesson-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ─── ADMIN TABLE ─── */
.table-wrapper { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: var(--surface2); padding: 12px 16px; text-align: left; font-size: .82rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.data-table td { padding: 14px 16px; border-top: 1px solid var(--border); font-size: .88rem; }
.data-table tr:hover td { background: var(--surface2); }
.table-actions { display: flex; gap: 8px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
}
.badge-office { background: #EEF4FF; color: var(--primary); }
.badge-production { background: #FFF7ED; color: var(--orange); }
.badge-management { background: #F5F3FF; color: var(--purple); }
.badge-all { background: var(--surface2); color: var(--text-muted); }

/* ─── FORMS ─── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: .9rem;
  color: var(--text); background: var(--surface); outline: none; transition: border-color .15s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(66,133,244,.12); }
textarea.form-input { resize: vertical; }
select.form-input { cursor: pointer; }
.field-hint { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }

/* ─── BUTTONS ─── */
.btn-primary {
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 10px 20px;
  font-size: .9rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.btn-full { width: 100%; padding: 13px; margin-top: 8px; font-size: 1rem; }

.btn-secondary {
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 20px;
  font-size: .9rem; font-weight: 600; font-family: var(--font); cursor: pointer; transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--text-muted); }

.btn-sm {
  padding: 6px 12px; font-size: .8rem; border-radius: 6px;
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-family: var(--font); transition: var(--transition); font-weight: 500;
}
.btn-sm:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm.danger:hover { border-color: var(--danger); color: var(--danger); }

.btn-success {
  background: var(--success); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 10px 20px;
  font-size: .9rem; font-weight: 600; font-family: var(--font); cursor: pointer; transition: var(--transition);
}
.btn-success:hover { background: #2D9249; }

/* ─── MODALS ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); width: 480px; max-width: 100%;
  animation: slideUp .25s ease;
}
.modal-box.wide { width: 560px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  color: var(--text-muted); padding: 4px 8px; border-radius: 6px; transition: var(--transition);
}
.modal-close:hover { background: var(--surface2); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1E293B; color: #fff; padding: 12px 24px;
  border-radius: 30px; font-size: .88rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── EMPTY STATE ─── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex !important; }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .course-detail-layout { flex-direction: column; }
  .course-sidebar { width: 100%; }
  .page-content { padding: 20px 16px; }
  .search-box { width: 160px; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
  .topbar-actions .search-box { display: none; }
  .login-card { padding: 28px 20px; }
}
