/* Admin styles re-use variables from base.css */

/* ============================================================
   NEW DASHBOARD — card grid control panel
   ============================================================ */

.dash-dashboard {
  padding: 2rem 1rem 4rem;
}

/* Header */
.dash-header {
  margin-bottom: 1.75rem;
}

.dash-welcome {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  color: var(--primary);
  margin: 0 0 0.35rem;
  letter-spacing: 0.01em;
}

.dash-subtitle {
  color: var(--gray-600);
  font-size: 0.98rem;
  line-height: 1.6;
  max-width: 62ch;
  margin: 0;
}

/* Stats bar */
.dash-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.95rem;
  margin-bottom: 2rem;
}

@media (max-width: 600px) {
  .dash-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.dash-stat {
  background: linear-gradient(
    165deg,
    rgba(29, 35, 49, 0.92),
    rgba(20, 25, 36, 0.9)
  );
  border: 1px solid rgba(177, 146, 76, 0.28);
  border-radius: 16px;
  padding: 0.95rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: 0 10px 26px rgba(6, 9, 16, 0.34);
}

.dash-stat-icon {
  color: rgba(224, 188, 104, 0.95);
  margin-bottom: 0.15rem;
}

.dash-stat-count {
  font-size: 1.5rem;
  font-weight: 800;
  color: #f4e8c8;
  line-height: 1;
  font-family: "Sora", "Manrope", sans-serif;
}

.dash-stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(214, 220, 234, 0.82);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Section */
.dash-section {
  margin-top: 2rem;
  margin-bottom: 0;
}

.dash-section:first-of-type {
  margin-top: 0;
}

.dash-section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(216, 223, 238, 0.88);
  margin: 0 0 0.95rem;
  padding-bottom: 0.62rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.dash-section-title::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: 0 0 0 3px rgba(218, 179, 95, 0.2);
}

.dash-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 0.95rem;
}

@media (max-width: 520px) {
  .dash-section-grid {
    grid-template-columns: 1fr;
  }
}

/* Card */
.dash-card {
  background: linear-gradient(
    170deg,
    rgba(28, 34, 47, 0.96),
    rgba(17, 22, 33, 0.94)
  );
  border: 1px solid rgba(177, 146, 76, 0.26);
  border-radius: 16px;
  padding: 1.1rem 1.05rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.58rem;
  min-height: 210px;
  box-shadow: 0 12px 28px rgba(6, 9, 16, 0.35);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(6, 9, 16, 0.42);
  border-color: rgba(224, 188, 104, 0.58);
}

.dash-card:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-sm);
}

.dash-card:focus-visible {
  outline: 3px solid rgba(224, 188, 104, 0.65);
  outline-offset: 2px;
}

.dash-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(
    145deg,
    rgba(224, 188, 104, 0.18),
    rgba(224, 188, 104, 0.08)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f0cf89;
  flex-shrink: 0;
}

.dash-card-body {
  flex: 1;
}

.dash-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f5f8ff;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.dash-card-desc {
  font-size: 0.83rem;
  color: rgba(214, 220, 234, 0.82);
  margin: 0;
  line-height: 1.58;
  min-height: 2.6em;
  max-width: 34ch;
}

.dash-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #e0bc68;
  letter-spacing: 0.01em;
  margin-top: auto;
  opacity: 0.9;
  transition:
    gap 0.18s ease,
    opacity 0.18s ease;
}

.dash-card:hover .dash-card-cta {
  gap: 0.45rem;
  opacity: 1;
}

/* Account / Logout card */
.dash-account {
  margin-top: 2.35rem;
  padding: 1rem 1.05rem 1.1rem;
  border-radius: 16px;
  border: 1px solid rgba(177, 146, 76, 0.3);
  background: linear-gradient(
    180deg,
    rgba(20, 25, 36, 0.86),
    rgba(12, 16, 24, 0.82)
  );
}

.dash-account .dash-section-grid {
  grid-template-columns: minmax(0, 240px);
}

