/* assets/css/admin.css */
/* Admin panel styles */

/* ===== ADMIN LAYOUT ===== */
.admin-body {
  background: #F8FAFC;
}

.admin-wrap {
  display: flex;
  min-height: calc(100vh - var(--nav-h));
}

/* ===== ADMIN SIDEBAR ===== */
.admin-sidebar {
  width: 220px;
  background: var(--text1);
  flex-shrink: 0;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  display: none;
}

.admin-sidebar-inner {
  padding: 1.5rem 0;
}

.admin-nav-section {
  margin-bottom: 1.5rem;
}

.admin-nav-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.35);
  padding: 0 1.25rem;
  margin-bottom: 0.5rem;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 1.25rem;
  color: rgba(255,255,255,.65);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.admin-nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
  text-decoration: none;
}

.admin-nav-link.active {
  background: rgba(79,70,229,.25);
  color: #fff;
  border-left-color: var(--accent);
}

.admin-nav-link svg { opacity: 0.7; flex-shrink: 0; }
.admin-nav-link.active svg,
.admin-nav-link:hover svg { opacity: 1; }

/* ===== ADMIN MAIN ===== */
.admin-main {
  flex: 1;
  min-width: 0;
}

/* ===== ADMIN TOPBAR ===== */
.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-topbar h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text1);
}

.admin-topbar-actions { display: flex; gap: 8px; }

/* ===== ADMIN CONTENT ===== */
.admin-content {
  padding: 1.5rem;
}

/* ===== ADMIN STATS ===== */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.admin-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.admin-stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--accent-lt);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.admin-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text1);
  letter-spacing: -0.6px;
  line-height: 1;
  margin-bottom: 2px;
}

.admin-stat-label {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
}

/* ===== ADMIN PAGE ===== */
.admin-page {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  background: #F8FAFC;
  min-height: 100vh;
}

.admin-page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text1);
  letter-spacing: -0.5px;
  margin: 0;
  margin-bottom: 0.25rem;
}

.admin-breadcrumb {
  font-size: 13px;
  color: var(--text3);
  margin: 0;
}

.admin-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity .15s;
}

.admin-breadcrumb a:hover {
  opacity: 0.7;
}

/* ===== ADMIN TOPBAR ===== */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 0;
}

.admin-topbar > div:first-child {
  flex: 1;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ===== ADMIN CARD ===== */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.admin-card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.admin-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text1);
  margin: 0;
}

.admin-card-body { padding: 1.5rem; }

.card-meta {
  padding: 1rem 1.5rem 0;
  font-size: 13px;
  color: var(--text3);
  font-weight: 500;
}

/* ===== ADMIN FORM ===== */
.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.admin-form-grid .form-group { margin-bottom: 0; }

/* ===== FILTER BAR ===== */
.filter-bar {
  padding: 1.25rem 1.5rem;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  width: 100%;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 140px;
}

.filter-group .form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.filter-group .form-select,
.filter-group .form-input {
  font-size: 13px;
}

/* ===== ADMIN TABLE ===== */
.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table thead {
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
}

.admin-table th {
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text3);
  text-align: left;
}

.admin-table td {
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text1);
  vertical-align: middle;
}

.admin-table tbody tr {
  transition: background .15s ease;
}

.admin-table tbody tr:hover {
  background: var(--surface2);
}

.admin-table tbody tr.row-inactive {
  opacity: 0.6;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table .text-center { text-align: center; }
.admin-table .text-muted { color: var(--text3); }

/* ===== TABLE ELEMENTS ===== */
.day-chip {
  display: inline-block;
  background: var(--accent-lt);
  color: var(--accent);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 12px;
}

.answer-badge {
  display: inline-block;
  background: var(--surface2);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-family: monospace;
  font-size: 12px;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-active {
  background: #D1FAE5;
  color: #065F46;
}

.status-draft {
  background: #FEE2E2;
  color: #991B1B;
}

.score-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 12px;
}

.sb-5 { background: #D1FAE5; color: #065F46; }
.sb-4 { background: #CCFBF1; color: #134E4A; }
.sb-3 { background: #FEF3C7; color: #78350F; }
.sb-2 { background: #FECACA; color: #7C2D12; }
.sb-1 { background: #FCA5A5; color: #7F1D1D; }
.sb-0 { background: #E5E7EB; color: #374151; }

.question-cell {
  max-width: 300px;
  word-break: break-word;
}

/* ===== ROW ACTIONS ===== */
.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form {
  display: contents;
}

.btn-sm {
  display: inline-block;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all .15s ease;
}

.btn-edit {
  background: var(--surface2);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-edit:hover {
  background: var(--accent);
  color: #fff;
}

.btn-delete {
  background: var(--err-bg);
  color: var(--err-txt);
  border: 1px solid var(--err);
}

.btn-delete:hover {
  background: var(--err);
  color: #fff;
}

/* ===== ADMIN STATS GRID ===== */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon-indigo {
  background: #E0E7FF;
  color: #4F46E5;
}

.stat-icon-green {
  background: #D1FAE5;
  color: #059669;
}

.stat-icon-amber {
  background: #FEF3C7;
  color: #D97706;
}

.stat-icon-red {
  background: #FEE2E2;
  color: #DC2626;
}

.stat-body {
  flex: 1;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text1);
  letter-spacing: -0.4px;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
}

/* ===== TWO-COLUMN LAYOUT ===== */
.admin-two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .admin-two-col {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  border: 1px solid var(--border);
  text-decoration: none;
  cursor: pointer;
  transition: all .15s;
}

.page-btn:hover {
  background: var(--surface2);
  text-decoration: none;
}

.page-btn-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ===== FORMS ===== */
.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .admin-form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.admin-form-grid .form-group {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  margin-bottom: 6px;
}

.form-label .req {
  color: var(--err);
  margin-left: 2px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text1);
  background: var(--surface);
  transition: border-color .15s;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-lt);
}

.form-input::placeholder {
  color: var(--text3);
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

/* ===== CODE BLOCK ===== */
.code-block {
  background: var(--text1);
  color: #fff;
  padding: 1rem;
  border-radius: var(--r-sm);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  overflow-x: auto;
  margin-bottom: 1rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ===== FORMAT RULES LIST ===== */
.format-rules {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  font-size: 13px;
}

.format-rules li {
  padding: 6px 0;
  padding-left: 24px;
  position: relative;
  color: var(--text2);
}

.format-rules li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #059669;
  font-weight: bold;
}

/* ===== ALERTS ===== */
/* See ALERT ENHANCEMENTS section for alert styling */

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text3);
}

.empty-state p {
  margin-bottom: 1rem;
  font-size: 14px;
}

.text-muted {
  color: var(--text3);
}

/* ===== UPLOAD AREA ===== */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--r-lg);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-lt);
}

.upload-zone-icon { color: var(--text3); margin: 0 auto 1rem; }
.upload-zone h3 { font-size: 15px; color: var(--text2); margin-bottom: 0.5rem; }
.upload-zone p  { font-size: 13px; color: var(--text3); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all .15s;
}

.page-link:hover { background: var(--surface2); text-decoration: none; }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== ADMIN LOGIN ===== */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text1);
  padding: 1rem;
}

