/* CSS Reset & Variable Definitions */
:root {
  --bg-dark: #eaf6f0; /* Soft Macaron Mint Green */
  --bg-panel: rgba(255, 255, 255, 0.7); /* Translucent white glass */
  --bg-card: rgba(255, 255, 255, 0.45);
  --bg-card-hover: rgba(255, 255, 255, 0.85);
  --border-glass: rgba(0, 0, 0, 0.05);
  --border-glass-bright: rgba(0, 0, 0, 0.1);
  
  --text-primary: #1e293b; /* Deep slate */
  --text-secondary: #475569; /* Slate secondary */
  --text-muted: #64748b; /* Slate muted */
  
  --primary: #f06a28; /* Warm Brand Orange from Logo */
  --primary-light: #f7854d;
  --primary-glow: rgba(240, 106, 40, 0.15);
  --primary-hover: #d85616;
  
  --accent: #5c60f5; /* Premium Indigo Accent */
  --accent-glow: rgba(92, 96, 245, 0.12);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.12);
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-glow: rgba(244, 63, 94, 0.12);

  --font-display: 'Resource Han Rounded CN', system-ui, sans-serif;
  --font-body: 'Resource Han Rounded CN', system-ui, sans-serif;
  
  --shadow-premium: 0 20px 40px -15px rgba(12, 45, 28, 0.06), 0 0 30px 0 rgba(240, 106, 40, 0.02);
  --shadow-inset: inset 0 1px 0 0 rgba(255, 255, 255, 0.6);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Base custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.16);
}

/* Ambient Lights in Background */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.75;
}
.glow-1 {
  width: 50vw;
  height: 50vw;
  left: -10vw;
  top: -10vw;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  animation: floatGlow 20s infinite alternate;
}
.glow-2 {
  width: 60vw;
  height: 60vw;
  right: -15vw;
  bottom: -15vw;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  animation: floatGlow 25s infinite alternate-reverse;
}

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(3%, 5%) scale(1.1); }
  100% { transform: translate(-2%, -3%) scale(0.95); }
}

/* App Header Section */
.app-header {
  backdrop-filter: blur(16px);
  background-color: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 2rem; /* slightly tighter header padding to look highly premium with the logo */
}
.header-container {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
}
.logo-divider {
  width: 1.5px;
  height: 22px;
  background: rgba(30, 41, 59, 0.15);
  margin: 0 0.5rem;
  display: inline-block;
}
.logo-text {
  font-family: var(--font-body);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--primary);
}
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.admin-login-screen {
  min-height: 100vh;
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
}
.admin-login-card {
  width: min(100%, 420px);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium), var(--shadow-inset);
  padding: 2rem;
  backdrop-filter: blur(14px);
}
.admin-login-logo {
  height: 52px;
  width: auto;
  object-fit: contain;
  display: block;
  margin-bottom: 1.4rem;
}
.admin-login-card h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.2;
  margin-bottom: 0.45rem;
}
.admin-login-card > p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 1.5rem;
}
.admin-login-submit {
  width: 100%;
}
.admin-login-error {
  color: var(--danger);
  background: var(--danger-glow);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  font-size: 0.85rem;
  margin: -0.4rem 0 1rem;
}

/* Premium Buttons Styling */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  box-shadow: var(--shadow-inset);
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px -4px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px -2px var(--primary-glow);
  filter: brightness(1.1);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  border-color: var(--border-glass-bright);
}
.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}
.btn-tertiary {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  box-shadow: none;
}
.btn-tertiary:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}
.btn-icon {
  width: 18px;
  height: 18px;
}

/* Admin Access */
.admin-only {
  display: none !important;
}
body.is-admin-page.is-admin-authenticated .admin-only:not(.hidden) {
  display: inline-flex !important;
}
body.is-admin-page.is-admin-authenticated .modal-overlay.admin-only:not(.hidden) {
  display: flex !important;
}
body.is-admin-page:not(.is-admin-authenticated) .app-header,
body.is-admin-page:not(.is-admin-authenticated) .app-main {
  display: none;
}