.dash-logout-card {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.15rem;
  border-radius: 12px;
  border: 1.5px solid rgba(220, 112, 112, 0.38);
  background: linear-gradient(
    180deg,
    rgba(76, 30, 30, 0.5),
    rgba(52, 22, 22, 0.48)
  );
  color: #f2b1b1;
  font-size: 0.93rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.dash-logout-card:hover {
  background: linear-gradient(
    180deg,
    rgba(94, 34, 34, 0.58),
    rgba(62, 26, 26, 0.56)
  );
  border-color: rgba(236, 129, 129, 0.64);
  transform: translateY(-2px);
}

.dash-logout-card:active {
  transform: translateY(0) scale(0.98);
}

.dash-logout-card:focus-visible {
  outline: 3px solid rgba(236, 129, 129, 0.52);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .dash-section-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .dash-card {
    min-height: 200px;
  }
}

@media (max-width: 640px) {
  .dash-dashboard {
    padding: 1.2rem 0.4rem 2.2rem;
  }

  .dash-header {
    margin-bottom: 1.2rem;
  }

  .dash-stats-bar {
    margin-bottom: 1.45rem;
  }

  .dash-section {
    margin-top: 1.55rem;
  }

  .dash-section-grid {
    gap: 0.78rem;
  }

  .dash-card {
    min-height: 186px;
    padding: 0.95rem 0.9rem 0.88rem;
  }

  .dash-card-desc {
    font-size: 0.81rem;
    min-height: 2.5em;
  }

  .dash-account {
    margin-top: 1.9rem;
    padding: 0.85rem 0.8rem 0.9rem;
  }

  .dash-account .dash-section-grid {
    grid-template-columns: 1fr;
  }

  .dash-logout-card {
    justify-content: center;
    width: 100%;
  }
}
/* ============================================================ */

/* Namespaced admin styles to avoid bleeding into public UI */
.admin {
  background: var(--gray-100);
  min-height: calc(100vh - 160px); /* account for header+footer */
}

.admin .admin-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}

.admin .admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
  flex-wrap: wrap; /* allow controls to wrap on smaller screens */
}

.admin .admin-title {
  font-size: 1.75rem;
  color: var(--primary);
}

.admin .admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.admin .admin-actions .form-control {
  flex: 1 1 180px; /* grow search/selects to usable width */
  min-width: 120px;
}
.admin .admin-actions .btn {
  flex: 0 0 auto; /* keep buttons compact */
}
@media (max-width: 520px) {
  .admin .admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .admin .admin-actions .form-control {
    grid-column: 1 / -1; /* inputs full-width row */
    width: 100%;
  }
  .admin .admin-actions .btn {
    width: 100%; /* buttons full-width on phones */
  }
}

.admin .admin-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(380px, 1fr)
  ); /* restore desktop density */
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 768px) {
  .admin .admin-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}
@media (max-width: 520px) {
  .admin .admin-grid {
    grid-template-columns: 1fr; /* single column on phones */
    gap: 1rem;
  }
}

.admin .card {
  background: var(--gray-50);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-400);
  padding: 1rem;
  overflow: hidden; /* prevent any inner transforms from bleeding out */
  min-width: 0; /* allow grid to shrink item without overflow */
}

/* Editor page: allow rich text toolbar/popovers to overflow cleanly */
.admin .editor-card {
  overflow: visible; /* ensure descendants can overflow the card */
}
.admin .editor-card .ql-toolbar,
.admin .editor-card .ql-container {
  position: relative;
  z-index: 200; /* baseline within card */
}
.admin .editor-card .ql-container {
  min-height: 220px;
  border: 1px solid var(--gray-400);
  border-radius: 8px;
  background: var(--gray-50);
}
.admin .editor-card .ql-toolbar {
  border: 1px solid var(--gray-400);
  border-radius: 8px;
  background: var(--gray-50);
  margin-bottom: 0.5rem;
  overflow: visible; /* allow picker dropdown to overflow */
}
.admin .editor-card .ql-editor {
  min-height: 200px;
  padding: 0.6rem 0.75rem;
}

/* Ensure the content editor area is always visibly boxed */
.admin .content-editor {
  border: 1px solid var(--gray-400);
  border-radius: 8px;
  background: var(--gray-50);
  min-height: 220px;
  pointer-events: auto;
  position: relative;
  overflow: visible; /* allow toolbar dropdowns to overflow */
}
.admin .content-editor .ql-container {
  border: 0;
  min-height: 220px;
  position: relative;
  z-index: 1000; /* keep editor under toolbar dropdowns */
}

