:root {
  --primary-color: #1e293b;
  --accent-color: #d81b60;
  --bg-light: #f8f9fa;
  --text-dark: #333333;
  --text-light: #ffffff;
  --success-color: #2e7d32;
  --danger-color: #c62828;
}

* {
  box-sizing: border-box;
  font-family: "Assistant", sans-serif;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-light);
  color: var(--text-dark);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.btn {
  align-items: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-size: 1rem;
  font-weight: 600;
  gap: 8px;
  justify-content: center;
  padding: 8px 15px;
  transition: background 0.2s;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.btn-primary {
  background: var(--accent-color);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: #b0154d;
}

.btn-secondary {
  background: #64748b;
  color: #ffffff;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-danger {
  background: var(--danger-color);
  color: #ffffff;
}

.btn-danger:hover {
  background: #a81d1d;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid #ffffff;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.btn-outline:hover {
  background: #ffffff;
  color: var(--primary-color);
  text-shadow: none;
}

.full-width {
  width: 100%;
}

#toast {
  background: #333333;
  border-radius: 8px;
  bottom: 20px;
  color: #ffffff;
  opacity: 0;
  padding: 15px 25px;
  pointer-events: none;
  position: fixed;
  right: 20px;
  transition: opacity 0.3s;
  z-index: 10000;
}

#toast.show {
  opacity: 1;
}

.file-mode-warning {
  align-items: center;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #7c2d12;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 10px 16px;
  position: relative;
  text-align: center;
  z-index: 850;
}

.file-mode-warning strong {
  color: #9a3412;
}

.file-mode-warning a {
  color: #b0154d;
  direction: ltr;
  font-weight: 800;
}

#initial-loader {
  align-items: center;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  left: 0;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 9999;
}

#loader-text {
  color: var(--primary-color);
}

.spinner {
  animation: spin 1s linear infinite;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top: 4px solid var(--accent-color);
  height: 50px;
  margin-bottom: 20px;
  width: 50px;
}

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

#auth-section {
  align-items: center;
  background-image: url("/public/hero.jpg");
  background-position: center;
  background-size: cover;
  display: none;
  flex-grow: 1;
  justify-content: center;
  padding: 20px;
  position: relative;
  width: 100%;
}

#auth-section::before {
  background: rgba(0, 0, 0, 0.5);
  content: "";
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
}

.auth-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  padding: 40px;
  position: relative;
  text-align: center;
  width: 100%;
  z-index: 5;
}

.auth-card h2 {
  color: var(--primary-color);
  margin-bottom: 25px;
}

.auth-brand-title {
  color: var(--accent-color);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 10px;
}

.input-group {
  margin-bottom: 15px;
  text-align: right;
}

.input-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.input-group input {
  border: 1px solid #dddddd;
  border-radius: 6px;
  font-size: 1rem;
  padding: 10px;
  width: 100%;
}

#app-section {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.site-header-container {
  background-image: url("/public/hero.jpg");
  background-position: center;
  background-size: cover;
  color: #ffffff;
  position: relative;
  width: 100%;
}

.site-header-container::before {
  background: rgba(0, 0, 0, 0.4);
  content: "";
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 1;
}

.app-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1200px;
  padding: 30px 40px;
  position: relative;
  width: 100%;
  z-index: 2;
}