/* App Main Container */
.app-main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* Toolbar & Filters */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}
.filter-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.25rem;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.filter-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.toolbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex: 0 1 auto;
  gap: 1.25rem;
  min-width: 0;
}
.category-filter,
.category-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-inset);
  backdrop-filter: blur(8px);
}
.category-filter-btn,
.category-picker-btn {
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.65rem 1rem;
  transition: all 0.25s ease;
  white-space: nowrap;
}
.category-filter-btn:hover,
.category-picker-btn:hover {
  color: var(--primary);
  background: rgba(240, 106, 40, 0.06);
}
.category-filter-btn.active,
.category-picker-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  box-shadow: 0 4px 16px -6px var(--primary-glow);
}
#course-type-filter .category-filter-btn[data-value="thinking"]:hover {
  color: #5c60f5;
  background: rgba(92, 96, 245, 0.08);
}
#course-type-filter .category-filter-btn[data-value="puzzle"]:hover {
  color: #047857;
  background: rgba(16, 185, 129, 0.1);
}
#course-type-filter .category-filter-btn[data-value="logic"]:hover {
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
}
#course-type-filter .category-filter-btn.active[data-value="thinking"] {
  color: #fff;
  background: rgba(92, 96, 245, 0.82);
  box-shadow: 0 8px 22px -10px rgba(92, 96, 245, 0.8);
}
#course-type-filter .category-filter-btn.active[data-value="puzzle"] {
  color: #fff;
  background: rgba(16, 185, 129, 0.84);
  box-shadow: 0 8px 22px -10px rgba(16, 185, 129, 0.8);
}
#course-type-filter .category-filter-btn.active[data-value="logic"] {
  color: #fff;
  background: rgba(245, 158, 11, 0.88);
  box-shadow: 0 8px 22px -10px rgba(245, 158, 11, 0.8);
}
.category-picker {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: none;
}
.category-picker-btn {
  transition: color 0.12s ease;
}
.category-picker-btn.active {
  background-color: var(--primary);
  background-image: none;
  box-shadow: none;
}
.module-dropdown {
  position: relative;
  min-width: 170px;
}
.module-dropdown-toggle {
  width: 100%;
  min-height: 2.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem 0.65rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  outline: none;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: var(--shadow-inset);
  backdrop-filter: blur(8px);
}
.module-dropdown-toggle:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-inset), 0 0 15px -3px var(--primary-glow);
}
.module-dropdown-toggle:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-inset), 0 0 15px -3px var(--primary-glow);
}
.module-dropdown.open .module-dropdown-toggle {
  border-color: var(--primary);
  box-shadow: var(--shadow-inset), 0 0 15px -3px var(--primary-glow);
}
.module-dropdown-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.module-dropdown-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #94a3b8;
  transition: transform 0.2s ease, color 0.2s ease;
}
.module-dropdown.open .module-dropdown-icon {
  color: var(--primary);
  transform: rotate(180deg);
}
.module-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  right: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 240px;
  padding: 0.35rem;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 36px -24px rgba(15, 23, 42, 0.38), var(--shadow-inset);
  backdrop-filter: blur(8px);
}
.module-dropdown.open .module-dropdown-menu {
  display: flex;
}
.module-dropdown-option {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.72rem 0.8rem;
  text-align: left;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.module-dropdown-option:hover,
.module-dropdown-option:focus {
  color: var(--primary);
  background: rgba(240, 106, 40, 0.06);
  outline: none;
}
.module-dropdown-option.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 16px -6px var(--primary-glow);
}
.search-bar {
  position: relative;
  flex: 0 1 330px;
  max-width: 330px;
  min-width: 240px;
}
.search-bar input {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s;
  backdrop-filter: blur(8px);
}
.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 15px -3px var(--primary-glow);
}

.sort-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sort-selector label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
}
.sort-dropdown {
  min-width: 132px;
}

/* Card Grid Layout */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  position: relative;
  min-height: 200px;
}

.grid-container.admin-course-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.course-row[hidden] {
  display: none !important;
}