/* Ensure Quill inside content-editor is always interactive and visible */
.admin .content-editor .ql-toolbar,
.admin .content-editor .ql-container {
  position: relative;
  pointer-events: auto;
}
.admin .content-editor .ql-toolbar {
  z-index: 900; /* below fixed header (1000) */
}
.admin .content-editor .ql-container {
  z-index: 100; /* keep content under navbar */
}

/* Flatten any legacy mini-gallery markup (old content) */
.admin .ql-editor .mini-gallery {
  display: contents;
}
.admin .ql-editor .mini-gallery figure {
  display: block;
  margin: 0.75rem auto;
  max-width: 640px;
}
.admin .ql-editor .mini-gallery img {
  width: 100%;
  height: auto;
  object-fit: cover;
}
/* Aesthetic images inside the Quill editor (smaller by default) */
.admin .ql-editor img {
  display: block;
  width: 100%;
  max-width: 640px; /* reduce dominance */
  height: auto;
  margin: 0.75rem auto;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
/* Allow alignment controls to affect images with good wrapping */
.admin .ql-editor .ql-align-left img {
  float: left;
  margin: 0.5rem 1rem 1rem 0;
}
.admin .ql-editor .ql-align-right img {
  float: right;
  margin: 0.5rem 0 1rem 1rem;
}
.admin .ql-editor .ql-align-center img {
  float: none;
  margin-left: auto;
  margin-right: auto;
}
/* Clear floats within editor content area to avoid layout overflow */
.admin .content-editor:after {
  content: "";
  display: table;
  clear: both;
}

/* Removed mini-gallery layout styles */
/* no custom scrollbar needed when not scrolling */
.admin .content-editor textarea.form-control {
  border: 0;
  min-height: 220px;
  resize: vertical;
}

/* SimpleEditor styles removed: Quill-only editor in use */

/* Ensure Quill popups/dropdowns are above editor but below header */
.admin .ql-tooltip,
.admin .ql-picker-options {
  position: absolute; /* Quill default */
  z-index: 1400; /* above toolbar and header */
  pointer-events: auto;
}

/* Skeleton loaders */
.admin .skeleton .thumb {
  height: 150px;
  border-radius: var(--card-radius);
  background: linear-gradient(
    90deg,
    var(--gray-200),
    var(--gray-300),
    var(--gray-200)
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.admin .skeleton .line {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(
    90deg,
    var(--gray-200),
    var(--gray-300),
    var(--gray-200)
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin: 8px 0;
}
@keyframes shimmer {
  0% {
    background-position: 0% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Admin post card preview (similar to portfolio tiles) */
.admin .admin-post-card {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.25rem;
  box-shadow: none;
  transition: none;
  position: relative;
  z-index: auto;
  min-width: 0;
  pointer-events: none; /* toolbar/buttons re-enable below */
}
@media (max-width: 640px) {
  .admin .admin-post-card {
    grid-template-columns: 160px minmax(0, 1fr); /* keep side-by-side, reduce thumb */
    align-items: start;
  }
  .admin .admin-post-card .thumb img,
  .admin .admin-post-card .thumb.no-thumb {
    height: 120px;
  }
}
@media (max-width: 420px) {
  .admin .admin-post-card {
    grid-template-columns: 1fr; /* stack for very small screens */
  }
  .admin .admin-post-card .thumb {
    margin-bottom: 0.5rem;
  }
  .admin .admin-post-card .thumb img,
  .admin .admin-post-card .thumb.no-thumb {
    height: 180px;
  }
}

/* Ensure action buttons wrap nicely on narrow widths */
.admin .admin-post-card .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Neutralize portfolio hover/overlay effects for admin cards */
.admin .admin-post-card:hover {
  transform: none;
  box-shadow: none;
}
.admin .admin-post-card::before {
  content: none;
}

.admin .admin-post-card .thumb {
  display: block;
  width: 100%;
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.admin .admin-post-card .thumb img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  transform: none !important; /* hard stop on any inherited transforms */
  pointer-events: none; /* image should not capture clicks */
}
/* No-thumb variant: show a strong initial like other cards */
.admin .admin-post-card.no-thumb .thumb.no-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px; /* align with image height in admin cards */
  border-radius: var(--card-radius);
  background: var(--brand-grad-card);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}
.admin .admin-post-card.no-thumb .thumb.no-thumb .initial {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}
/* Variant: blog card without thumbnail */
.admin .admin-post-card.no-thumb {
  grid-template-columns: 160px minmax(0, 1fr);
}
.admin .admin-post-card .thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-200);
  border: 1px dashed var(--gray-500);
  height: 150px;
  border-radius: var(--card-radius);
  box-shadow: none;
}
.admin .admin-post-card .no-thumb-badge {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--gray-600);
}
.admin .admin-post-card .toolbar,
.admin .admin-post-card .toolbar *,
.admin .admin-post-card button,
.admin .admin-post-card a {
  pointer-events: auto; /* allow interactions inside toolbar */
  position: relative;
  z-index: 5;
}

/* Compact action buttons inside cards so they fit small columns */
.admin .admin-post-card .toolbar .btn {
  min-width: auto;
  padding: 0.5rem 1rem;
}

/* Award cards in admin share visitor design with control-specific tweaks */
.admin .award-admin-shell {
  padding: 0.75rem;
}

.admin .award-admin-shell .award-card {
  height: 100%;
}

.admin .award-admin-shell .award-card:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
}

.admin .admin-post-card .admin-post-body h3 {
  margin: 0 0 0.25rem 0;
  color: var(--primary);
}

.admin .admin-post-card .admin-post-body p {
  color: var(--gray-600);
  margin: 0;
}

/* Forms */
.admin .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .admin .form-row {
    grid-template-columns: 1fr;
  }
}

