/* ========== Base / Variables ========== */
:root {
  --bg: #f5f6f8;            /* app background */
  --surface: #ffffff;       /* cards/panels */
  --text: #1e1e1e;          /* primary text */
  --muted: #8c8c8c;         /* secondary text */
  --accent: #7A3B4E;        /* Atlanta Locals maroon */
  --sidebar-bg: #1c1c1c;    /* dark sidebar */
  --sidebar-text: #e6e6e6;  /* light text in sidebar */
  --border: #e6e7eb;        /* subtle borders */
  --radius: 14px;           /* rounded corners */
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 20px;
  --space-5: 24px;

  /* Table-specific tokens */
  --table-head-bg: #fafbfc;
  --table-row-hover: #faf7f8;
  --link: #334155;
  --link-hover: #111827;
  --danger: #b42318;
  --danger-ink: #7f1d1d;
}

/* Base reset-ish */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Layout: sidebar + main */
.admin-wrapper {
  display: grid;
  grid-template-columns: 260px 1fr;  /* fixed sidebar, fluid main */
  min-height: 100vh;
}

/* ========== Aside (Left Nav) ========== */
.admin-sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: var(--space-5) var(--space-4);
}

.sidebar-header { margin-bottom: var(--space-5); }

.brand-title {
  margin: 0 0 var(--space-1) 0;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #ffffff;
}

.brand-subtitle {
  margin: 0;
  font-size: 13px;
  color: #cfcfcf;
}

.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li + li { margin-top: var(--space-3); }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.2s ease, color 0.2s ease;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #ffffff; }

.nav-icon { width: 22px; text-align: center; opacity: 0.95; }
.nav-label { font-size: 15px; letter-spacing: 0.2px; }

.sidebar-nav a.is-active {
  background: rgba(122, 59, 78, 0.22);
  color: #ffffff;
  border: 1px solid rgba(122, 59, 78, 0.35);
}

/* Backdrop for mobile overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 80;
}

/* ========== Main Area ========== */
.admin-main {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
}

/* Top Bar (first row in main) */
.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
}

.page-title h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.user-info { display: flex; align-items: center; gap: var(--space-2); }
.user-email { font-size: 14px; color: var(--muted); }

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
}

/* Hamburger button (mobile only) */
.hamburger-btn {
  background: none; border: 0; font-size: 22px; line-height: 1;
  cursor: pointer; padding: 8px 10px; display: none;
}

/* ========== Content Container (Second Row) ========== */
.admin-content-container {
  background: var(--bg);
  padding: var(--space-4);
  border-radius: var(--radius);
}

.content-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.content-card-header { margin-bottom: var(--space-5); }
.content-card-title { margin: 0; font-size: 18px; font-weight: 700; }
.content-card-subtitle { margin: var(--space-1) 0 0 0; font-size: 14px; color: var(--muted); }

/* Header row that holds title/subtitle on the left and a CTA on the right */
.content-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* Content Option Row */
.content-option {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--surface);
  transition: border-color 0.2s ease;
}
.content-option:hover { border-color: var(--accent); }

.content-option-icon { font-size: 24px; margin-bottom: var(--space-2); }
.content-option-info { margin-bottom: var(--space-3); }

.option-title { margin: 0 0 var(--space-1) 0; font-size: 16px; font-weight: 600; }
.option-description { margin: 0; font-size: 14px; color: var(--muted); }

.content-option-action { margin-top: auto; }

