/* ==========================================================================
   Admin panel — extends the tokens defined in css/app.css
   ========================================================================== */

/* ------------------------------------------------------------------ login -- */
.ad-login-wrap {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 2rem 1.5rem;
}
.ad-login {
  width: 100%;
  max-width: 26rem;
  display: grid;
  gap: 1.1rem;
  padding: 2.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  background: hsl(var(--card));
}
.ad-login-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
}
.ad-login-sub {
  margin-top: -0.6rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}
.ad-back {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  transition: color 0.2s;
}
.ad-back:hover {
  color: hsl(var(--foreground));
}
.ad-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: hsl(var(--muted-foreground));
}
.ad-checkbox input {
  width: 1rem;
  height: 1rem;
  accent-color: hsl(var(--copper));
}

/* -------------------------------------------------------------- dashboard -- */
.ad-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: 1fr;
}

.ad-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  background: hsl(0 0% 7%);
  border-right: 1px solid hsl(var(--border));
}
.ad-sidebar-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.ad-sidebar-head strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 400;
  color: hsl(var(--copper-light));
}
.ad-sidebar-head span {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: hsl(var(--muted-foreground));
}

.ad-nav {
  display: grid;
  gap: 0.2rem;
  flex: 1;
  align-content: start;
}
.ad-nav a {
  padding: 0.6rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
  transition: background-color 0.15s, color 0.15s;
}
.ad-nav a:hover {
  background: hsl(0 0% 11%);
  color: hsl(var(--foreground));
}
.ad-nav a.is-active {
  background: hsl(var(--copper));
  color: #fff;
}
.ad-nav-group {
  margin: 1rem 0 0.35rem;
  padding-inline: 0.85rem;
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground) / 0.8);
}

.ad-nav-drop-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
  transition: background-color 0.15s, color 0.15s;
}
.ad-nav-drop-btn:hover {
  background: hsl(0 0% 11%);
  color: hsl(var(--foreground));
}
.ad-nav-drop-btn .chev {
  width: 0.8rem;
  height: 0.8rem;
  transition: transform 0.2s;
}
.ad-nav-drop-btn[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}
.ad-nav-drop {
  display: grid;
  gap: 0.2rem;
}
.ad-nav-drop a {
  padding-left: 1.6rem;
}

.ad-sidebar-foot {
  display: grid;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
}
.ad-user {
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ad-main {
  padding: 1.75rem 1.5rem 4rem;
  min-width: 0;
}
.ad-main-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.ad-main-head h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
}
.ad-main-sub {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
}
/* Hamburger for the mobile sidebar drawer; visible below 1024px only. */
.ad-sidebar-toggle {
  display: none;
}
/* Backdrop for the mobile drawer; never rendered on desktop. */
.ad-sidebar-backdrop {
  display: none;
}
.ad-main-title {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  min-width: 0;
}
.ad-main-actions {
  display: flex;
  gap: 0.6rem;
}

/* ----------------------------------------------------------------- cards -- */
.ad-cards {
  display: grid;
  gap: 1rem;
  margin-top: 1.75rem;
}
.ad-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.4rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}
.ad-card-value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: hsl(var(--copper-light));
  line-height: 1;
}
.ad-card-label {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}

.ad-panel {
  margin-top: 2rem;
}
.ad-panel-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

/* ----------------------------------------------------------------- table -- */
.ad-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.ad-table th,
.ad-table td {
  text-align: left;
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}
.ad-table th {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 400;
}
.ad-table tbody tr:hover {
  background: hsl(0 0% 10%);
}
.ad-table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  justify-content: flex-end;
}
.ad-table-actions form {
  display: inline;
}
.ad-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  background: hsl(var(--copper) / 0.16);
  color: hsl(var(--copper-light));
}
.ad-link {
  font-size: 0.78rem;
  color: hsl(var(--copper-light));
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}
.ad-link:hover {
  border-bottom-color: currentColor;
}
.ad-link-danger {
  color: hsl(0 65% 62%);
}

/* ----------------------------------------------------------------- forms -- */
.ad-form {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.75rem;
  max-width: 52rem;
}
.ad-field {
  display: grid;
  gap: 0.45rem;
}
.ad-field-label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
.ad-field-hint {
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground) / 0.75);
}
.ad-field-error {
  font-size: 0.75rem;
  color: hsl(0 72% 66%);
}
.ad-field.is-invalid input,
.ad-field.is-invalid textarea,
.ad-field.is-invalid select {
  border-color: hsl(0 60% 45%);
}

.ad-field input,
.ad-field select,
.ad-field textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  background: hsl(0 0% 9%);
  border: 1px solid hsl(var(--border));
  border-radius: 0.55rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}
.ad-field input:focus,
.ad-field select:focus,
.ad-field textarea:focus {
  outline: none;
  border-color: hsl(var(--copper));
  box-shadow: 0 0 0 3px hsl(var(--copper) / 0.18);
}

.ad-slug {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.ad-image {
  display: grid;
  gap: 0.75rem;
}
.ad-image-preview {
  height: 8rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.55rem;
  overflow: hidden;
  background: hsl(0 0% 9%);
  display: grid;
  place-items: center;
}
.ad-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ad-image-preview span {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
}
.ad-image-controls {
  display: grid;
  gap: 0.5rem;
}
.ad-image-upload {
  display: grid;
  gap: 0.4rem;
  padding-top: 0.25rem;
  border-top: 1px dashed hsl(var(--border));
}
.ad-image-upload input[type='file'] {
  font-size: 0.82rem;
  color: hsl(var(--muted-foreground));
}

.ad-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
}