.app-header h1 {
  color: #fca311;
  font-size: 2.5rem;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

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

.user-name {
  font-size: 1.2rem;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.logout-btn {
  background: none;
  border: none;
  color: #eeeeee;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.logout-btn:hover {
  color: var(--accent-color);
}

.hero-banner {
  backdrop-filter: blur(2px);
  background-color: rgba(30, 41, 59, 0.84);
  color: #ffffff;
  padding: 20px 40px;
  position: relative;
  width: 100%;
  z-index: 2;
}

.hero-banner-content {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1200px;
  width: 100%;
}

.hero-banner h2 {
  font-size: 1.6rem;
  font-weight: 600;
}

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

.topic-section {
  margin-bottom: 50px;
}

.topic-header {
  align-items: center;
  border-bottom: 1px solid var(--accent-color);
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
  padding-bottom: 8px;
}

.topic-title {
  color: var(--primary-color);
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
}

.order-controls {
  display: flex;
  gap: 5px;
}

.order-btn {
  background: #e2e8f0;
  border: none;
  border-radius: 4px;
  color: #475569;
  cursor: pointer;
  padding: 4px 8px;
  transition: 0.2s;
}

.order-btn:hover {
  background: #cbd5e1;
  color: #0f172a;
}

.modules-grid {
  display: grid;
  gap: 30px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  margin-bottom: 50px;
}

.module-card {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.module-img {
  background: #eeeeee;
  height: 160px;
  width: 100%;
}

.module-content {
  display: flex;
  flex-grow: 1;
  flex-direction: column;
  padding: 20px;
}

.module-tag {
  align-self: flex-start;
  background: #e0e0e0;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 10px;
  padding: 3px 8px;
}

.module-title {
  color: var(--primary-color);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.module-desc {
  color: #666666;
  flex-grow: 1;
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.module-footer {
  align-items: center;
  border-top: 1px solid #eeeeee;
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 15px;
}

.admin-card-tools {
  align-items: center;
  background: #f8fafc;
  border-top: 1px dashed #cbd5e1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 20px;
}

.admin-action-group {
  display: flex;
  gap: 5px;
}

.admin-card-tools .btn {
  font-size: 0.85rem;
  padding: 4px 8px;
}

.inactive-card {
  filter: grayscale(0.8);
  opacity: 0.6;
}

#settings-management-view {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.24);
  display: none;
  left: 50%;
  margin: 0;
  max-width: 700px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 25px;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  z-index: 950;
}

.settings-backdrop {
  background: rgba(15, 23, 42, 0.42);
  inset: 0;
  position: fixed;
  z-index: 900;
}

body.settings-open .site-header-container,
body.settings-open #course-view {
  filter: grayscale(0.15);
  pointer-events: none;
  user-select: none;
}

.settings-window-title {
  color: var(--primary-color);
  margin: 0 0 22px;
  padding-left: 44px;
}

.settings-section {
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 25px;
  padding-bottom: 25px;
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-section h2 {
  color: var(--primary-color);
  margin-bottom: 15px;
}

.settings-section p {
  color: #555555;
  font-size: 0.95rem;
  margin-bottom: 15px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
}

#current-cloud-user-pass {
  background: #f1f5f9;
}

.settings-password-grid {
  align-items: end;
  margin-bottom: 0;
}

.settings-submit-group {
  justify-content: flex-end;
}

.settings-submit-group .btn {
  height: 45px;
}

.header-image-preview {
  background-image: url("/public/hero.jpg");
  background-position: center;
  background-size: cover;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  height: 120px;
  margin-top: 8px;
  overflow: hidden;
}

.range-label-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.range-label-row output {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: var(--primary-color);
  font-size: 0.85rem;
  font-weight: 800;
  min-width: 52px;
  padding: 2px 10px;
  text-align: center;
}

#header-position-y {
  accent-color: var(--accent-color);
  cursor: pointer;
  padding: 0;
}

.range-hints {
  color: #64748b;
  display: flex;
  font-size: 0.82rem;
  justify-content: space-between;
  margin-top: 2px;
}

.settings-window-actions {
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  margin-top: 24px;
  padding-top: 18px;
}

.backup-zone {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  margin-top: 15px;
  padding: 20px;
  text-align: center;
}

.snapshot-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin: 8px 0 18px;
  padding: 16px;
}

.system-check-report {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  margin: 0 0 18px;
  padding: 16px;
}

.system-check-report h4 {
  color: var(--primary-color);
  margin-bottom: 6px;
}

.system-check-report p {
  color: #475569;
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.system-check-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.system-check-pill {
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
}

.system-check-pill span {
  font-size: 0.78rem;
  font-weight: 700;
}

.system-check-pill strong {
  font-size: 0.95rem;
}

.system-check-pill.is-ok {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.system-check-pill.is-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.snapshot-panel h4 {
  color: var(--primary-color);
  margin-bottom: 6px;
}

.snapshot-panel p {
  color: #475569;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.snapshot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.snapshot-empty {
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  color: #64748b !important;
  margin: 0 !important;
  padding: 10px;
}

.snapshot-item {
  align-items: center;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px;
}

.snapshot-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.snapshot-details strong {
  color: var(--primary-color);
}

.snapshot-details span {
  color: #64748b;
  font-size: 0.85rem;
}

.snapshot-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.snapshot-actions .btn {
  font-size: 0.85rem;
  padding: 6px 10px;
}

.backup-zone h4 {
  color: var(--primary-color);
  margin-bottom: 10px;
}

.backup-zone p {
  color: var(--danger-color);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 15px;
}

.backup-report {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  margin-top: 16px;
  padding: 14px;
  text-align: right;
}

.backup-report ul {
  margin-right: 20px;
}

.restore-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  color: #9a3412 !important;
  margin-top: 12px;
  padding: 10px;
}

.restore-backup-button {
  margin-top: 14px;
}

#module-view {
  background: #ffffff;
  display: none;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.module-view-header {
  align-items: center;
  background: var(--primary-color);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  padding: 15px 30px;
  width: 100%;
}

#course-iframe {
  background: #ffffff;
  border: none;
  flex-grow: 1;
  min-height: calc(100vh - 70px);
  width: 100%;
}

.empty-state {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  padding: 28px;
  text-align: center;
}

#module-modal {
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  height: 100%;
  justify-content: center;
  left: 0;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
}

