/* ===== CSS CUSTOM PROPERTIES (Mobile App Theme) ===== */
:root {
  --primary: #1B4F72;
  --primary-light: #2471A3;
  --primary-lighter: #EBF5FB;
  --primary-dark: #154360;
  --accent: #F39C12;
  --accent-light: #F5B041;
  --accent-lighter: #FEF9E7;
  --accent-dark: #D68910;
  --success: #27AE60;
  --success-light: #D4EFDF;
  --error: #E74C3C;
  --error-light: #FADBD8;
  --warning: #F39C12;
  --warning-light: #FEF9E7;
  --ai: #8E44AD;
  --text: #1A1A1A;
  --text-secondary: #6C757D;
  --text-disabled: #ADB5BD;
  --bg-root: #FFFFFF;
  --bg-default: #F8F9FA;
  --bg-secondary: #F2F4F6;
  --bg-tertiary: #E9ECEF;
  --border: #E9ECEF;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* ===== RESET & BASE ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-default); color: var(--text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* ===== SIDEBAR ===== */
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.875rem; border-radius: var(--radius-sm);
  font-size: 0.8125rem; font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary); text-decoration: none;
}
.sidebar-link:hover { background: var(--bg-secondary); color: var(--text); transform: translateX(2px); }
.sidebar-link.active {
  background: var(--primary-lighter);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-link .material-icons-outlined { font-size: 19px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 1rem;
}

/* ===== STAT CARDS ===== */
.stat-card {
  background: white; border-radius: var(--radius-lg);
  padding: 1.5rem; border: 1px solid var(--border);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

/* ===== TABLES ===== */
.table-container {
  overflow-x: auto; border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 0.875rem 1.125rem;
  font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-secondary); background: var(--bg-default);
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
td {
  padding: 0.875rem 1.125rem; font-size: 0.8125rem;
  border-bottom: 1px solid var(--bg-secondary); color: #334155;
  vertical-align: middle;
}
tr { transition: background 0.15s ease; }
tr:hover td { background: var(--bg-default); }
tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.1875rem 0.625rem; border-radius: 9999px;
  font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-blue { background: var(--primary-lighter); color: var(--primary); }
.badge-green { background: var(--success-light); color: #166534; }
.badge-red { background: var(--error-light); color: #991b1b; }
.badge-yellow { background: var(--accent-lighter); color: var(--accent-dark); }
.badge-gray { background: var(--bg-secondary); color: var(--text-secondary); }
.badge-purple { background: #f3e8ff; color: var(--ai); }
.badge-indigo { background: #e0e7ff; color: #3730a3; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.5625rem 1.125rem; border-radius: var(--radius-sm);
  font-size: 0.8125rem; font-weight: 550;
  cursor: pointer; border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 3px rgba(27, 79, 114, 0.3);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(27, 79, 114, 0.35); }

.btn-accent {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 3px rgba(243, 156, 18, 0.3);
}
.btn-accent:hover { background: var(--accent-dark); box-shadow: 0 4px 12px rgba(243, 156, 18, 0.35); }

.btn-danger {
  background: var(--error);
  color: white;
  box-shadow: 0 1px 3px rgba(231, 76, 60, 0.3);
}
.btn-danger:hover { background: #c0392b; box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35); }

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 1px 3px rgba(39, 174, 96, 0.3);
}
.btn-success:hover { background: #229954; }

.btn-secondary {
  background: white; color: #374151;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.btn-secondary:hover { background: var(--bg-default); border-color: #9ca3af; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; border-radius: 6px; }
.btn-icon {
  padding: 0.375rem; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); transition: all 0.2s ease;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--bg-secondary); color: var(--text); }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 1.125rem; }

label {
  display: block; font-size: 0.8125rem; font-weight: 550;
  color: #374151; margin-bottom: 0.375rem;
  letter-spacing: 0.01em;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="date"],
input[type="datetime-local"], input[type="tel"], input[type="search"],
select, textarea {
  width: 100%; padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  font-size: 0.875rem; font-family: inherit;
  color: var(--text); background: var(--bg-root);
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-appearance: none; appearance: none;
}
input::placeholder, textarea::placeholder {
  color: var(--text-disabled); font-weight: 400;
}
input:hover, select:hover, textarea:hover {
  border-color: var(--primary-light);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 79, 114, 0.12), 0 1px 2px rgba(0, 0, 0, 0.04);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-default); color: var(--text-disabled); cursor: not-allowed;
  border-color: var(--border);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* Custom Select Dropdown */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236C757D' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
  cursor: pointer;
  line-height: 1.5;
  min-height: 42px;
}
select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231B4F72' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
select option {
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text);
  background: white;
  line-height: 1.6;
}
select option:checked {
  background: var(--primary-lighter);
  color: var(--primary);
}
select option[value=""] {
  color: var(--text-disabled);
  font-style: italic;
}
select:invalid { color: var(--text-disabled); }

input[type="checkbox"], input[type="radio"] {
  width: auto; appearance: auto; -webkit-appearance: auto;
}

/* ===== SPINNER ===== */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4rem 1.5rem; color: var(--text-disabled);
}

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 1.25rem; right: 1.25rem;
  padding: 0.875rem 1.25rem; border-radius: var(--radius-md);
  font-size: 0.8125rem; font-weight: 500; z-index: 100;
  animation: slideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex; align-items: center; gap: 0.5rem;
  max-width: 380px;
}
.toast-success { background: var(--success-light); color: #166534; border: 1px solid #a9dfbf; }
.toast-error { background: var(--error-light); color: #991b1b; border: 1px solid #f5b7b1; }

/* ===== TABS ===== */
.tab-btn {
  padding: 0.625rem 1.125rem;
  font-size: 0.8125rem; font-weight: 500;
  border: none; background: none; cursor: pointer;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  transition: all 0.2s ease; white-space: nowrap;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover { color: var(--text); background: var(--bg-default); }

/* ===== LOGIN / SIGNUP PAGE ===== */
.auth-bg {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-lighter) 0%, #D4E6F1 30%, #D6EAF8 60%, #EBF5FB 100%);
  background-size: 400% 400%;
  animation: gradientShift 12s ease infinite;
  padding: 1.5rem; position: relative;
}
.auth-bg::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(27, 79, 114, 0.06) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(243, 156, 18, 0.04) 0%, transparent 50%);
  pointer-events: none;
}
.auth-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.8);
  width: 100%; max-width: 440px;
  padding: 2.5rem;
  position: relative; z-index: 1;
}
.auth-logo {
  width: 4rem; height: 4rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.25rem;
  box-shadow: 0 8px 24px rgba(27, 79, 114, 0.25);
}
.auth-title { font-size: 1.625rem; font-weight: 700; color: var(--text); text-align: center; }
.auth-subtitle { font-size: 0.875rem; color: var(--text-secondary); text-align: center; margin-top: 0.375rem; }
.auth-alert {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  font-size: 0.8125rem; margin-bottom: 1.25rem;
  display: flex; align-items: flex-start; gap: 0.5rem; line-height: 1.5;
}
.auth-alert-error { background: var(--error-light); color: #991b1b; border: 1px solid #f5b7b1; }
.auth-alert-success { background: var(--success-light); color: #166534; border: 1px solid #a9dfbf; }
.auth-footer {
  text-align: center; font-size: 0.8125rem;
  color: var(--text-secondary); margin-top: 1.5rem;
}
.auth-footer a { color: var(--primary); font-weight: 500; text-decoration: none; transition: color 0.15s; }
.auth-footer a:hover { color: var(--primary-dark); text-decoration: underline; }
.auth-note {
  text-align: center; font-size: 0.75rem;
  color: var(--text-disabled); margin-top: 0.75rem;
  line-height: 1.5; padding: 0 0.5rem;
}
.auth-card input[type="text"], .auth-card input[type="email"],
.auth-card input[type="password"], .auth-card input[type="tel"] {
  padding: 0.75rem 1rem; border-radius: var(--radius-md);
  font-size: 0.875rem; border: 1.5px solid var(--border); background: var(--bg-default);
}
.auth-card input:focus { background: white; border-color: var(--primary); }
.auth-card .btn-primary {
  padding: 0.75rem 1.5rem; font-size: 0.9375rem; font-weight: 600;
  border-radius: var(--radius-md); width: 100%; justify-content: center; margin-top: 0.5rem;
}

/* ===== WIZARD / STEPPER ===== */
.wizard-container { min-height: calc(100vh - 120px); display: flex; flex-direction: column; }

.wizard-header {
  background: white; border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem; display: flex; align-items: center; gap: 1rem;
}
.wizard-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--text); flex: 1; }