/* --------------------------------------------------------------- buttons -- */
.ad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}
.ad-btn-primary {
  background: hsl(var(--copper));
  color: #fff;
}
.ad-btn-primary:hover {
  background: hsl(var(--copper-light));
  color: hsl(20 40% 10%);
}
.ad-btn-ghost {
  border-color: hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
.ad-btn-ghost:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--copper));
}
.ad-btn-block {
  width: 100%;
}

/* ---------------------------------------------------------------- alerts -- */
.ad-alert {
  margin-top: 1.25rem;
  padding: 0.8rem 1rem;
  border-radius: 0.55rem;
  font-size: 0.84rem;
  border: 1px solid;
}
.ad-alert-ok {
  color: hsl(150 55% 65%);
  border-color: hsl(150 40% 30%);
  background: hsl(150 40% 12%);
}
.ad-alert-error {
  color: hsl(0 72% 68%);
  border-color: hsl(0 50% 34%);
  background: hsl(0 45% 13%);
}
.ad-error-list {
  display: grid;
  gap: 0.25rem;
  list-style: disc;
  padding-left: 1.1rem;
}
.ad-empty {
  font-size: 0.85rem;
  line-height: 1.7;
  color: hsl(var(--muted-foreground));
}

/* ================================================================ responsive */
/* Mobile: the sidebar becomes an off-canvas drawer opened from a hamburger
   button next to the page heading. */
@media (max-width: 1023.98px) {
  /* Keep the bar with the hamburger visible while scrolling. */
  .ad-main {
    padding-top: 0;
  }
  .ad-main-head {
    position: sticky;
    top: 0;
    z-index: 30;
    margin-inline: -1.5rem;
    padding: 0.9rem 1.5rem;
    background: hsl(var(--background) / 0.95);
    backdrop-filter: blur(8px);
  }

  .ad-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid hsl(var(--border));
    border-radius: 0.5rem;
    color: hsl(var(--foreground));
    transition: color 0.2s, border-color 0.2s;
  }
  .ad-sidebar-toggle:hover {
    color: hsl(var(--copper-light));
    border-color: hsl(var(--copper));
  }
  .ad-sidebar-toggle svg {
    width: 1.2rem;
    height: 1.2rem;
  }

  .ad-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(17rem, 84vw);
    overflow-y: auto;
    border-right: 1px solid hsl(var(--border));
    box-shadow: 0 0 40px hsl(0 0% 0% / 0.45);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
  }
  .ad-shell.is-sidebar-open .ad-sidebar {
    transform: none;
  }

  .ad-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: hsl(0 0% 0% / 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
  }
  .ad-shell.is-sidebar-open .ad-sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }
}

@media (min-width: 640px) {
  .ad-cards {
    grid-template-columns: repeat(3, 1fr);
  }
  .ad-image {
    grid-template-columns: 12rem 1fr;
    align-items: start;
  }
  .ad-image-preview {
    height: 100%;
    min-height: 8rem;
  }
}

@media (min-width: 1024px) {
  .ad-shell {
    grid-template-columns: 17rem 1fr;
  }
  .ad-sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 1.75rem;
  }
  .ad-main {
    padding: 2.5rem 2.5rem 5rem;
  }
  .ad-cards {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* -------------------------------------------------------------- ckeditor -- */
/* The editor UI itself is styled by vendor/ckeditor/ckeditor5.css. These
   overrides repaint it with the dark admin palette (variables set on <body>
   so panels that CK appends to <body> inherit them too). */
body {
  --ck-color-base-background: hsl(0 0% 9%);
  --ck-color-base-foreground: hsl(0 0% 12%);
  --ck-color-base-text: hsl(0 0% 93%);
  --ck-color-base-border: hsl(var(--border));
  --ck-color-base-active: hsl(var(--copper));
  --ck-color-base-activeforeground: hsl(0 0% 100%);
  --ck-color-toolbar-background: hsl(0 0% 9%);
  --ck-color-toolbar-border: hsl(var(--border));
  --ck-color-button-default__background: transparent;
  --ck-color-button-default__background-hover: hsl(0 0% 16%);
  --ck-color-button-default__background-active: hsl(0 0% 22%);
  --ck-color-button-on__background: hsl(var(--copper) / 0.22);
  --ck-color-button-on__color: hsl(var(--copper-light));
  --ck-color-dropdown-panel-background: hsl(0 0% 12%);
  --ck-color-dropdown-panel-border: hsl(var(--border));
  --ck-color-panel-background: hsl(0 0% 12%);
  --ck-color-panel-border: hsl(var(--border));
  --ck-color-list-background: hsl(0 0% 12%);
  --ck-color-list-button-hover__background: hsl(0 0% 18%);
  --ck-color-input-background: hsl(0 0% 9%);
  --ck-color-input-border: hsl(var(--border));
  --ck-color-input-text: hsl(0 0% 93%);
  --ck-color-tooltip-background: hsl(0 0% 20%);
  --ck-color-tooltip-text: hsl(0 0% 95%);
}
.ck.ck-editor__editable_inline {
  min-height: 12rem;
  background: hsl(0 0% 9%);
  color: hsl(0 0% 93%);
  border-color: hsl(var(--border));
}
.ck.ck-editor__editable_inline:focus {
  border-color: hsl(var(--copper));
}
.ck-content a {
  color: hsl(var(--copper-light));
}
