/* =========================================================================
   admin.css — shared styles for all newhome admin pages
   Layout: fixed 240px sidebar + scrollable main content area
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:        #cc223d;
  --accent-dark:   #890218;
  --ink:           #1f3f7c;
  --ink-2:         #082e76;
  --ink-muted:     rgba(15,15,18,0.55);
  --page-bg:       #EDE9E2;
  --page-bg-2:     #F5F2EC;
  --surface:       #FFFFFF;
  --hairline:      rgba(15,15,18,0.1);
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        14px;
  --radius-sm:     8px;
  --shadow-sm:     0 2px 8px rgba(15,15,18,0.06);
  --shadow-md:     0 6px 24px rgba(15,15,18,0.09);
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #cc223d;
  --info:          #0ea5e9;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--page-bg-2);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.admin-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}


.sidebar-logo {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 92px;
  padding: 1.1rem 1.5rem 1rem;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-logo a {
  display: inline-flex;
  align-items: center;
  width: 100%;
  text-decoration: none;
}

.sidebar-logo img {
  display: block;
  width: 142px;
  max-width: 100%;
  max-height: 58px;
  object-fit: contain;
}

.sidebar-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  padding: 1.2rem 1.5rem 0.4rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  min-height: 48px;
  gap: 10px;
  padding: 11px 1.5rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.18s;
}

.sidebar-nav a i {
  width: 18px;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  flex-shrink: 0;
}

.sidebar-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.07);
  border-left-color: rgba(255,255,255,0.3);
}

.sidebar-nav a:hover i { color: rgba(255,255,255,0.85); }

.sidebar-nav a.active {
  color: #fff;
  background: rgba(204,34,61,0.2);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-nav a.active i { color: #fff; }

.sidebar-nav-site {
  flex: 0 0 auto;
}

.sidebar-bottom {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.8rem;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }

.sidebar-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
  text-transform: capitalize;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  min-height: 48px;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: rgba(204,34,61,0.15);
  border: 1px solid rgba(204,34,61,0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
}

.sidebar-logout:hover {
  background: rgba(204,34,61,0.28);
  color: #fff;
}

.system-sidebar-toggle,
.system-sidebar-backdrop {
  display: none;
}

/* ── Main area ───────────────────────────────────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.topbar-breadcrumb a {
  color: var(--ink-muted);
  text-decoration: none;
}

.topbar-breadcrumb a:hover { color: var(--ink); }

.topbar-breadcrumb .sep { opacity: 0.4; }

.topbar-breadcrumb .current {
  color: var(--ink);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.topbar-badge .badge-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* ── Content area ────────────────────────────────────────────────────────── */
.admin-content {
  flex: 1;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
}

.page-header p {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  margin-bottom: 4px;
}

.stat-card-icon.blue   { background: rgba(14,165,233,0.1);  color: #0ea5e9; }
.stat-card-icon.green  { background: rgba(22,163,74,0.1);   color: var(--success); }
.stat-card-icon.red    { background: rgba(204,34,61,0.1);   color: var(--accent); }
.stat-card-icon.amber  { background: rgba(217,119,6,0.1);   color: var(--warning); }
.stat-card-icon.navy   { background: rgba(31,63,124,0.1);   color: var(--ink); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* ── Cards / panels ──────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--hairline);
}

.panel-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title i { color: var(--accent); }

.panel-action {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s;
}

.panel-action:hover { background: rgba(204,34,61,0.07); }

.panel-body { padding: 1.5rem; }

.panel-body-flush { padding: 0; }

/* ── Two-column layout for charts ────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
/* Table wraps scroll horizontally instead of squeezing columns unreadably. */
.panel-body-flush,
.tab-content,
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--page-bg-2);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--page-bg-2); }

