/*#region ====== Global ====== */

:root {

  /* Typography */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI",
             Roboto, Inter, Helvetica, Arial, sans-serif;

  /* Text */
  --text-main: #2f2f3a;
  --text-muted: #8b8fa3;

  /* Gray system */
  --gray-1: #ffffff;
  --gray-2: #f8f9fc;
  --gray-3: #f2f3f7;
  --gray-4: #e6e8f0;

  /* Header */
  --bg-header: var(--gray-3);

  /* Accent system */
  --accent: #6b5cff;
  --accent-hover: #5c4cf5;
  --accent-soft: rgba(107,92,255,0.08);
  --accent-soft-strong: rgba(107,92,255,0.14);
  --accent-soft-active: rgba(107,92,255,0.20);
  --accent-soft-light: rgba(107,92,255,0.06);
  --accent-soft-mid: rgba(107,92,255,0.12);

  /* Status */
  --danger: #e5484d;
  --success: #2ecc71;

}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-ui);
  color: var(--text-main);
}

.hidden {
  display: none;
}

.app-loading {
  visibility: hidden;
}

.btn {
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;

  border: 1px solid var(--gray-4);
  background: white;
  color: var(--text-main);

  cursor: pointer;

  transition: background 0.15s ease,
              opacity 0.15s ease,
              transform 0.12s ease;
}

.btn:hover {
  background: var(--gray-2);
}


/* Accent (Save / Confirm) */

.btn-accent {
  background: var(--accent);
  color: white;
  border: none;
  opacity: 0.8;
}

.btn-accent:hover:not(:disabled) {
  opacity: 1;
  background: var(--accent-hover);
}


/* Danger (Delete) */

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  opacity: 0.8;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  opacity: 1;
}


/* Disabled */

.btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/*#endregion */

/*#region ====== Header ====== */

#header {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 4px 16px;
  margin-bottom: 12px;
}

#header-title {
  text-align: center;
}

#header-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

#item-count {
  margin-left: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

#panel-toggle {
  display: flex;
  align-items: center;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/*.panel-toggle-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: white;
  cursor: pointer;
}

.panel-toggle-btn:hover {
  background: var(--gray-2);
} */

/*#endregion */

/*#region ====== Table ====== */

#item-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

#item-table thead tr {
  background: var(--bg-header);
}

#item-table th,
#item-table td {
  padding: 12px;
  font-size: 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-4);
}

#item-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

#item-table tbody tr {
  transition: background 0.15s ease, transform 0.12s ease;
}

#item-table tbody tr:hover {
  background: var(--gray-2);
}

/*#endregion */

/*#region ====== Row Actions ====== */

.actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  cursor: pointer;
  padding: 4px 6px;
  border: none;
  background: none;

  transition: transform 0.12s ease, opacity 0.15s ease;
}

.action-btn:hover {
  transform: scale(1.12);
  opacity: 0.7;
}

.action-btn.edit {
  color: var(--accent);
}

.action-btn.delete {
  color: var(--danger);
}

/*#endregion */

/*#region ====== Switch (Yes / No) ====== */

.switch-yn {
  display: inline-flex;
}

.switch-yn input {
  display: none;
}

.switch-track {
  position: relative;
  width: 64px;
  height: 24px;
  border-radius: 999px;
  background: var(--danger);
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.15);
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  color: white;
  pointer-events: none;
}

.switch-label.yes { left: 8px; opacity: 0; }
.switch-label.no  { right: 8px; opacity: 1; }

.switch-yn input:checked + .switch-track {
  background: var(--success);
}

.switch-yn input:checked + .switch-track .switch-thumb {
  transform: translateX(40px);
}

.switch-yn input:checked + .switch-track .switch-label.yes {
  opacity: 1;
}

.switch-yn input:checked + .switch-track .switch-label.no {
  opacity: 0;
}

/*#endregion */

/*#region ====== Footer / Pagination ====== */

#footer {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  padding: 12px 8px;
  font-size: 13px;
  color: #777;
  align-items: center;
}

.page-icon {
  background: none;
  border: none;
  cursor: pointer;
}

