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

body {
  font-family: 'Barlow', sans-serif;
  font-size: 14px;
  background: #f4f5f7;
  color: #1a1a2e;
}

/* ── Login ─────────────────────────────────────────────────────────────────── */
.admin-login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1a1a2e;
}

.login-wrap {
  background: #fff;
  padding: 48px 40px;
  border-radius: 8px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-logo {
  font-size: 28px;
  font-weight: 700;
  color: #C4922A;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.login-wrap h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #1a1a2e;
}

.login-wrap label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #666;
  margin-bottom: 6px;
}

.login-wrap input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.login-wrap input:focus {
  outline: none;
  border-color: #1a1a2e;
}

.login-wrap button {
  width: 100%;
  padding: 11px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-wrap button:hover { background: #2d2d50; }

.login-error {
  background: #fef2f2;
  color: #c0392b;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.admin-page {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 220px;
  background: #1a1a2e;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 28px 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
}

.sidebar-logo {
  font-size: 18px;
  font-weight: 700;
  color: #C4922A;
  padding: 0 24px 28px;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  flex: 1;
}

.sidebar-link {
  display: block;
  padding: 10px 24px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
}

.sidebar-link.active {
  color: #fff;
  background: rgba(255,255,255,0.09);
}

.sidebar-divider {
  margin: 8px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-docs {
  padding: 12px 0 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-docs-label {
  padding: 0 24px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
}

.sidebar-doc-link {
  font-size: 13px;
}

.sidebar-logout {
  padding: 0 24px 8px;
  margin-top: 8px;
}

.sidebar-logout button {
  width: 100%;
  padding: 9px;
  background: transparent;
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.sidebar-logout button:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}

.admin-main {
  margin-left: 220px;
  padding: 40px;
  flex: 1;
  max-width: 1100px;
}

.admin-preview-page {
  max-width: none;
}

.admin-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.admin-editor-form {
  min-width: 0;
}

.admin-preview-panel {
  position: sticky;
  top: 24px;
}

.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.preview-meta p {
  font-size: 12px;
  color: #6b7280;
}

.preview-status {
  font-size: 12px;
  color: #6b7280;
}

.preview-status[data-state="error"] {
  color: #c0392b;
}

.admin-preview-frame {
  width: 100%;
  min-height: 78vh;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
}

.admin-doc {
  max-width: 920px;
}

.doc-intro {
  margin-top: 6px;
  color: #6b7280;
  line-height: 1.6;
}

.doc-content {
  color: #1f2937;
  line-height: 1.75;
}

.doc-content h1,
.doc-content h2,
.doc-content h3 {
  color: #111827;
  line-height: 1.3;
}

.doc-content h1 {
  font-size: 30px;
  margin: 0 0 20px;
}

.doc-content h2 {
  font-size: 22px;
  margin: 34px 0 14px;
  padding-top: 6px;
  border-top: 1px solid #f0f2f5;
}

.doc-content h3 {
  font-size: 17px;
  margin: 24px 0 10px;
}

.doc-content p,
.doc-content ul,
.doc-content pre {
  margin: 0 0 16px;
}

.doc-content ul {
  padding-left: 20px;
}

.doc-content li + li {
  margin-top: 6px;
}

.doc-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 2px 6px;
}

.doc-content pre {
  background: #111827;
  color: #f9fafb;
  border-radius: 10px;
  padding: 18px;
  overflow-x: auto;
}

.doc-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.doc-content a {
  color: #1d4ed8;
  text-decoration: none;
}

.doc-content a:hover {
  text-decoration: underline;
}

/* ── Section ───────────────────────────────────────────────────────────────── */
.admin-section {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  margin-bottom: 32px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  padding: 8px 18px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-primary:hover { background: #2d2d50; }

.btn-ghost {
  display: inline-block;
  padding: 8px 18px;
  background: transparent;
  color: #1a1a2e;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s;
}

.btn-ghost:hover { border-color: #aaa; }

.btn-edit {
  display: inline-block;
  padding: 4px 12px;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-edit:hover { background: #e0e7ff; }

.btn-delete {
  padding: 4px 12px;
  background: #fef2f2;
  color: #c0392b;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-delete:hover { background: #fee2e2; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  padding: 0 12px 10px 0;
  border-bottom: 1px solid #eee;
}

.admin-table td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

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

.admin-table a { color: #1a1a2e; text-decoration: none; }
.admin-table a:hover { text-decoration: underline; }

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.row-actions form { margin: 0; }

.tag-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #f3f4f6;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #555;
}

/* ── Editable tables ───────────────────────────────────────────────────────── */
.editable-table input,
.editable-table select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  background: #fafafa;
  transition: border-color 0.15s, background 0.15s;
}

.editable-table input:focus,
.editable-table select:focus {
  outline: none;
  border-color: #1a1a2e;
  background: #fff;
}

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

/* ── News form ─────────────────────────────────────────────────────────────── */
.news-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.news-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.news-form label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #666;
}

.news-form label small {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  color: #999;
}

.news-form input,
.news-form textarea {
  padding: 9px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: #fafafa;
  transition: border-color 0.15s, background 0.15s;
}

.news-form input:focus,
.news-form textarea:focus {
  outline: none;
  border-color: #1a1a2e;
  background: #fff;
}

.news-form textarea {
  resize: vertical;
  line-height: 1.6;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.form-error {
  background: #fef2f2;
  color: #c0392b;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 13px;
}

/* ── Image upload widget ────────────────────────────────────────────────────── */
.image-upload-widget {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-preview {
  position: relative;
  display: inline-block;
  max-width: 400px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.image-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: cover;
}

.image-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-remove:hover { background: rgba(0,0,0,0.85); }

.image-upload-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: #f4f5f7;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  width: fit-content;
}

.image-upload-btn:hover { background: #e9eaec; }

.image-upload-hint {
  font-size: 12px;
  color: #9ca3af;
}

@media (max-width: 1180px) {
  .admin-editor-layout {
    grid-template-columns: 1fr;
  }

  .admin-preview-panel {
    position: static;
  }

  .admin-preview-frame {
    min-height: 60vh;
  }
}

@media (max-width: 760px) {
  .admin-main {
    margin-left: 0;
    padding: 24px 16px;
  }

  .admin-sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .admin-page {
    flex-direction: column;
  }

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

  .table-actions,
  .form-actions,
  .preview-meta {
    flex-direction: column;
    align-items: stretch;
  }
}
