@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --background: #0b0f19;
  --panel-bg: rgba(17, 24, 39, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --primary: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.4);
  --primary-hover: #6366f1;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--background);
  background-image: 
    radial-gradient(at 0% 0%, rgba(30, 27, 75, 0.4) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(17, 24, 39, 0.6) 0, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* --- HIỆU ỨNG GLASSMORPHISM --- */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

/* --- MÀN HÌNH ĐĂNG NHẬP --- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  text-align: center;
}

.brand-logo {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 20px;
  text-shadow: 0 0 20px var(--primary-glow);
  display: inline-block;
}

h2 {
  font-weight: 700;
  font-size: 1.8rem;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #fff 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 30px;
}

.input-group {
  position: relative;
  margin-bottom: 20px;
  text-align: left;
}

.input-group i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.input-group input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
  background: rgba(255, 255, 255, 0.08);
}

.btn-glow {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-glow:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 25px rgba(99, 102, 241, 0.6);
  transform: translateY(-2px);
}

.btn-glow:active {
  transform: translateY(0);
}

.error-msg {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* --- MÀN HÌNH CHÍNH --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  margin-bottom: 30px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border: 1px solid var(--primary);
  color: #fff;
}

.user-text h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.user-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
}

.btn-danger {
  padding: 10px 16px;
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: #fca5a5;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--danger);
}

/* --- KPI GRID --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 35px;
}

.kpi-card {
  padding: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.kpi-card.blue::before { background: #3b82f6; }
.kpi-card.green::before { background: var(--success); }
.kpi-card.purple::before { background: var(--primary); }

.kpi-num {
  font-size: 2.2rem;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --- KHU VỰC ĐIỀU KHIỂN & BẢNG --- */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title h3 {
  font-size: 1.4rem;
  font-weight: 600;
}

.table-container {
  padding: 24px;
  margin-bottom: 35px;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.crm-table th {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.crm-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.crm-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.status-badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-badge.active {
  background: var(--success-bg);
  color: var(--success);
}

.status-badge.error {
  background: var(--danger-bg);
  color: var(--danger);
}

/* --- TOGGLE SWITCH --- */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--success-bg);
  border-color: var(--success);
}

input:checked + .slider:before {
  transform: translateX(24px);
  background-color: var(--success);
}

/* --- THANH TIẾN TRÌNH --- */
.progress-bar-container {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  height: 8px;
  overflow: hidden;
  margin-top: 6px;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
  height: 100%;
  width: 0%;
  transition: width 0.5s ease-in-out;
}

.progress-bar-fill.finished {
  background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
}

/* --- POPUP / MODAL --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  padding: 30px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  transition: color 0.3s;
}

.close-btn:hover {
  color: var(--text);
}

/* --- MÀN HÌNH ĐIỀU KHIỂN CHI TIẾT --- */
.back-bar {
  margin-bottom: 20px;
}

.hidden {
  display: none !important;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

@media (max-width: 768px) {
  .crm-table th, .crm-table td {
    padding: 12px 8px;
    font-size: 0.85rem;
  }
  
  .app-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
}

/* --- MODAL KHÁM PHÁ LỚP HỌC --- */
.explore-modal-card {
  max-width: 1000px;
  width: 90vw;
  height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.explore-container {
  display: flex;
  flex: 1;
  gap: 20px;
  overflow: hidden;
  margin-top: 10px;
}

/* Sidebar danh mục */
.explore-sidebar {
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--border);
  padding-right: 16px;
  overflow-y: auto;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.category-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.category-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.category-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Nội dung danh sách */
.explore-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.explore-search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.search-input-group {
  flex: 1;
}

.explore-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding-right: 8px;
  align-content: start;
}

/* Thẻ khóa học */
.explore-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: all 0.3s ease;
}

.explore-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.explore-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.8em;
}

.explore-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.explore-card-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.explore-card-action {
  width: 100%;
}

/* Phân trang */
.explore-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.explore-pagination span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Trạng thái Loading */
.explore-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .explore-modal-card {
    height: 90vh;
  }
  .explore-container {
    flex-direction: column;
  }
  .explore-sidebar {
    width: 100%;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
    height: auto;
    overflow-x: auto;
  }
  .category-item {
    padding: 8px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
  }
}

/* --- HỆ THỐNG THÔNG BÁO TOAST TỰ CHỈNH (CUSTOM TOAST NOTIFICATION) --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 16px 20px;
  min-width: 320px;
  max-width: 420px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translateX(120%);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.35);
  position: relative;
  overflow: hidden;
}

.toast.active {
  transform: translateX(0);
}

.toast.fade-out {
  opacity: 0;
  transform: translateX(120%);
}

.toast-icon {
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 3px;
  color: #fff;
}

.toast-message {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px;
  transition: color 0.2s;
}

.toast-close:hover {
  color: #fff;
}

/* Các loại thông báo */
.toast.success {
  border-left: 4px solid var(--success);
}
.toast.success .toast-icon {
  color: var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}
.toast.error .toast-icon {
  color: var(--danger);
}

.toast.info {
  border-left: 4px solid var(--primary);
}
.toast.info .toast-icon {
  color: var(--primary);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}
.toast.warning .toast-icon {
  color: var(--warning);
}

/* Thanh thời gian chạy */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
}

.toast-progress-fill {
  height: 100%;
  width: 100%;
  background: var(--primary);
  transition: width 4s linear;
}

.toast.success .toast-progress-fill {
  background: var(--success);
}
.toast.error .toast-progress-fill {
  background: var(--danger);
}
.toast.warning .toast-progress-fill {
  background: var(--warning);
}

/* --- HỘP CHỌN GHI NHỚ ĐĂNG NHẬP --- */
.form-options {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 20px;
  padding-left: 4px;
}

.remember-me-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.remember-me-label:hover {
  color: var(--text);
}

.remember-me-label input {
  display: none;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  display: inline-block;
  position: relative;
  transition: all 0.2s ease;
}

.remember-me-label input:checked + .custom-checkbox {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.remember-me-label input:checked + .custom-checkbox::after {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: #fff;
  font-size: 0.75rem;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* --- HOẠT ẢNH TRANG TRÍ HÀI HƯỚC CHO TRANG ĐĂNG NHẬP --- */
.login-card {
  position: relative;
}

.floating-decorations {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
}

.decor-icon {
  position: absolute;
  font-size: 1.6rem;
  opacity: 0.55;
  animation: floatGently 4s ease-in-out infinite;
  user-select: none;
}

@keyframes floatGently {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-12px) rotate(12deg) scale(1.1);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
