/* ═══════════════════════════════════════════════════════
   HD Estate — Admin Panel Styles
═══════════════════════════════════════════════════════ */

:root {
  --g9: #0f2118; --g8: #1e3a2f; --g7: #2d5a45; --g6: #3a7a5e;
  --a5: #e8803a; --a4: #f0a060; --a1: #fef3c7;
  --bg: #f4f6f3; --surface: #fff; --border: #e2e8e0;
  --text-1: #111827; --text-2: #374151; --text-3: #6b7280; --text-4: #9ca3af;
  --red: #dc2626; --red-bg: #fef2f2; --red-border: #fecaca;
  --green-bg: #f0faf5; --green-border: #a7f3d0;
  --amber-bg: #fffbeb; --amber-border: #fde68a;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  display: flex;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 1rem; }

/* ── Sidebar ────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--g8);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 8px;
}
.sidebar-logo span { color: var(--a4); }

.sidebar-section {
  padding: 8px 12px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  margin: 8px 0 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  font-weight: 500;
  transition: background .2s, color .2s;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.sidebar-nav a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}
.sidebar-nav a svg { opacity: .7; flex-shrink: 0; }
.sidebar-nav a:hover svg, .sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  font-size: .8rem;
  transition: color .2s;
}
.sidebar-footer a:hover { color: rgba(255,255,255,.85); }

/* ── Main area ──────────────────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.admin-content {
  padding: 28px;
  flex: 1;
}

/* ── Page heading ───────────────────────────────────────── */
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-heading h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.page-heading p {
  font-size: .875rem;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  border: none;
  transition: all .18s;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--g7); color: #fff; }
.btn-primary:hover { background: var(--g8); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); color: var(--text-2); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--g6); color: var(--g8); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1.5px solid var(--red-border); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 6px; }

/* ── Stats cards ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; }
.stat-label { font-size: .8rem; color: var(--text-3); margin-top: 2px; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.table-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  flex: 1; max-width: 280px;
}
.table-search input {
  border: none;
  background: none;
  outline: none;
  color: var(--text-1);
  font-size: .875rem;
  width: 100%;
}
.table-search input::placeholder { color: var(--text-4); }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 16px;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

.td-title { font-weight: 600; color: var(--text-1); max-width: 300px; }
.td-title-sub { font-size: .78rem; color: var(--text-4); margin-top: 2px; font-weight: 400; }
.td-img { width: 56px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--bg); }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green  { background: var(--green-bg);  color: #059669; }
.badge-amber  { background: var(--amber-bg);  color: #92400e; }
.badge-gray   { background: var(--bg);        color: var(--text-3); }

/* ── Form ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.form-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  font-weight: 700;
  color: var(--text-1);
  background: var(--bg);
}
.form-card-body { padding: 20px; }

.form-row { margin-bottom: 18px; }
.form-row:last-child { margin-bottom: 0; }

label.field-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
label.field-label .required { color: var(--red); }
.field-hint { font-size: .75rem; color: var(--text-4); margin-top: 4px; }

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-1);
  background: var(--surface);
  transition: border-color .18s, box-shadow .18s;
  outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--g6);
  box-shadow: 0 0 0 3px rgba(58,122,94,.15);
}
.form-textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.form-input.has-count { padding-right: 52px; }

.input-wrap { position: relative; }
.char-count {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: .72rem;
  color: var(--text-4);
  pointer-events: none;
}

/* Slug field */
.slug-wrap { display: flex; gap: 8px; align-items: center; }
.slug-prefix {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 9px 10px;
  font-size: .8rem;
  color: var(--text-3);
  white-space: nowrap;
  border-right: none;
}
.slug-input {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  flex: 1;
}

/* Image upload */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-area:hover {
  border-color: var(--g6);
  background: var(--green-bg);
}
.upload-area svg { margin: 0 auto 8px; color: var(--text-4); }
.upload-area p  { font-size: .8rem; color: var(--text-3); }
.upload-area input { display: none; }

#image-preview {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  display: none;
}
.current-image-wrap { margin-bottom: 12px; }
.current-image-wrap img {
  width: 100%;
  border-radius: var(--radius-sm);
  aspect-ratio: 16/9;
  object-fit: cover;
}

/* Toggle / switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toggle-switch {
  position: relative;
  width: 42px; height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
input:checked + .toggle-slider { background: var(--g6); }
input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-label { font-size: .875rem; color: var(--text-2); }

/* ── Alert ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--green-bg);  border: 1px solid var(--green-border); color: #065f46; }
.alert-error   { background: var(--red-bg);    border: 1px solid var(--red-border);   color: #991b1b; }
.alert-warning { background: var(--amber-bg);  border: 1px solid var(--amber-border); color: #92400e; }

/* ── Quill editor ───────────────────────────────────────── */
.ql-container { font-size: .9375rem; font-family: inherit; border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important; }
.ql-toolbar { border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important; border-color: var(--border) !important; }
.ql-container { border-color: var(--border) !important; min-height: 320px; }
.ql-editor { min-height: 320px; line-height: 1.7; }
.ql-editor:focus-within { box-shadow: inset 0 0 0 2px rgba(58,122,94,.2); }

/* ── Login page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--g9) 0%, var(--g8) 100%);
  padding: 24px;
  margin-left: 0 !important;
}
.login-box {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--g8);
  margin-bottom: 6px;
}
.login-logo span { color: var(--a5); }
.login-subtitle { font-size: .875rem; color: var(--text-3); margin-bottom: 28px; }
.login-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; }

/* ── Delete confirm ─────────────────────────────────────── */
.delete-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--red-border);
  padding: 32px;
  max-width: 500px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  body { display: block; }
  .admin-sidebar { display: none; }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .table-wrap { overflow-x: auto; }
}
