:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #c81e1e;
  --accent-hover: #a51616;
  --whatsapp: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
  --font: 'Hind', 'Poppins', 'Noto Sans Devanagari', 'Nirmala UI', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

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

.admin-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Auth */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 10px 25px rgba(17, 24, 39, 0.06);
}

.auth-header {
  text-align: center;
  margin-bottom: 22px;
}

.auth-header h1 {
  margin: 8px 0 4px;
  font-size: 1.4rem;
}

.auth-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.auth-footer a:hover {
  color: var(--text);
}

.brand-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

/* Topbar */
.admin-topbar {
  background: #111827;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  gap: 10px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
}

.admin-brand small {
  font-weight: 500;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.14);
  padding: 2px 7px;
  border-radius: 999px;
}

.nav-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.admin-nav {
  display: none;
  width: 100%;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.admin-nav.open {
  display: flex;
}

.admin-nav a {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #d1d5db;
}

.admin-nav a:hover,
.admin-nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.admin-nav .nav-logout {
  color: #fca5a5;
}

/* Main */
.admin-main {
  padding-top: 22px;
  padding-bottom: 50px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 1.55rem;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.82rem;
}

.btn-full {
  width: 100%;
}

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

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

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

.btn-secondary:hover {
  background: #f9fafb;
}

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

.btn-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

/* Alerts & Banners */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 0.92rem;
}

.alert ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.share-success-box {
  background: #ecfdf5;
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.share-url-line {
  font-size: 0.82rem;
  color: #047857;
  word-break: break-all;
}

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

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-value {
  font-size: 1.5rem;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.panel-heading {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.filter-tabs {
  display: flex;
  gap: 6px;
}

.filter-tabs a {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--muted);
}

.filter-tabs a.active {
  background: var(--text);
  color: #fff;
}

.toolbar-search {
  display: flex;
  gap: 6px;
  width: 100%;
}

.toolbar-search input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

/* Article List */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.article-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: center;
}

.article-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #e5e7eb;
}

.article-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.article-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-published {
  background: #dcfce7;
  color: #166534;
}

.status-draft {
  background: #fef3c7;
  color: #92400e;
}

.status-featured {
  background: #fee2e2;
  color: #991b1b;
}

.status-video {
  background: #e0e7ff;
  color: #3730a3;
}

.embed-status-pill {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.embed-status-ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.embed-status-err {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.cat-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 999px;
}

.article-item-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
  line-height: 1.3;
}

.article-item-sub {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.article-item-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  gap: 6px;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-form {
  display: inline;
}

.empty-box {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}

/* Forms */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label,
.upload-box > label {
  font-size: 0.88rem;
  font-weight: 600;
}

.req {
  color: var(--accent);
}

.field-hint {
  margin: 2px 0 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 30, 30, 0.1);
}

.slug-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
}

.slug-prefix {
  padding: 0 10px;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slug-input-wrap input {
  border: none;
  border-left: 1px solid #d1d5db;
  border-radius: 0;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

/* Rich Text Editor */
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.rte-toolbar button {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}

.rte-toolbar button:hover {
  background: #f3f4f6;
}

.rte-editable {
  min-height: 240px;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 0 0 8px 8px;
  background: #fff;
  outline: none;
  line-height: 1.65;
}

.rte-editable:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
}

.rte-editable:focus {
  border-color: var(--accent);
}

.sr-only-textarea {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Uploads & Previews */
.images-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.upload-box {
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  padding: 14px;
  background: #fafafa;
}

.upload-box input[type="file"] {
  width: 100%;
  font-size: 0.86rem;
  margin-bottom: 10px;
}

.upload-preview {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #e5e7eb;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-placeholder {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Live WhatsApp Preview Card */
.wa-preview-card {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  overflow: hidden;
  background: #f0f2f5;
}

.wa-preview-img-wrap {
  aspect-ratio: 1200 / 630;
  background: #dfe3e8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.wa-preview-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wa-preview-no-img {
  font-size: 0.82rem;
  color: #6b7280;
}

.wa-preview-body {
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

.wa-preview-title {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.3;
  margin-bottom: 4px;
}

.wa-preview-desc {
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.35;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wa-preview-domain {
  font-size: 0.74rem;
  color: #9ca3af;
}

/* Editor Grid */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.cat-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.stack-col {
  display: flex;
  flex-direction: column;
}

.radio-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-pill {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}

.ads-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ad-card-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: center;
}

.ad-card-preview {
  width: 100%;
  max-width: 180px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #f3f4f6;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ad-code-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  padding: 8px;
  text-align: center;
}

.ad-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.sub-heading {
  margin: 0;
  font-size: 0.96rem;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.swatch-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d1d5db;
  cursor: pointer;
  padding: 0;
}

.swatch-btn.active {
  box-shadow: 0 0 0 2px #111827;
  transform: scale(1.08);
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-row input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

@media (min-width: 720px) {
  .ads-grid {
    grid-template-columns: 420px 1fr;
  }
  .ad-card-row {
    grid-template-columns: 140px 1fr auto;
  }
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 720px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .toolbar-search {
    width: auto;
  }
  .article-item {
    grid-template-columns: 140px 1fr auto;
  }
  .images-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col-grid {
    grid-template-columns: 360px 1fr;
  }
}

@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }
  .admin-nav {
    display: flex;
    width: auto;
    flex-direction: row;
    align-items: center;
    padding-top: 0;
    border-top: none;
  }
  .editor-layout {
    grid-template-columns: 1fr 350px;
  }
}