.page-icon:disabled {
  opacity: 0.4;
  cursor: default;
}

.footer-message {
  position: fixed;
  bottom: 20px;
  right: 24px;
  background: #2e7d32;
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  z-index: 9999;
}

.footer-message.show {
  opacity: 1;
  transform: translateY(0);
}

.footer-message.error {
  background: #c62828;
}

/*#endregion */

/*#region ====== Modal Base ====== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}

.modal-card {
  position: relative;
  margin: 5vh auto;
  background: white;
  border-radius: 8px;
  padding: 28px 32px 24px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-card.action {
  max-width: 520px;
  width: 90%;
}

.modal-card.edit {
  width: 95%;
  max-width: 1200px;
}

.modal-content {
  width: 100%;
  max-width: 100%;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  margin: 0;
}

.readonly-field {
  background-color: #f4f6f8;
  color: #555;
  cursor: not-allowed;
}

#edit-form {
  width: 100%;
}

.edit-field {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}

.edit-field label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.edit-field-group-row.edit-field label {
  justify-content: flex-start;
}

.edit-field input[type="text"],
.edit-field input[type="number"],
.edit-field select {
  width: 60%;
}

.edit-field.modified input,
.edit-field.modified textarea,
.edit-field.modified select {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.05);
}

.edit-field.modified label,
.modified-section {
  color: var(--accent);
  font-weight: 600;
}

.modified-field {
  border-color: var(--accent);
  background: rgba(124,92,255,0.05);
}

.lesson-header.modified-section .lesson-range-title {
  color: var(--accent);
  font-weight: 700;
}

#edit-modal {
  z-index: 1000;
}

#action-modal {
  z-index: 2000;
}

/*#endregion */

/*#region ====== Modal Content Column ====== */

.modal-content h3 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 600;
}

#modal-desc {
  font-size: 16px;
  line-height: 1.5;
  color: #555;
  margin-bottom: 20px;
}

/*#endregion */

/*#region ====== Awareness Checkbox ====== */

.modal-awareness {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
}

.modal-awareness input {
  margin-top: 2px;
}

/*#endregion */

/*#region ====== Modal Actions ====== */

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
}

/*#endregion */

/*#region ====== Review Content Editing ====== */

.content-row textarea {
  width: 100%;
}

.lesson-row {
  margin-bottom: 18px;
}

.lesson-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.lesson-header:hover {
  background: var(--gray-2);
  border-radius: 6px;
}

.lesson-range-title {
  font-size: 13px;
  font-weight: 600;
  color: #666;
  margin: 0;
}

.lesson-toggle-btn {
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
}

.lesson-content-wrapper {
  margin-top: 6px;
}

.lesson-content-wrapper.collapsed {
  display: none;
}

/*#endregion */

/*#region ====== Marketplace Content Editiong ====== */

.round-section {
  margin-bottom: 25px;
}

.round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.round-header:hover {
  background: var(--gray-2);
  border-radius: 6px;
}

.round-header h4 {
  margin: 0;
}

.round-toggle {
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
}

.round-content {
  display: none;
}

.round-content.open {
  display: block;
}

/* preview textarea */
.round-preview {
  width: 100%;
  margin-top: 10px;
}

.word-counter {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
  text-align: right;
}

/* ------ Chapter Merge ------ */

.chapter-checkbox-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.chapter-checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
}

.chapter-checkbox-row label:hover {
  background: var(--gray-2);
}

/* ------ Lesson Merge ------ */

.level-block {
  padding: 5px;
  margin-top: 5px;
}

.level-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  margin-bottom: 8px;
  padding: 4px 6px;
  border-radius: 6px;
}

.level-header:hover {
  background: var(--accent-soft);
}

.level-header.has-selection {
  background: var(--accent-soft-strong);
  font-weight: 600;
}

.level-header.has-selection:hover {
  background: var(--accent-soft-active);
}

.level-header.has-selection .level-title {
  font-weight: 700;
}

.level-title {
  font-weight: 600;
}

.level-content {
  display: none;
  margin-left: 10px;
}

