/* Admin section styles layered on top of the public CasaMejor theme. */

.admin-main {
  padding: 24px 0 48px;
}

.admin-hero {
  border-bottom: 1px solid var(--border);
  padding: 28px 0 20px;
}

.admin-hero__eyebrow {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.admin-hero__title {
  color: var(--text);
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.04;
  margin: 0 0 10px;
}

.admin-hero__lede {
  color: var(--text-2);
  margin: 0;
  max-width: 880px;
}

.admin-shell-layout {
  display: grid;
  gap: 16px;
  padding-top: 18px;
}

.admin-alert {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--elev);
  padding: 16px 18px;
}

.admin-alert h3 {
  margin: 0 0 8px;
}

.admin-alert p {
  color: var(--text-2);
  margin: 0;
}

.admin-alert-warning {
  border-color: #8c6a29;
}

.admin-alert-error {
  border-color: #7e3333;
}

.admin-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--elev);
  padding: 18px;
}

.admin-card h3 {
  margin-top: 0;
}

.admin-card-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-card-grid-tight {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
}

.admin-stat-value {
  color: var(--text);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 800;
  margin: 6px 0 0;
}

.admin-stat-value-small {
  font-size: 1rem;
  line-height: 1.4;
}

/* Stat card: minimum readable height on desktop. */
.admin-stat-card {
  min-height: 118px;
}

/* Primary stat value — large number or short relative-age label. */
.admin-stat-primary {
  color: var(--text);
  font-size: clamp(1.25rem, 1.6vw, 1.9rem);
  font-weight: 800;
  line-height: 1.1;
  margin: 10px 0 0;
}

/* Secondary stat line — source name, exact datetime, or sub-label. */
.admin-stat-secondary {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  margin: 6px 0 0;
}