.modal-content {
  background: #ffffff;
  border-radius: 12px;
  max-height: 90vh;
  max-width: 800px;
  overflow-y: auto;
  padding: 30px;
  position: relative;
  width: 90%;
}

.modal-close {
  background: none;
  border: none;
  color: #666666;
  cursor: pointer;
  font-size: 1.5rem;
  left: 20px;
  position: absolute;
  top: 15px;
}

#modal-title {
  color: var(--primary-color);
  margin-bottom: 20px;
}

.form-grid {
  display: grid;
  gap: 15px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 15px;
  text-align: right;
}

.form-group label {
  font-weight: 600;
}

.form-group input,
.form-group select {
  border: 1px solid #cccccc;
  border-radius: 6px;
  font-size: 1rem;
  padding: 10px;
}

.field-with-action {
  align-items: stretch;
  display: flex;
  gap: 6px;
}

.field-with-action input,
.field-with-action select {
  flex: 1;
  min-width: 0;
}

.field-trash-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid #d7dce3;
  border-radius: 6px;
  color: var(--danger-color);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 42px;
  font-size: 0.95rem;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.field-trash-button:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fecaca;
}

.field-trash-button:disabled {
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.6;
}

.module-warning-box {
  align-items: flex-start;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #7c2d12;
  display: flex;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 14px;
}

.module-warning-icon {
  align-items: center;
  background: #ffedd5;
  border-radius: 999px;
  color: #ea580c;
  display: inline-flex;
  flex: 0 0 34px;
  height: 34px;
  justify-content: center;
  margin-top: 2px;
  width: 34px;
}

.module-warning-content {
  flex: 1;
}

.module-warning-content strong {
  color: #9a3412;
  display: block;
  font-size: 1rem;
  margin-bottom: 3px;
}

.module-warning-content p {
  color: #7c2d12;
  line-height: 1.45;
  margin: 0;
}

.module-warning-close {
  background: none;
  border: none;
  color: #9a3412;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 4px;
}

#form-topic-custom,
#form-tag-custom {
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  margin-top: 20px;
}

.remove-image-button {
  display: none;
  font-size: 0.85rem;
  margin-top: 5px;
  padding: 4px 10px;
  width: max-content;
}

.preview-container {
  background: #eeeeee;
  border: 1px solid #dddddd;
  border-radius: 8px;
  display: none;
  height: 160px;
  margin: 10px 0 24px auto;
  overflow: hidden;
  width: 300px;
}

#form-image-preview {
  display: block;
  height: 100%;
  width: 100%;
}

.lesson-upload-zone {
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  margin-top: 15px;
  padding: 15px;
}

.lesson-upload-zone label {
  color: var(--accent-color);
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
}

.lesson-upload-zone p {
  color: #555555;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.lesson-upload-zone input {
  border: 1px solid #cccccc;
  border-radius: 6px;
  font-size: 1rem;
  padding: 10px;
  width: 100%;
}

@media (max-width: 720px) {
  .app-header,
  .hero-banner-content {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .app-header {
    padding: 24px 20px;
  }

  .app-header h1 {
    font-size: 2rem;
  }

  .hero-banner {
    padding: 18px 20px;
  }

  .hero-banner h2 {
    font-size: 1.35rem;
  }

  .user-controls,
  .settings-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .btn,
  .logout-btn {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column;
  }

  .snapshot-item {
    align-items: stretch;
    flex-direction: column;
  }

  .snapshot-actions {
    flex-direction: column;
  }

  .system-check-grid {
    grid-template-columns: 1fr;
  }

  .preview-container {
    width: 100%;
  }
}