.course-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  width: 100%;
  min-height: 132px;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-premium), var(--shadow-inset);
  backdrop-filter: blur(12px);
}

.course-row-thumb {
  width: 132px;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.68);
}

.course-row-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.course-row-main {
  min-width: 0;
}

.course-row-title-line {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  margin-bottom: 0.32rem;
}

.course-row-title {
  min-width: 0;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-row-intro {
  max-width: 720px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.65rem;
}

.course-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.row-meta-pill,
.course-row-status {
  display: inline-flex;
  align-items: center;
  max-width: 180px;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta-pill.type {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-muted);
}

.row-meta-pill.type.thinking {
  background: rgba(92, 96, 245, 0.08);
  color: var(--accent);
}

.row-meta-pill.type.puzzle {
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
}

.row-meta-pill.type.logic {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
}

.row-meta-pill.module {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-muted);
}

.course-row-status.ready {
  justify-content: center;
  min-width: 1.65rem;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-muted);
}

.course-row-status-icon {
  width: 0.78rem;
  height: 0.78rem;
  display: block;
}

.course-row-status.pending {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-muted);
}

.course-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  min-width: max-content;
}

.btn-row-action {
  min-width: 64px;
  padding: 0.52rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.btn-row-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* Courseware Cards CSS */
.courseware-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-premium), var(--shadow-inset);
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  flex-direction: column;
  min-height: 300px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.courseware-card.is-placeholder {
  cursor: default;
}

.courseware-card[hidden] {
  display: none !important;
}

.courseware-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity 0.4s;
}

.courseware-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glass-bright);
  transform: translateY(-6px);
  box-shadow: 0 25px 45px -12px rgba(12, 45, 28, 0.12), 0 0 25px 0 rgba(240, 106, 40, 0.08);
}

.courseware-card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.card-header.has-cover {
  display: block;
  aspect-ratio: 16 / 9;
  margin: -1.25rem -1.25rem 1rem;
  overflow: hidden;
  position: relative;
}

.card-header.has-cover .btn-delete-card {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
}

.card-header.has-cover .card-actions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}

.card-cover {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.04);
}

.card-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.card-type-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: inline-flex;
  align-items: center;
  max-width: calc(100% - 5.75rem);
  min-height: 1.75rem;
  padding: 0.28rem 0.68rem;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 999px;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
  z-index: 4;
}

.card-type-badge.thinking {
  background: rgba(92, 96, 245, 0.76);
}

.card-type-badge.puzzle {
  background: rgba(16, 185, 129, 0.78);
}

.card-type-badge.logic {
  background: rgba(245, 158, 11, 0.82);
}

.card-icon-box {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(240, 106, 40, 0.08);
  border: 1px solid rgba(240, 106, 40, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  transition: all 0.3s;
}

.courseware-card:hover .card-icon-box {
  background: var(--primary);
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(240, 106, 40, 0.2);
}

.card-icon {
  width: 24px;
  height: 24px;
}

/* Card Action Buttons */
.card-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  z-index: 5;
}
.btn-delete-card,
.btn-edit-card {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5; /* click capability override */
}
.btn-edit-card:hover {
  background: var(--accent-glow);
  color: var(--accent);
  transform: scale(1.1);
}
.btn-delete-card:hover {
  background: var(--danger-glow);
  color: var(--danger);
  transform: scale(1.1);
}
.btn-delete-card svg,
.btn-edit-card svg {
  width: 18px;
  height: 18px;
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.55rem;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  word-break: normal;
  display: block;
  height: 1.62rem;
  overflow: hidden;
  margin-bottom: 0;
}

.card-intro {
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.45;
  height: 2.5rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: -0.15rem;
}

.card-intro.is-empty {
  visibility: hidden;
}

/* Loading Spinner */
.loading-spinner-container {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 0;
  color: var(--text-secondary);
  gap: 1rem;
}
.spinner {
  width: 45px;
  height: 45px;
  border: 3.5px solid rgba(0, 0, 0, 0.05);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State Styling */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem;
  background: var(--bg-panel);
  border: 1px dashed var(--border-glass-bright);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  max-width: 600px;
  margin: 2rem auto;
  box-shadow: var(--shadow-premium);
}
.empty-icon-container {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-glass);
}
.empty-icon {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
}
.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.empty-state p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  max-width: 400px;
}