.wizard-stepper {
  background: white; border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
}
.wizard-steps {
  display: flex; align-items: flex-start; justify-content: space-between;
  max-width: 800px; margin: 0 auto;
}
.wizard-step {
  display: flex; flex-direction: column; align-items: center;
  flex: 0 0 auto; width: 100px; text-align: center; position: relative;
}
.wizard-step-circle {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem; font-weight: 600;
  transition: all 0.3s ease; margin-bottom: 0.5rem;
  border: 2px solid var(--border); color: var(--text-disabled); background: white;
}
.wizard-step.active .wizard-step-circle {
  background: var(--primary); color: white; border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(27, 79, 114, 0.3);
}
.wizard-step.completed .wizard-step-circle {
  background: var(--success); color: white; border-color: var(--success);
}
.wizard-step-title {
  font-size: 0.6875rem; font-weight: 500; color: var(--text-disabled);
  line-height: 1.3;
}
.wizard-step.active .wizard-step-title { color: var(--primary); font-weight: 600; }
.wizard-step.completed .wizard-step-title { color: var(--success); }

.wizard-step-line {
  flex: 1; height: 2px; background: var(--border);
  margin-top: 18px; margin-left: -12px; margin-right: -12px;
  transition: background 0.3s ease;
}
.wizard-step-line.completed { background: var(--success); }

