/* ============================================================
   GLOBAL RESET
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;

  --secondary: #0f172a;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #0284c7;

  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;

  --sidebar: #0f172a;
  --sidebar-soft: #1e293b;
  --sidebar-text: #cbd5e1;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);

  --container: 1180px;
  --admin-sidebar-width: 260px;
  --topbar-height: 68px;

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--primary);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.container {
  width: min(100% - 32px, var(--container));
  margin-inline: auto;
}

.container-fluid {
  width: 100%;
  max-width: 100%;
  padding: 0 24px;
}

.main {
  min-height: calc(100vh - var(--topbar-height));
  padding: 28px 0 48px;
}

.ctx-admin {
  background: #f1f5f9;
}

.ctx-admin .main {
  padding: 0;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 21px;
  color: var(--secondary);
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.brand-tag {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0;
}

.nav-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link,
.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 650;
  transition: 0.18s ease;
}

.nav-link:hover,
.nav-link.active,
.topbar-link:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-cta {
  background: var(--primary);
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.btn-cta:hover {
  background: var(--primary-dark);
  color: #fff !important;
}

.nav-user,
.topbar-user {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.nav-toggle,
.sidebar-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  color: var(--text);
  font-size: 20px;
}

.topbar-admin {
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.topbar-admin .topbar-inner {
  padding: 0 22px;
}

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

/* ============================================================
   ADMIN SHELL
   ============================================================ */
.admin-shell {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

.sidebar {
  width: var(--admin-sidebar-width);
  flex: 0 0 var(--admin-sidebar-width);
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
}

.sidebar-nav {
  padding: 20px 14px;
}

.sidebar-group {
  margin-bottom: 22px;
}

.sidebar-heading {
  padding: 0 12px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #94a3b8;
  font-weight: 800;
}

.sidebar-link {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--sidebar-text);
  border-radius: 12px;
  font-weight: 650;
  transition: 0.18s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: var(--sidebar-soft);
  color: #fff;
}

.admin-content {
  flex: 1;
  min-width: 0;
  padding: 28px 0 50px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer,
.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
}

.footer-brand {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.footer-text,
.footer-copy {
  margin: 0;
  color: var(--muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--muted);
  font-weight: 650;
}

.footer-links a:hover {
  color: var(--primary);
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-wrap {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-weight: 650;
}

.flash-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.flash-danger,
.flash-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.flash-warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.flash-info {
  border-color: #bae6fd;
  background: #f0f9ff;
  color: #075985;
}

.flash-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.08);
  color: inherit;
  font-size: 18px;
}

/* ============================================================
   PAGE HEADER AND BREADCRUMB
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.18;
  letter-spacing: -0.04em;
  color: var(--secondary);
}

.breadcrumb {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.breadcrumb li:not(:last-child)::after {
  content: "/";
  margin-left: 8px;
  color: var(--border-dark);
}

.breadcrumb a {
  color: var(--muted);
  font-weight: 650;
}

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

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 750;
  line-height: 1;
  transition: 0.18s ease;
  background: #fff;
  color: var(--text);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

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

.btn-light {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-light:hover {
  background: #f8fafc;
}

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

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

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

.btn-sm {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ============================================================
   CARDS AND GRIDS
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-body {
  padding: 20px;
}

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}

.stat-value {
  color: var(--secondary);
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.04em;
}

/* ============================================================
   FORMS
   ============================================================ */
.form {
  display: grid;
  gap: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-group {
  display: grid;
  gap: 7px;
}

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

.required {
  color: var(--danger);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="url"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border-dark);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: 0.18s ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--danger);
}

.field-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

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

.help-text {
  color: var(--muted);
  font-size: 13px;
}

.auth-card {
  width: min(100%, 440px);
  margin: 44px auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-title {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.auth-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.filter-field {
  min-width: 180px;
  flex: 1;
  display: grid;
  gap: 6px;
}

.filter-field label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.filter-actions {
  display: flex;
  gap: 8px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.table th,
.table td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #f8fafc;
  font-weight: 900;
}

.table tr:last-child td {
  border-bottom: 0;
}

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

.table-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.thumb {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  background: #e2e8f0;
  border: 1px solid var(--border);
}

.logo-thumb {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #fff;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  background: #e2e8f0;
  color: #334155;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #e0f2fe;
  color: #075985;
}

.badge-muted {
  background: #f1f5f9;
  color: #64748b;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.page-link {
  min-width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 11px;
  font-weight: 800;
  padding: 0 11px;
}

.page-link:hover,
.page-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.page-link.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================================
   PUBLIC BUSINESS CARDS
   ============================================================ */
.hero {
  background: linear-gradient(135deg, #eff6ff, #ffffff 45%, #eef2ff);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: clamp(26px, 5vw, 56px);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.hero-title {
  margin: 0 0 12px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: -0.06em;
  color: var(--secondary);
}

.hero-text {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 17px;
  max-width: 700px;
}

.search-box {
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  max-width: 760px;
}

.search-box input,
.search-box select {
  border: 0;
  box-shadow: none;
  background: #f8fafc;
}

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

.business-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: 0.2s ease;
}

.business-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.business-card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e2e8f0;
}

.business-card-body {
  padding: 16px;
}

.business-card-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.business-card-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.business-card-text {
  color: var(--muted);
  margin: 0 0 14px;
}

.business-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-header {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

.detail-title {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.05em;
}

.detail-meta {
  color: var(--muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.gallery-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.ad-banner {
  display: block;
  margin: 18px 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.ad-banner img {
  width: 100%;
  object-fit: cover;
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  background: #fff;
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted {
  color: var(--muted);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.text-center {
  text-align: center;
}

.mt-0 {
  margin-top: 0;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.mb-3 {
  margin-bottom: 24px;
}

.hidden {
  display: none !important;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .grid-4,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .business-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: var(--topbar-height);
    z-index: 60;
    transition: left 0.2s ease;
  }

  body.sidebar-open .sidebar {
    left: 0;
  }

  .admin-content {
    width: 100%;
  }
}

@media (max-width: 768px) {
  :root {
    --topbar-height: 64px;
  }

  .container,
  .container-fluid {
    width: min(100% - 24px, var(--container));
    padding: 0;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-main {
    position: absolute;
    top: var(--topbar-height);
    left: 12px;
    right: 12px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 12px;
    box-shadow: var(--shadow);
  }

  body.nav-open .nav-main,
  .nav-main.is-open {
    display: flex;
  }

  .nav-link {
    justify-content: flex-start;
    border-radius: 12px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-user,
  .topbar-link[href*="View"] {
    display: none;
  }

  .page-header,
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-row,
  .grid-2,
  .grid-3,
  .grid-4,
  .stats-grid,
  .business-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-box {
    flex-direction: column;
  }

  .filter-bar {
    display: grid;
  }

  .filter-actions {
    width: 100%;
  }

  .filter-actions .btn {
    flex: 1;
  }

  .auth-card {
    margin: 24px auto;
    padding: 22px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  .hero {
    border-radius: 20px;
  }

  .card-body,
  .card-header,
  .detail-header {
    padding: 16px;
  }

  .table th,
  .table td {
    padding: 10px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }
}