.level-content.open {
  display: block;
}

.lesson-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  margin-bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
}

.lesson-group-header:hover {
  background: var(--accent-soft-light);
}

.lesson-group-header.has-selection {
  background: var(--accent-soft-mid);
  font-weight: 600;
}

.lesson-group-header.has-selection:hover {
  background: var(--accent-soft-active);
}

.lesson-group-row {
  display: none;
  margin-left: 24px;
  margin-bottom: 10px;

  flex-wrap: nowrap;
  overflow-x: auto;  
}

.lesson-group-row.open {
  display: flex;
}

.lesson-group-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  flex: 0 0 auto;
  white-space: nowrap;

  padding: 2px 4px;
  border-radius: 4px;
}

.lesson-group-row label:hover {
  background: var(--gray-2);
  border-radius: 4px;
  padding: 2px 4px;
}

.level-header span,
.lesson-group-header span {
  width: 18px;
  text-align: right;
  flex: 0 0 18px;
}

.round-layout-row {
  display: flex;
  gap: 24px;
  margin-top: 12px;
}

.round-left-panel {
  width: 50%;
  min-width: 260px;
}

.round-right-panel {
  flex: 1;
}

.round-right-panel textarea {
  width: 100%;
  height: 320px;
}

/* ------ Difficulty ------ */

.difficulty-row {
  display: flex;
  gap: 20px;
  margin: 6px 0 12px 0;
}

.difficulty-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;

  padding: 2px 6px;
  border-radius: 6px;

  transition: background 0.15s ease, transform 0.12s ease;
}

.difficulty-option:hover {
  background: var(--gray-2);
  border-radius: 6px;
  padding: 2px 6px;
}

.difficulty-option input[type="radio"] {
  transform: scale(1.2);
}

.difficulty-option input:checked + span {
  font-weight: 600;
  color: var(--accent);
}

/*#endregion */

/*#region ====== Editor ====== */

input[type="text"],
input[type="number"],
select,
textarea {
  border: 1px solid var(--gray-4);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;

  transition: border 0.12s ease, box-shadow 0.12s ease;
}

input:hover,
select:hover,
textarea:hover {
  box-shadow: 0 0 0 1px var(--gray-4);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(107,92,255,0.25);
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.lesson-toggle-btn:hover,
.round-toggle:hover {
  transform: scale(1.2);
}

.lesson-toggle-btn,
.round-toggle {
  transition: background 0.15s ease, transform 0.12s ease;
}

.level-header,
.lesson-group-header {
  transition: background 0.15s ease, transform 0.12s ease;
}

.lesson-header,
.round-header,
.level-header,
.lesson-group-header {
  background: var(--gray-2);
  border-radius: 6px;
  padding: 4px 8px;

  transition: background 0.15s ease;
}

.lesson-header:hover,
.round-header:hover,
.level-header:hover,
.lesson-group-header:hover {
  background: var(--gray-3);
}

.round-header.modified-section h4 {
  color: var(--accent);
  font-weight: 700;
}

.lesson-toggle-btn,
.round-toggle {
  border: 1px solid var(--gray-4);
  background: white;
  border-radius: 6px;
  width: 24px;
  height: 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  transition: background 0.15s ease, transform 0.12s ease;
}

.lesson-toggle-btn:hover,
.round-toggle:hover {
  background: var(--gray-2);
  transform: scale(1.1);
}

.round-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.round-playtest-btn {
  margin-left: 10px;
  font-size: 13px;
  padding: 3px 8px;
  cursor: pointer;
}

.edit-field-group-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
}

.edit-field-group-row > label {
  width: 120px;
  flex: none;
  font-weight: 600;
}

.edit-field-group {
  display: flex;
  gap: 28px;
}

.edit-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.edit-inline-field input {
  width: 80px;
}

.grouped-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.grouped-row > label {
  width: 250px;
  flex: none;
  font-weight: 600;
}

.group-inputs {
  display: flex;
  gap: 28px;
}

.edit-inline-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.percent-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.percent-input input {
  width: 70px;
  text-align: right;
}

/*#endregion */