.admin-login-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

.admin-login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 2rem;
}

.admin-login-logo span {
  font-size: 16px;
  font-weight: 800;
  color: var(--text1);
}

.admin-badge {
  display: inline-block;
  background: var(--err-bg);
  color: var(--err-txt);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
}

/* ===== NAV TEXT (for admin username) ===== */
.nav-text {
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 0;
  white-space: nowrap;
}

/* ===== ALERT ENHANCEMENTS ===== */
.admin-alerts {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 1.25rem 1.5rem;
  border-radius: var(--r-lg);
  font-size: 13px;
  line-height: 1.6;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.alert-icon {
  flex-shrink: 0;
  font-size: 16px;
  font-weight: bold;
  margin-top: 2px;
}

.alert-content {
  flex: 1;
}

.alert-content ul {
  list-style: none;
  padding: 0.5rem 0 0 0;
  margin: 0;
}

.alert-content li {
  padding: 0.25rem 0;
  padding-left: 20px;
  position: relative;
}

.alert-content li::before {
  content: '•';
  position: absolute;
  left: 8px;
}

.alert-success {
  background: #D1FAE5;
  color: #065F46;
  border: 1px solid #6EE7B7;
}

.alert-error {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FCA5A5;
}

.alert-warn {
  background: #FEF3C7;
  color: #78350F;
  border: 1px solid #FCD34D;
}

/* ===== UPLOAD FORM ENHANCEMENTS ===== */
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group:last-of-type {
  margin-bottom: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.btn-large {
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  font-size: 16px;
}

/* ===== FILE INPUT STYLING ===== */
.file-input-wrapper {
  position: relative;
  overflow: hidden;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.file-input-label {
  display: block;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.file-input-wrapper:hover .file-input-label {
  border-color: var(--accent);
  background: var(--accent-lt);
}

.file-input-wrapper input[type="file"]:focus + .file-input-label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== CODE BLOCK ENHANCEMENTS ===== */
.code-block-wrapper {
  margin: 1.5rem 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.code-block {
  background: var(--text1);
  color: #fff;
  padding: 1.25rem;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  overflow-x: auto;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  border-radius: 0;
}

/* ===== FORMAT SECTION ENHANCEMENTS ===== */
.format-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.format-intro {
  font-size: 14px;
  color: var(--text2);
  margin: 0;
  line-height: 1.6;
}

.format-intro strong {
  color: var(--text1);
  font-weight: 600;
}

/* ===== RULES SECTION ===== */
.rules-section,
.notes-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rules-title,
.notes-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text1);
  margin: 0;
}

.format-rules {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.format-rules li {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0;
  padding-left: 0;
  position: relative;
}

.format-rules li::before {
  content: '';
}

.rule-name {
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
  font-family: 'Courier New', monospace;
}

.rule-desc {
  font-size: 13px;
  color: var(--text2);
}

.notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.notes-list li {
  font-size: 13px;
  color: var(--text2);
  padding-left: 24px;
  position: relative;
}

.notes-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #10B981;
  font-weight: bold;
  font-size: 14px;
}

/* ===== TEMPLATE ACTION ===== */
.template-action {
  display: flex;
  justify-content: center;
  padding: 1rem 0 0 0;
  border-top: 1px solid var(--border);
}

/* ===== CARD ENHANCEMENTS ===== */
.upload-card,
.format-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.upload-card .admin-card-body,
.format-card .admin-card-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .admin-page {
    padding: 1rem;
  }

  .admin-page-title {
    font-size: 1.35rem;
  }

  .admin-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .filter-form {
    flex-direction: column;
  }

  .filter-group {
    min-width: unset;
  }

  .admin-table {
    font-size: 12px;
  }

  .admin-table th,
  .admin-table td {
    padding: 10px 8px;
  }

  .row-actions {
    justify-content: center;
  }

  .admin-two-col {
    grid-template-columns: 1fr;
  }

  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 640px) {
  .admin-sidebar { display: block; }
  .admin-stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .admin-page {
    padding: 2rem;
  }

  .admin-stats-grid {
    grid-template-columns: repeat(var(--cols, 4), 1fr);
  }

  .topbar-actions {
    justify-content: flex-end;
  }
}
