/* ── RESET & BASE ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1a1a2e; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, select, button { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }

/* ── LOGIN ───────────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-wrap { background: #fff; padding: 40px; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.15); text-align: center; min-width: 340px; }
.login-wrap h1 { font-size: 28px; color: #1a1a2e; margin-bottom: 4px; }
.login-sub { color: #888; font-size: 13px; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input { padding: 12px 16px; border: 1px solid #ddd; border-radius: 8px; font-size: 15px; }
.login-form input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,.15); }
.login-form button { padding: 12px; background: #667eea; color: #fff; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; }
.login-form button:hover { background: #5a6fd6; }
.login-error { color: #e53e3e; font-size: 13px; min-height: 20px; }

/* ── TOPBAR ──────────────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; background: #1a1a2e; color: #fff; padding: 0 24px; height: 56px; }
.topbar .logo { color: #fff; font-weight: 700; font-size: 18px; }
.topbar .logo:hover { text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.topbar-right a { color: #a0aec0; }
.topbar-right a:hover { color: #fff; text-decoration: none; }
.topbar-select { background: #2d2d4a; color: #fff; border: 1px solid #444; border-radius: 6px; padding: 4px 8px; font-size: 14px; }

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
.layout { display: flex; height: calc(100vh - 56px); }
.sidebar { width: 220px; background: #fff; border-right: 1px solid #e2e8f0; padding: 16px 0; overflow-y: auto; }
.sidebar a { display: flex; align-items: center; gap: 8px; padding: 10px 20px; color: #4a5568; font-size: 14px; font-weight: 500; }
.sidebar a:hover { background: #f7fafc; color: #2d3748; text-decoration: none; }
.sidebar a.active { background: #ebf4ff; color: #2563eb; font-weight: 600; }
.main { flex: 1; padding: 24px 32px; overflow-y: auto; }

/* ── TYPOGRAPHY ──────────────────────────────────────────────────────────── */
h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 17px; color: #2d3748; margin-bottom: 12px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h1 { margin-bottom: 0; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn { padding: 8px 20px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #374151; font-size: 14px; font-weight: 500; }
.btn:hover { background: #f9fafb; }
.btn-green { background: #10b981; color: #fff; border-color: #10b981; }
.btn-green:hover { background: #059669; }
.btn-red { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-red:hover { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: 13px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; }
.btn-sm:hover { background: #f3f4f6; }
.btn-sm.btn-red { border-color: #fca5a5; color: #dc2626; }
.btn-sm.btn-green { background: #10b981; color: #fff; border-color: #10b981; }

.help { font-size: 13px; color: #6b7280; margin-bottom: 8px; }
.help code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* ── TABLE ───────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.table th, .table td { text-align: left; padding: 10px 16px; font-size: 14px; border-bottom: 1px solid #f1f5f9; }
.table th { background: #f8fafc; color: #64748b; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.table tbody tr:hover { background: #f8fafc; }

/* ── CARDS ───────────────────────────────────────────────────────────────── */
.card { background: #fff; border-radius: 12px; padding: 20px 24px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.resource-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.resource-card { background: #fff; border-radius: 12px; padding: 20px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 8px; }
.resource-card h3 { font-size: 16px; }
.resource-card .rc-type { font-size: 11px; text-transform: uppercase; color: #888; }
.resource-card .rc-actions { margin-top: 8px; display: flex; gap: 8px; }

/* ── FIELDS ──────────────────────────────────────────────────────────────── */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.field input, .field textarea, .field select { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 2px rgba(102,126,234,.12); }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input, .field-row textarea { flex: 1; }
.img-preview { max-width: 200px; max-height: 120px; border-radius: 8px; object-fit: cover; margin: 4px 0; border: 1px solid #e2e8f0; }
.img-preview-sm { max-width: 100px; max-height: 60px; border-radius: 4px; object-fit: cover; }

/* ── MODAL ───────────────────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 28px 32px; max-width: 600px; width: 90%; max-height: 85vh; overflow-y: auto; box-shadow: 0 25px 80px rgba(0,0,0,.25); }
.modal-wide { max-width: 720px; }
.modal h2 { margin-bottom: 20px; }
.modal-btns { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #4a5568; margin-bottom: 12px; font-weight: 500; }
.modal input[type="text"], .modal input[type="number"], .modal input[type="password"], .modal textarea, .modal select { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; }
.modal input:focus, .modal textarea:focus, .modal select:focus { outline: none; border-color: #667eea; }
.modal fieldset { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.modal legend { font-size: 13px; font-weight: 600; color: #4a5568; }
.cb { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; font-size: 14px !important; margin-bottom: 6px !important; }
.cb input[type="checkbox"] { width: 16px; height: 16px; }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── QUESTS ──────────────────────────────────────────────────────────────── */
.quest-card { display: flex; background: #fff; border-radius: 12px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); overflow: hidden; }
.quest-card-preview { width: 100px; min-height: 100px; display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; }
.qc-emoji { font-size: 36px; }
.qc-order { position: absolute; top: 6px; right: 8px; background: rgba(0,0,0,.3); color: #fff; font-size: 11px; border-radius: 8px; padding: 1px 8px; }
.quest-card-info { flex: 1; padding: 14px 18px; }
.quest-card-info h3 { font-size: 16px; margin-bottom: 4px; }
.quest-meta-sm { display: flex; gap: 12px; font-size: 13px; color: #64748b; margin-bottom: 6px; }
.quest-desc-sm { font-size: 13px; color: #4a5568; line-height: 1.5; max-height: 40px; overflow: hidden; }
.quest-card-actions { display: flex; gap: 4px; margin-top: 10px; }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1a1a2e; color: #fff; padding: 12px 24px; border-radius: 8px; font-size: 14px; z-index: 2000; opacity: 0; transform: translateY(20px); transition: all .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }

/* ── UTILS ───────────────────────────────────────────────────────────────── */
.empty { color: #999; text-align: center; padding: 40px 0; font-size: 15px; }
.custom-block { background: #f8fafc; border: 1px dashed #cbd5e0; border-radius: 8px; padding: 12px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.custom-block input, .custom-block textarea { flex: 1; font-size: 13px; }

/* ── SECTION ORDER ───────────────────────────────────────────────────────── */
.order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 6px;
  transition: background .15s;
}
.order-item:hover { background: #f1f5f9; }
.order-label { font-size: 14px; font-weight: 500; color: #1a1a2e; min-width: 180px; }
.order-slug { font-size: 12px; color: #94a3b8; background: #e2e8f0; padding: 2px 8px; border-radius: 4px; }
.order-arrows { display: flex; gap: 4px; margin-left: auto; }
.order-arrows .btn-sm { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 16px; padding: 0; }
.order-arrows .btn-sm:disabled { opacity: .3; cursor: default; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .field-grid, .form-cols { grid-template-columns: 1fr; }
  .layout { flex-direction: column; }
  .main { padding: 16px; }
}