.admin-filters {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.admin-filters label {
  color: var(--text-2);
  display: grid;
  gap: 6px;
}

.admin-filter-actions {
  align-items: end;
  display: flex;
}

.admin-checkbox {
  align-items: center;
  display: flex !important;
  gap: 8px;
  padding-top: 26px;
}

.admin-inline-meta {
  color: var(--muted);
  margin-bottom: 12px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  border-collapse: collapse;
  width: 100%;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-table td {
  color: var(--text-2);
}

.admin-pagination,
.admin-toolbar {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 14px;
}

.admin-toolbar {
  align-items: center;
  margin-bottom: 14px;
}

/* Medium widths: collapse tight grid from 5 to 3 columns. */
@media (max-width: 1080px) {
  .admin-card-grid-tight {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Admin pages: keep the admin navigation reachable on tablets and phones. */
@media (max-width: 980px) {
  .site-header .header-wrap {
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .site-header .main-nav {
    display: flex;
    flex: 1 1 100%;
    gap: 8px;
    order: 3;
    overflow-x: auto;
    padding: 2px 0 4px;
    -webkit-overflow-scrolling: touch;
  }

  .site-header .main-nav .nav-link {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-2);
    flex: 0 0 auto;
    padding: 6px 10px;
    white-space: nowrap;
  }

  .site-header .main-nav .nav-link:hover,
  .site-header .main-nav .nav-link:focus-visible {
    border-color: var(--accent);
    color: var(--text);
  }

  #admin-identity {
    margin-left: auto;
  }
}

/* Narrow widths: collapse all grids to 2 columns. */
@media (max-width: 720px) {
  .admin-card-grid,
  .admin-card-grid-tight,
  .admin-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile: single column. */
@media (max-width: 480px) {
  .admin-card-grid,
  .admin-card-grid-tight,
  .admin-filters {
    grid-template-columns: 1fr;
  }
}

.admin-user-cell {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 180px;
}

.admin-user-avatar {
  border: 1px solid var(--border);
  border-radius: 999px;
  flex: 0 0 auto;
  height: 32px;
  object-fit: cover;
  width: 32px;
}

.admin-user-avatar-fallback {
  align-items: center;
  background: var(--panel-2);
  color: var(--muted);
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 750;
  justify-content: center;
  text-transform: uppercase;
}

.admin-user-name {
  color: var(--text);
  font-weight: 700;
}

.admin-muted {
  color: var(--muted);
  font-size: 0.86em;
}

/* ── Column cell alignment ──────────────────────────────────────── */

/* Right-align numeric listing-count cells. */
.admin-count-cell {
  text-align: right;
}

/* Constrain the newest-title column so long titles do not flood the row. */
.admin-title-cell {
  max-width: 320px;
  overflow: hidden;
}

/* CSS two-line clamp for the title text span. */
.admin-title-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Center the ID and Link columns. */
.admin-link-cell,
.admin-id-cell {
  text-align: center;
}

/* ── Status badges ──────────────────────────────────────────────── */

/* Base badge: compact pill with uppercase label. */
.admin-status-badge {
  border-radius: 4px;
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Current — subtle green tint. */
.admin-status-current {
  background: rgba(56, 142, 60, 0.18);
  color: #66bb6a;
}

/* Possibly stale — amber tint. */
.admin-status-possibly-stale {
  background: rgba(245, 124, 0, 0.18);
  color: #ffa726;
}

/* Stale — red tint. */
.admin-status-stale {
  background: rgba(183, 28, 28, 0.18);
  color: #ef5350;
}

/* No listings found — neutral grey. */
.admin-status-no-listings-found {
  background: rgba(120, 120, 120, 0.15);
  color: var(--muted);
}

/* Disabled — muted grey. */
.admin-status-disabled {
  background: rgba(80, 80, 80, 0.15);
  color: var(--muted);
}

/* Error — red tint, visually distinct class from stale for future use. */
.admin-status-error {
  background: rgba(183, 28, 28, 0.18);
  color: #ef5350;
}

/* Admin click analytics sections reuse existing cards and tables with small
   spacing helpers so the new page remains visually consistent with current
   admin users/sessions/data-updates screens. */
.admin-click-section {
  margin-top: 18px;
}

.admin-click-filters {
  margin-bottom: 18px;
}

.admin-click-secondary-filters {
  margin: 0 0 14px;
}

.admin-sort-control {
  color: var(--text-2);
  display: grid;
  gap: 6px;
  max-width: 260px;
}

/* ── Admin click activity table ─────────────────────────────────── */

.admin-click-events-table-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}

.admin-click-events-table {
  min-width: 1280px;
  table-layout: fixed;
}

.admin-click-events-table th,
.admin-click-events-table td {
  vertical-align: middle;
  white-space: nowrap;
}

.admin-click-events-table th:nth-child(1),
.admin-click-events-table td:nth-child(1) { width: 150px; }
.admin-click-events-table th:nth-child(2),
.admin-click-events-table td:nth-child(2) { width: 210px; }
.admin-click-events-table th:nth-child(3),
.admin-click-events-table td:nth-child(3) { width: 148px; }
.admin-click-events-table th:nth-child(4),
.admin-click-events-table td:nth-child(4) { width: 500px; }
.admin-click-events-table th:nth-child(5),
.admin-click-events-table td:nth-child(5) { width: 100px; }
.admin-click-events-table th:nth-child(6),
.admin-click-events-table td:nth-child(6) { width: 142px; }

.admin-click-user-cell,
.admin-click-listing-cell {
  white-space: normal;
}

.admin-block-text {
  display: block;
}

.admin-time-cell {
  color: var(--text);
  font-size: 0.92rem;
  white-space: nowrap !important;
}

.admin-event-badge,
.admin-session-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  padding: 7px 10px;
  white-space: nowrap;
}

.admin-event-listing {
  background: rgba(46, 91, 146, 0.18) !important;
  border-color: rgba(122, 174, 235, 0.42) !important;
  color: #9fc4f3 !important;
}

.admin-event-contact {
  background: rgba(36, 116, 83, 0.18) !important;
  border-color: rgba(88, 191, 140, 0.44) !important;
  color: #a9dec4 !important;
}

.admin-event-locked {
  background: rgba(145, 100, 35, 0.20) !important;
  border-color: rgba(232, 200, 140, 0.42) !important;
  color: #e8c88c !important;
}

.admin-session-badge {
  background: var(--panel-2);
  color: var(--text);
}

.admin-session-badge-muted {
  color: var(--muted);
}

.admin-click-listing-cell {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 440px;
  max-width: 500px;
}

.admin-listing-thumb-link {
  border-radius: 10px;
  display: inline-flex;
  flex: 0 0 92px;
  height: 68px;
  max-height: 68px;
  max-width: 92px;
  overflow: hidden;
  width: 92px;
}

.admin-listing-thumb {
  border: 1px solid var(--border);
  border-radius: 10px;
  display: block;
  flex: 0 0 92px;
  height: 68px !important;
  max-height: 68px !important;
  max-width: 92px !important;
  min-height: 68px;
  min-width: 92px;
  object-fit: cover;
  width: 92px !important;
}

.admin-listing-thumb-fallback {
  align-items: center;
  background: var(--panel-2);
  color: var(--muted);
  display: inline-flex;
  justify-content: center;
}

.admin-listing-text {
  display: block;
  min-width: 0;
  overflow: hidden;
}

.admin-listing-title {
  color: var(--text);
  display: block;
  font-weight: 800;
  line-height: 1.25;
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-listing-title-link,
.admin-row-link,
.admin-action-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.admin-listing-title-link:hover,
.admin-row-link:hover,
.admin-action-link:hover {
  text-decoration: underline;
}

.admin-row-actions {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  gap: 4px;
  white-space: nowrap;
}

.admin-action-link {
  display: block;
  line-height: 1.25;
  padding: 2px 0;
  white-space: nowrap;
}

.admin-action-separator {
  display: none;
}

.admin-listing-source {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.25;
  margin-top: 4px;
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-source-name-cell {
  color: var(--text-2);
  font-weight: 650;
  white-space: nowrap;
}