/* Modal Windows Setup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(12, 30, 20, 0.35);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s;
}

.course-drawer-overlay {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 30px 60px -15px rgba(12, 45, 28, 0.15), 0 0 50px 0 rgba(240, 106, 40, 0.04);
  padding: 2rem;
  animation: modalScaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  color: var(--text-primary);
}

.course-drawer-card {
  width: min(100%, 560px);
  max-width: 560px;
  height: 100vh;
  max-height: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  padding: 2rem;
  animation: drawerSlideIn 0.28s ease-out;
}

@keyframes drawerSlideIn {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes modalScaleUp {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  transition: color 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  line-height: 1;
}
.btn-close:hover {
  color: var(--danger);
}

/* Forms CSS */
.form-group {
  margin-bottom: 1.5rem;
}
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.label-row label {
  margin-bottom: 0;
}
.label-optional {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}
.required-mark {
  color: var(--danger);
  font-weight: 700;
}
.char-count {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.char-count.is-over {
  color: var(--danger);
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
  width: 100%;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s;
}
.form-group textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.55;
}
.native-select-proxy {
  display: none;
}
.course-module-dropdown {
  width: 100%;
}
.form-group select {
  cursor: pointer;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 16px;
  padding-right: 2.4rem;
}
.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 15px -3px var(--primary-glow);
}
.form-group input[type="text"].is-invalid,
.form-group textarea.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 15px -3px var(--danger-glow);
}

.field-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.55rem;
}

/* Optional Cover Upload */
.cover-upload-zone {
  min-height: 118px;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}
.cover-upload-zone:hover {
  border-color: var(--primary-light);
  background: rgba(240, 106, 40, 0.04);
  box-shadow: 0 0 18px rgba(240, 106, 40, 0.05);
}
.cover-upload-placeholder {
  height: 100%;
  min-height: 118px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.2rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.82rem;
}
.cover-upload-icon {
  width: 34px;
  height: 34px;
  color: var(--primary-light);
}
.cover-preview {
  position: absolute;
  inset: 0;
  background: #ffffff;
}
.cover-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.cover-file-name {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  max-width: calc(100% - 4.5rem);
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}
.btn-remove-cover {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  transition: all 0.3s;
  backdrop-filter: blur(8px);
}
.btn-remove-cover:hover {
  background: var(--danger-glow);
  color: var(--danger);
}

/* Custom Drag and Drop zone */
.drag-drop-zone {
  border: 2px dashed rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-md);
  padding: 2.2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.02);
  transition: all 0.3s;
  position: relative;
}
.drag-drop-zone.dragover {
  border-color: var(--primary-light);
  background: rgba(240, 106, 40, 0.06);
  box-shadow: 0 0 20px rgba(240, 106, 40, 0.05);
}
.hidden-file-input {
  display: none;
}
.upload-cloud-icon {
  width: 42px;
  height: 42px;
  color: var(--text-muted);
  margin-bottom: 1rem;
  transition: color 0.3s, transform 0.3s;
}
.drag-drop-zone:hover .upload-cloud-icon,
.drag-drop-zone.dragover .upload-cloud-icon {
  color: var(--primary-light);
  transform: translateY(-3px);
}
.drag-text-main {
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--text-secondary);
}
.drag-text-main span {
  color: var(--primary-light);
  text-decoration: underline;
  font-weight: 600;
}
.drag-text-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* File Selected Status Inside D&D Area */
.file-status {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease-out;
}
.file-icon {
  width: 32px;
  height: 32px;
  color: var(--primary-light);
}
.file-name {
  font-weight: 600;
  font-size: 0.95rem;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-remove-file {
  background: rgba(0, 0, 0, 0.04);
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}
.btn-remove-file:hover {
  background: var(--danger-glow);
  color: var(--danger);
}

/* Upload Progress */
.upload-progress-container {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.2s ease-out;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}
.progress-status {
  color: var(--text-secondary);
}
.progress-percent {
  font-weight: 700;
  color: var(--accent);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 2rem;
}

.module-modal-card {
  max-width: 560px;
}

.module-name-group {
  margin-bottom: 1rem;
}

.inline-form-row {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.inline-form-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.inline-form-row .btn {
  flex: 0 0 auto;
  min-width: 72px;
  white-space: nowrap;
}

.module-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1rem;
}

.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.018);
}