.wizard-progress {
  margin-top: 1rem; max-width: 800px; margin-left: auto; margin-right: auto;
}
.wizard-progress-bar {
  height: 4px; border-radius: 2px; background: var(--border); overflow: hidden;
}
.wizard-progress-fill {
  height: 100%; border-radius: 2px; background: var(--primary);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.wizard-progress-text {
  display: flex; justify-content: space-between;
  margin-top: 0.5rem; font-size: 0.75rem;
}
.wizard-progress-text span:first-child { color: var(--text-secondary); }
.wizard-progress-text span:last-child { color: var(--primary); font-weight: 600; }

.wizard-body {
  flex: 1; padding: 2rem; overflow-y: auto;
  max-width: 900px; margin: 0 auto; width: 100%;
}
.wizard-section-title {
  font-size: 1.375rem; font-weight: 700; color: var(--text);
  margin-bottom: 0.375rem;
}
.wizard-section-desc {
  font-size: 0.875rem; color: var(--text-secondary);
  margin-bottom: 1.75rem;
}

.wizard-footer {
  background: white; border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex; justify-content: space-between; align-items: center;
}

/* Wizard Cards */
.wizard-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 1.25rem;
  margin-bottom: 0.75rem;
  transition: all 0.15s ease;
}
.wizard-card:hover { border-color: #cbd5e1; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }

.wizard-card-header {
  display: flex; align-items: center; gap: 0.75rem;
  cursor: pointer;
}
.wizard-card-number {
  width: 2rem; height: 2rem; border-radius: var(--radius-sm);
  background: var(--primary-lighter); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem; font-weight: 700; flex-shrink: 0;
}
.wizard-card-actions {
  display: flex; gap: 0.25rem; margin-left: auto;
}

/* Lesson type cards */
.type-card {
  border: 2px solid var(--border); border-radius: var(--radius-md);
  padding: 1rem; text-align: center; cursor: pointer;
  transition: all 0.2s ease;
}
.type-card:hover { border-color: var(--primary-light); }
.type-card.selected {
  border-color: var(--primary); background: var(--primary-lighter);
}
.type-card-icon {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.5rem;
  background: var(--bg-secondary); color: var(--text-secondary);
}
.type-card.selected .type-card-icon {
  background: var(--primary); color: white;
}

/* ===== COURSE CARDS ===== */
.course-card {
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 1.25rem;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.course-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

/* ===== UPLOAD AREA ===== */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius-md);
  padding: 2rem; text-align: center; cursor: pointer;
  transition: all 0.2s ease; margin-top: 0.5rem;
  background: var(--bg-default);
}
.upload-area:hover {
  border-color: var(--primary); background: var(--primary-lighter);
}

/* ===== CONTENT MODE TABS ===== */
.content-mode-tabs {
  display: flex; border: 1.5px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; margin-top: 0.25rem;
}
.content-mode-tab {
  flex: 1; padding: 0.5rem 0.75rem; border: none; background: white;
  cursor: pointer; font-size: 0.8125rem; font-weight: 550;
  color: var(--text-secondary); display: flex; align-items: center;
  justify-content: center; gap: 0.375rem;
  transition: all 0.2s ease;
}
.content-mode-tab:first-child { border-right: 1.5px solid var(--border); }
.content-mode-tab:hover { background: var(--bg-default); }
.content-mode-tab.active {
  background: var(--primary); color: white;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-disabled); }

/* ===== UTILITY ===== */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 768px) {
  .auth-card { padding: 1.75rem; max-width: 100%; }
  .auth-title { font-size: 1.375rem; }
  .wizard-steps { gap: 0.25rem; }
  .wizard-step { width: 70px; }
}