.data-table .mono {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* ── Badges / status pills ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-available, .badge-approved  { background: rgba(22,163,74,0.1);  color: #15803d; }
.badge-draft,     .badge-pending   { background: rgba(217,119,6,0.1);  color: #b45309; }
.badge-reserved                    { background: rgba(14,165,233,0.1); color: #0369a1; }
.badge-sold_out,  .badge-rejected  { background: rgba(204,34,61,0.1);  color: var(--accent); }
.badge-hidden,    .badge-suspended { background: rgba(15,15,18,0.07);  color: var(--ink-muted); }
.badge-archived                    { background: rgba(15,15,18,0.07);  color: var(--ink-muted); }
.badge-contributor                 { background: rgba(31,63,124,0.1);  color: var(--ink); }
.badge-admin, .badge-super_admin   { background: rgba(204,34,61,0.1);  color: var(--accent); }
.badge-agency                      { background: rgba(22,163,74,0.1);  color: #15803d; }
.badge-viewer                      { background: rgba(14,165,233,0.08); color: #0369a1; }
.badge-primary   { background: rgba(31,63,124,0.1);  color: var(--ink); }
.badge-resale    { background: rgba(217,119,6,0.1);  color: #b45309; }
.badge-rent      { background: rgba(14,165,233,0.1); color: #0369a1; }
.badge-share     { background: rgba(22,163,74,0.1);  color: #15803d; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.18s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}

.btn-primary:hover { background: var(--ink-2); }

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover { background: var(--accent-dark); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--hairline);
}

.btn-ghost:hover { background: var(--page-bg-2); }

.btn-danger {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(204,34,61,0.3);
}

.btn-danger:hover { background: rgba(204,34,61,0.06); }

.btn-success {
  background: transparent;
  color: var(--success);
  border: 1px solid rgba(22,163,74,0.35);
}

.btn-success:hover { background: rgba(22,163,74,0.07); }

.btn-sm { min-height: 48px; padding: 6px 12px; font-size: 0.78rem; border-radius: 6px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms inside admin panels ───────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.2rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.span-2 { grid-column: span 2; }
.form-field.span-3 { grid-column: span 3; }

.form-field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-2);
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: var(--page-bg-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: all 0.18s;
  width: 100%;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(31,63,124,0.12);
}

.form-field textarea { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.form-error {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}

.form-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 1.2rem;
  grid-column: 1 / -1;
}

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--ink-muted);
}

.empty-state i { font-size: 2.5rem; opacity: 0.3; margin-bottom: 1rem; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── Search/filter bar ───────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--hairline);
  background: var(--page-bg-2);
  flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}

.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--ink);
}

.filter-bar input { min-width: 220px; }

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--hairline);
  padding: 0 1.5rem;
  background: var(--surface);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  padding: 14px 18px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--ink); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Simple bar chart (CSS only) ─────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 50px;
  align-items: center;
  gap: 10px;
}

.bar-label { font-size: 0.78rem; font-weight: 600; color: var(--ink); text-transform: capitalize; }

.bar-track {
  height: 10px;
  background: var(--page-bg);
  border-radius: 100px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 100px;
  background: var(--ink);
  transition: width 0.4s ease;
}

.bar-fill.accent { background: var(--accent); }
.bar-fill.green  { background: var(--success); }
.bar-fill.amber  { background: var(--warning); }
.bar-fill.blue   { background: var(--info); }

.bar-count { font-size: 0.78rem; font-weight: 700; color: var(--ink-muted); text-align: right; }

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease;
  min-width: 260px;
}

.toast.success { background: #15803d; }
.toast.error   { background: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal overlay ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8,46,118,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(15,15,18,0.18);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--hairline);
}

.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--ink); }

.modal-close {
  width: 48px; height: 48px;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--hairline);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--ink-muted);
  transition: all 0.15s;
}

.modal-close:hover { background: var(--page-bg-2); color: var(--ink); }

.modal-body { padding: 1.5rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--hairline);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 1.2rem;
  border-top: 1px solid var(--hairline);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.page-btn:hover   { background: var(--page-bg-2); }
.page-btn.current { background: var(--ink); color: #fff; border-color: var(--ink); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Responsive collapse (tablets) ───────────────────────────────────────── */
@media (max-width: 900px) {
  .admin-sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .system-sidebar-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 130;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    cursor: pointer;
  }
  .system-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    border: 0;
    background: rgba(10,14,24,.55);
  }
  .system-sidebar-open .system-sidebar-backdrop { display: block; }
  .system-sidebar-open { overflow: hidden; }
  .admin-topbar { padding-left: 4.5rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .form-field.span-2,
  .form-field.span-3 { grid-column: span 1; }
  .data-table { min-width: 640px; }
}

/* ── Responsive collapse (phones) ────────────────────────────────────────── */
@media (max-width: 640px) {
  .admin-content { padding: 1rem; }

  .page-header { margin-bottom: 1.4rem; }
  .page-header h1 { font-size: 1.4rem; }

  .admin-topbar {
    height: auto;
    min-height: var(--topbar-h);
    flex-wrap: wrap;
    row-gap: 10px;
    padding: 12px 1rem 12px 4.5rem;
  }

  .topbar-breadcrumb { flex: 1 1 100%; overflow-x: auto; white-space: nowrap; }
  .topbar-actions { flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
  .stat-card { padding: 1.1rem 1.1rem; }
  .stat-value { font-size: 1.6rem; }

  .panel-header { padding: 1rem; flex-wrap: wrap; gap: 0.6rem; }
  .panel-body { padding: 1rem; }

  .filter-bar { padding: 0.85rem 1rem; }
  .filter-bar input,
  .filter-bar select { min-width: 0; flex: 1 1 100%; }

  .modal-overlay { padding: 1rem; }
  .modal-header,
  .modal-footer { padding: 1rem; flex-wrap: wrap; gap: 0.6rem; }
  .modal-body { padding: 1.1rem; }

  .bar-row { grid-template-columns: 76px 1fr 34px; gap: 8px; }
  .bar-label { font-size: 0.72rem; }

  .empty-state { padding: 2.25rem 1.25rem; }

  #toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { min-width: 0; width: 100%; }
}
