/* ============================================================
   Direct Results Consulting — Admin panel styles
   Reuses the brand tokens defined in styles.css (loaded first).
   ============================================================ */

.admin-body { background: var(--cream-100); min-height: 100dvh; }

/* ---- Gate screens (loading / login / denied) ---- */
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate__card {
  width: min(420px, 100%);
  background: var(--cream-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 34px 30px;
  text-align: center;
}
.gate__card img { height: 48px; width: auto; margin: 0 auto 16px; display: block; }
.gate__card h1 { font-size: 1.5rem; margin-bottom: 8px; }
.gate__card p { color: var(--text-soft); font-size: 14.5px; margin-bottom: 20px; }
.gate__form { display: grid; gap: 12px; text-align: left; }
.gate__form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.gate__form input {
  padding: 12px 14px; font: inherit; font-size: 15px;
  background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.gate__form input:focus { outline: none; border-color: var(--olive-300); box-shadow: 0 0 0 3px var(--olive-100); }
.gate__msg { font-size: 13.5px; color: var(--accent-dark); min-height: 18px; }
.gate__msg--ok { color: var(--primary-dark); }
.gate__back { display: inline-block; margin-top: 16px; font-size: 13.5px; color: var(--text-soft); }

/* ---- Shell: sidebar + content ---- */
.admin { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--olive-900);
  color: var(--cream-200);
  padding: 22px 16px;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.sidebar__brand img { height: 40px; width: auto; background: var(--cream-50); border-radius: 10px; padding: 6px 10px; }
.sidebar__brand span { font-family: "Fraunces", serif; font-weight: 600; font-size: 15px; color: #fff; line-height: 1.1; }
.sidebar__brand small { display: block; font-family: "Inter", sans-serif; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--peach-300); }

.sidebar__nav { display: grid; gap: 3px; margin-top: 6px; }
.navlink {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border: 0; background: transparent;
  border-radius: var(--radius-sm);
  color: var(--cream-300);
  font: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-align: left; width: 100%;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.navlink svg { flex: none; width: 18px; height: 18px; opacity: .85; }
.navlink:hover { background: rgba(255,255,255,.06); color: #fff; }
.navlink.is-active { background: var(--olive-700); color: #fff; }
.navlink[hidden] { display: none; }

.sidebar__foot { margin-top: auto; display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar__user { padding: 4px 8px; font-size: 12.5px; color: var(--olive-300); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user strong { display: block; color: var(--cream-100); font-size: 13.5px; }

/* ---- Content area ---- */
.content { padding: 30px clamp(18px, 3vw, 40px); max-width: 1100px; }
.view { display: none; }
.view.is-active { display: block; animation: fadeUp .3s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.view__head h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.view__head p { color: var(--text-soft); font-size: 14px; margin-top: 4px; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
}
.stat__num { font-family: "Fraunces", serif; font-size: 2.1rem; font-weight: 600; color: var(--primary-dark); }
.stat__label { font-size: 13px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

/* ---- Tables ---- */
.tablewrap { overflow-x: auto; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.data th, table.data td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute); background: var(--cream-50); position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--cream-50); }
.cell-actions { display: flex; gap: 8px; white-space: nowrap; }

/* Status badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge--published, .badge--going { background: var(--olive-100); color: var(--olive-700); }
.badge--draft, .badge--cancelled { background: var(--cream-300); color: var(--text-soft); }
.badge--admin { background: var(--peach-200); color: var(--accent-dark); }
.badge--owner { background: var(--olive-700); color: #fff; }
.badge--user { background: var(--cream-300); color: var(--text-soft); }

/* ---- Buttons (small admin variants; .btn base comes from styles.css) ---- */
.btn--xs { padding: 7px 13px; font-size: 13px; }
.btn--danger { background: #8a3b22; color: #fff; }
.btn--danger:hover { background: #6f2e19; }
.iconbtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  background: transparent; border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-soft); cursor: pointer; transition: all .15s var(--ease);
}
.iconbtn:hover { border-color: var(--olive-300); color: var(--text); background: var(--cream-50); }
.iconbtn--danger:hover { border-color: #c98a72; color: #8a3b22; background: #fbeee9; }

/* ---- Forms / editor ---- */
.form { display: grid; gap: 16px; max-width: 760px; }
.form__row { display: grid; gap: 6px; }
.form__row--2 { grid-template-columns: 1fr 1fr; gap: 16px; }
.form label { font-size: 13px; font-weight: 600; color: var(--text); }
.form input[type=text], .form input[type=number], .form input[type=date], .form input[type=url], .form select, .form textarea {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 14.5px;
  background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text);
}
.form textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--olive-300); box-shadow: 0 0 0 3px var(--olive-100); }
.form__actions { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
.form__hint { font-size: 12.5px; color: var(--text-mute); }

/* Markdown editor split */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor textarea { min-height: 360px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13.5px; }
.editor__preview {
  background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 18px 20px; min-height: 360px; overflow-y: auto; max-height: 520px;
}
.editor__preview h1, .editor__preview h2, .editor__preview h3 { font-family: "Fraunces", serif; margin: 1em 0 .4em; line-height: 1.2; }
.editor__preview h1 { font-size: 1.6rem; } .editor__preview h2 { font-size: 1.3rem; } .editor__preview h3 { font-size: 1.1rem; }
.editor__preview p { margin: 0 0 1em; line-height: 1.7; color: var(--text-soft); }
.editor__preview a { color: var(--primary-dark); text-decoration: underline; }
.editor__preview img { max-width: 100%; border-radius: var(--radius-sm); margin: .5em 0; }
.editor__preview ul, .editor__preview ol { margin: 0 0 1em; padding-left: 1.4em; color: var(--text-soft); line-height: 1.7; }
.editor__preview blockquote { border-left: 3px solid var(--peach-300); margin: 0 0 1em; padding: .2em 1em; color: var(--text-mute); }
.editor__preview code { background: var(--cream-200); padding: .1em .4em; border-radius: 5px; font-size: .9em; }
.editor__preview pre { background: var(--olive-900); color: var(--cream-100); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; }
.editor__preview pre code { background: transparent; color: inherit; }

/* Image upload preview */
.uploader { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.uploader__preview { width: 90px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--cream-200); }

/* Gallery grid (admin) */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.media-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.media-card img { width: 100%; height: 120px; object-fit: cover; display: block; }
.media-card__body { padding: 10px 12px; display: grid; gap: 8px; }
.media-card__body input { width: 100%; padding: 7px 9px; font: inherit; font-size: 12.5px; border: 1px solid var(--border); border-radius: 7px; }
.media-card__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Empty / loading states */
.empty { padding: 36px; text-align: center; color: var(--text-soft); background: var(--white); border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid var(--olive-300); border-top-color: var(--primary-dark); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile header (sidebar toggle) */
.admin-topbar { display: none; }

@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .admin-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--olive-900); color: #fff; position: sticky; top: 0; z-index: 50;
  }
  .admin-topbar img { height: 34px; background: var(--cream-50); border-radius: 8px; padding: 4px 8px; }
  .admin-topbar button { background: transparent; border: 0; color: #fff; cursor: pointer; padding: 6px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 60; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .admin.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .admin.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .editor, .form__row--2 { grid-template-columns: 1fr; }
}

/* ---- AI assist toolbar (blog editor) ---- */
.aibar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 10px;
  padding: 10px 12px;
  background: linear-gradient(100deg, var(--olive-100), var(--peach-100));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.aibar__label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .03em;
  color: var(--olive-700); margin-right: 4px;
}
.aibtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 6px 13px;
  background: var(--white); color: var(--primary-dark);
  border: 1px solid var(--olive-300); border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background-color .15s var(--ease), transform .15s var(--ease), box-shadow .2s var(--ease);
}
.aibtn:hover { background: var(--olive-600); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.aibtn:disabled { opacity: .7; cursor: default; transform: none; }
.aibtn .spinner { width: 15px; height: 15px; border-width: 2px; }