.admin label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.admin .form-control,
.admin input,
.admin textarea {
  width: 100%;
  border: 1px solid var(--gray-400);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  background: var(--gray-50);
}

.admin textarea {
  min-height: 90px;
  resize: vertical;
  position: relative;
  z-index: 0; /* below Quill toolbar/pickers */
}

/* Prevent form groups from clipping floating toolbars/popovers */
.admin .form-group {
  overflow: visible;
}

.admin .help-text {
  color: var(--gray-600);
  font-size: 0.9rem;
}

.admin .gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin .gallery img {
  width: 140px;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.admin .gallery .remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
}

.admin .toolbar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
@media (max-width: 520px) {
  .admin .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .admin .toolbar .btn,
  .admin .toolbar .form-control,
  .admin .toolbar select {
    width: 100%;
  }
}

/* Dashboard actions: responsive grid for primary manage buttons */
.admin .dashboard-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
  justify-items: stretch;
}
.admin .dashboard-actions .btn {
  width: 100%;
}
.admin .dashboard-logout {
  width: 100%;
}

@media (max-width: 480px) {
  .admin .dashboard-actions {
    grid-template-columns: 1fr;
  }
}

/* Layout for large CRUD: sidebar list + editor */
.admin .layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
}

.admin .sidebar {
  background: var(--gray-50);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-400);
  padding: 0.75rem;
  height: 100%;
}

.admin .list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.admin .list-item {
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
}
.admin .list-item:hover {
  background: var(--gray-100);
}
.admin .list-item.selected {
  background: var(--gray-300);
}
.admin .list-item .title {
  font-weight: 600;
}
.admin .list-item .subtitle {
  color: var(--gray-600);
  font-size: 0.9rem;
}

.admin .pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.admin .page-info {
  color: var(--gray-600);
}

.admin .content {
  min-height: 200px;
}

/* Toast notifications */
.admin .toast {
  position: sticky;
  top: 8px;
  z-index: 10;
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  animation: fadeout 3s forwards;
}
.admin .toast.success {
  background: #f2ecdf;
  color: var(--primary-dark);
}
.admin .toast.error {
  background: #eee7db;
  color: var(--primary-dark);
}
@keyframes fadeout {
  0% {
    opacity: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Login */
.admin .login-card {
  max-width: 520px;
  margin: 1rem auto;
}

/* Focus styles for accessibility */
.admin a:focus,
.admin button:focus,
.admin input:focus,
.admin textarea:focus {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}