/* Primary button style (works for <a> and <button>) */
.btn-select {
  display: inline-flex;          /* ensure anchors behave like buttons */
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;         /* remove underline on <a> */
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.02s ease;
}
.btn-select:hover { background: #652f3e; }
.btn-select:active { transform: translateY(1px); }
.btn-select:focus-visible {
  outline: 3px solid rgba(122,59,78,0.25);
  outline-offset: 2px;
}

/* ========== “Create New” CTA in card headers ========== */
.btn-create {
  display: inline-flex;
  align-items: center;
  background-color: #4CAF50; /* Green */
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out, transform 0.02s ease;
}
.btn-create:hover { background-color: #45a049; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.btn-create:active { transform: translateY(1px); }

.plus-icon {
  font-size: 18px;
  margin-right: 6px;
  font-weight: bold;
  line-height: 1;
}

/* ========== Admin Form (Create Post) ========== */
.content-card form { display: grid; gap: var(--space-4); }
.form-group { display: grid; gap: var(--space-2); }

.form-group label { font-size: 14px; color: var(--muted); }

.form-group input[type="text"],
.form-group input[type="file"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbfc;
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.form-group textarea { resize: vertical; min-height: 140px; }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 59, 78, 0.15);
  background: #fff;
}

/* Submit row aligns right by default */
.content-card form .form-group:last-child {
  display: flex;
  justify-content: flex-end;
}

/* Use existing .btn-select styles for the submit button */
.content-card form .btn-select { padding: 10px 18px; font-weight: 600; }

/* Optional: simple two-column layout on wider screens */
@media (min-width: 992px) {
  .content-card form { grid-template-columns: 1fr 1fr; }
  /* Make big fields span full width */
  #title, #slug, #content, .form-group:last-child { grid-column: 1 / -1; }
}

/* Accessibility: respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .admin-sidebar { transition: none !important; }
}

/* ========== Responsive & Toggle ========== */
@media (min-width: 768px) {
  .content-option { flex-direction: row; align-items: center; }
  .content-option-icon { margin-bottom: 0; margin-right: var(--space-3); }
  .content-option-info { flex: 1; margin-bottom: 0; }
  .content-option-action { margin-top: 0; }
}

@media (max-width: 767px) {
  .admin-wrapper { grid-template-columns: 1fr; }
  .admin-main { padding-top: calc(56px + env(safe-area-inset-top)); }

  .admin-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px;
    transform: translateX(-100%); transition: transform 0.25s ease;
    z-index: 90; display: block; text-align: left; padding-top: var(--space-5);
  }
  .admin-sidebar.is-open { transform: translateX(0); }
  body.sidebar-open { overflow: hidden; }
  .sidebar-nav a { justify-content: flex-start; }
  .hamburger-btn { display: inline-block; }

  .global-hamburger {
    position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 12px;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    transition: left 0.25s ease;
  }
  body.sidebar-open .global-hamburger { left: 272px; }
}

/* =====================================================
   ADMIN TABLES (Reusable Across All Admin List Views)
   ===================================================== */

/* Scroll container so wide tables don’t break layout */
.table-wrapper {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
}

/* Core table */
.admin-table {
  width: 100%;
  min-width: 900px;               /* allow consistent columns */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

/* Head */
.admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 700;
  color: #111827;
  background: var(--table-head-bg);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

/* Body cells */
.admin-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Row hover & zebra */
.admin-table tbody tr:hover { background: var(--table-row-hover); }
.admin-table tbody tr:nth-child(even) { background: #fff; }

/* Rounded corners (first/last visible cells) */
.admin-table thead th:first-child { border-top-left-radius: 12px; }
.admin-table thead th:last-child { border-top-right-radius: 12px; }
.admin-table tbody tr:last-child td:first-child { border-bottom-left-radius: 12px; }
.admin-table tbody tr:last-child td:last-child { border-bottom-right-radius: 12px; }

/* Truncation helpers for long text */
.cell--truncate {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Actions cell: inline links with spacing */
.cell-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Action links (reused everywhere) */
.btn-link {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 10px;
  background: #fff;
  transition: color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn-link:hover {
  color: var(--link-hover);
  border-color: #cfd3da;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.btn-link.danger {
  color: var(--danger-ink);
  border-color: rgba(180,35,24,0.25);
  background: rgba(180,35,24,0.06);
}
.btn-link.danger:hover {
  border-color: rgba(180,35,24,0.45);
  background: rgba(180,35,24,0.10);
}

/* Optional small thumbnail if you ever render images in a cell */
.thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Pagination (generic) */
.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 6px 0;
}
.page-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
}
.page-btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}
.page-number {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 14px;
}
.page-number.is-active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

/* Narrow screens: let the wrapper scroll horizontally */
@media (max-width: 640px) {
  .admin-table { min-width: 700px; }
}