.module-row-name {
  min-width: 0;
  color: var(--text-primary);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-row-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
}

.module-system-badge {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
}

/* Courseware Player Overlay */
.player-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-dark);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.player-controls {
  height: 60px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 1010;
}
.player-title {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.action-btn {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}
.action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.action-btn.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.action-btn svg {
  width: 18px;
  height: 18px;
}

.simulator-wrapper {
  flex: 1;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: auto;
  position: relative;
}

.device-frame {
  background: #000;
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9);
  transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), 
              height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), 
              border-radius 0.4s ease, 
              border 0.4s ease;
  position: relative;
}

.device-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.player-overlay.fullscreen-mode {
  padding: 0;
}
.player-overlay.fullscreen-mode .player-controls {
  display: none;
}
.player-overlay.fullscreen-mode .simulator-wrapper {
  padding: 0;
}
.player-overlay.fullscreen-mode .device-frame {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  border-radius: 0 !important;
}

/* Floating close helper in fullscreen playback */
.btn-exit-fullscreen-helper {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  z-index: 2000;
  transition: background 0.3s, transform 0.3s;
}
.btn-exit-fullscreen-helper:hover {
  background: var(--danger);
  transform: scale(1.1);
}

/* Toast Notifications System */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 2000;
}
.toast {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  color: var(--text-primary);
  backdrop-filter: blur(10px);
  box-shadow: 0 15px 35px -5px rgba(12, 45, 28, 0.1);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 250px;
  max-width: 400px;
  animation: toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition: all 0.3s;
}

@keyframes toastSlideIn {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success {
  border-left-color: var(--success);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast.info {
  border-left-color: var(--primary);
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .toolbar {
    align-items: stretch;
  }
  .toolbar-actions {
    flex: 1 1 100%;
    width: 100%;
    justify-content: flex-end;
  }
  .course-row {
    grid-template-columns: 112px minmax(0, 1fr);
  }
  .course-row-thumb {
    width: 112px;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  .course-row-actions {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: flex-end;
  }
}

/* Responsive Utilities */
@media (max-width: 640px) {
  .app-header {
    padding: 1rem;
  }
  .header-container {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  .header-actions {
    width: 100%;
    justify-content: center;
  }
  .logo-area {
    justify-content: center;
  }
  .app-main {
    padding: 1.5rem 1rem;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .filter-stack,
  .filter-group {
    width: 100%;
    align-items: stretch;
  }
  .filter-group {
    flex-direction: column;
    gap: 0.4rem;
  }
  .toolbar-actions {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    gap: 1rem;
  }
  .category-filter,
  .category-picker,
  .module-dropdown {
    width: 100%;
  }
  .category-filter-btn,
  .category-picker-btn {
    flex: 1;
    padding-inline: 0.55rem;
  }
  .course-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 0.9rem;
  }
  .course-row-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  .course-row-title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.4rem;
  }
  .course-row-title,
  .course-row-intro {
    white-space: normal;
  }
  .course-row-intro {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .course-row-actions {
    justify-content: stretch;
  }
  .btn-row-action {
    flex: 1;
    min-width: 0;
  }
  .course-drawer-overlay {
    align-items: flex-end;
  }
  .course-drawer-card {
    width: 100%;
    max-width: none;
    height: min(92vh, 780px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .search-bar {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  .sort-selector {
    justify-content: space-between;
  }
  .inline-form-row {
    flex-direction: column;
  }
  .module-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .module-row-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
