/* ============================================================
   UYIR PUBLICATIONS — ADMIN PANEL CSS
============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --a-bg:      #F4F6F4;
  --a-sidebar: #1C2B1A;
  --a-card:    #FFFFFF;
  --a-border:  #E2E8E2;
  --a-sage:    #4A7C59;
  --a-gold:    #C8A84B;
  --a-dark:    #1C2B1A;
  --a-text:    #2C3B28;
  --a-muted:   #7A8C76;
  --a-danger:  #DC2626;
  --a-success: #16A34A;
  --a-warn:    #D97706;
  --a-info:    #2563EB;
  --a-radius:  8px;
  --a-shadow:  0 1px 4px rgba(28,43,26,0.08);
}
body { font-family: 'Inter', system-ui, sans-serif; background: var(--a-bg); color: var(--a-text); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; }

/* ── LAYOUT ── */
/* NOTE: sidebar is position:fixed (out of normal flow), so admin-layout must NOT
   reserve grid space for it — only admin-main's margin-left creates the offset.
   Previously this used display:grid with a 260px column, which double-offset
   all content alongside admin-main's own margin-left and broke alignment. */
.admin-layout { display: block; min-height: 100vh; width: 100%; overflow-x: hidden; }

/* ── SIDEBAR ── */
.admin-sidebar {
  background: var(--a-sidebar); color: rgba(255,255,255,0.8);
  position: fixed; top: 0; left: 0; bottom: 0; width: 260px;
  overflow-y: auto; display: flex; flex-direction: column;
  transition: transform 0.3s; z-index: 100;
}
.sidebar-logo {
  padding: 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 0.8rem;
}
.sidebar-logo img { height: 36px; filter: brightness(10); }
.sidebar-logo-text strong { display: block; font-size: 0.88rem; color: var(--white, #fff); }
.sidebar-logo-text span { font-size: 0.7rem; color: rgba(255,255,255,0.4); }
.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-group { margin-bottom: 0.5rem; }
.nav-group-label {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(255,255,255,0.3);
  padding: 0.8rem 1.2rem 0.3rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.65rem 1.2rem; color: rgba(255,255,255,0.65);
  transition: all 0.2s; border-radius: 0; font-size: 0.88rem;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: rgba(74,124,89,0.2); color: #fff; border-left-color: var(--a-sage); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-badge {
  margin-left: auto; background: var(--a-gold); color: var(--a-dark);
  font-size: 0.65rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 10px;
}
.sidebar-user {
  padding: 1rem 1.2rem; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 0.8rem;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--a-sage); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0;
}
.sidebar-user-name { font-size: 0.85rem; color: #fff; font-weight: 500; }
.sidebar-user-role { font-size: 0.7rem; color: rgba(255,255,255,0.4); }
.sidebar-user-logout { margin-left: auto; background: none; border: none; color: rgba(255,255,255,0.4); cursor: pointer; transition: color 0.2s; }
.sidebar-user-logout:hover { color: #fff; }
.sidebar-user-logout svg { width: 16px; height: 16px; }

/* ── MAIN AREA ── */
.admin-main { margin-left: 260px; display: flex; flex-direction: column; min-height: 100vh; }

/* ── TOP BAR ── */
.admin-topbar {
  background: var(--a-card); border-bottom: 1px solid var(--a-border);
  padding: 0 1.5rem; height: 56px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
  box-shadow: var(--a-shadow);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.page-title { font-size: 1rem; font-weight: 600; color: var(--a-dark); }
.topbar-breadcrumb { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--a-muted); }
.topbar-breadcrumb a { color: var(--a-sage); }
.topbar-breadcrumb span { color: var(--a-muted); }
.topbar-right { display: flex; align-items: center; gap: 0.8rem; }
.topbar-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--a-border);
  background: transparent; display: flex; align-items: center; justify-content: center;
  color: var(--a-muted); cursor: pointer; transition: all 0.2s; position: relative;
}
.topbar-btn:hover { background: var(--a-bg); color: var(--a-dark); }
.topbar-btn svg { width: 18px; height: 18px; }
.topbar-notif-dot {
  position: absolute; top: 6px; right: 6px; width: 7px; height: 7px;
  background: #E05252; border-radius: 50%; border: 2px solid var(--a-card);
}

/* ── CONTENT ── */
.admin-content { flex: 1; padding: 1.5rem; min-width: 0; max-width: 100%; }

/* ── CARDS ── */
.a-card {
  background: var(--a-card); border-radius: var(--a-radius);
  border: 1px solid var(--a-border); box-shadow: var(--a-shadow);
}
.a-card-header {
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--a-border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.a-card-title { font-size: 0.92rem; font-weight: 600; color: var(--a-dark); }
.a-card-body { padding: 1.2rem; }
.a-card-footer { padding: 0.8rem 1.2rem; border-top: 1px solid var(--a-border); background: var(--a-bg); border-radius: 0 0 var(--a-radius) var(--a-radius); }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--a-card); border-radius: var(--a-radius);
  border: 1px solid var(--a-border); padding: 1.2rem;
  display: flex; align-items: center; gap: 1rem; box-shadow: var(--a-shadow);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.sage { background: rgba(74,124,89,0.12); color: var(--a-sage); }
.stat-icon.gold { background: rgba(200,168,75,0.12); color: var(--a-gold); }
.stat-icon.brown { background: rgba(107,66,38,0.12); color: #8B5E3C; }
.stat-icon.blue { background: rgba(37,99,235,0.1); color: var(--a-info); }
.stat-num { font-size: 1.6rem; font-weight: 700; color: var(--a-dark); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--a-muted); margin-top: 0.2rem; }
.stat-change { font-size: 0.72rem; font-weight: 600; margin-top: 0.2rem; }
.stat-change.up { color: var(--a-success); }
.stat-change.down { color: var(--a-danger); }

/* ── TABLES ── */
.a-table-wrap { overflow-x: auto; }
.a-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.a-table th { padding: 0.65rem 1rem; text-align: left; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--a-muted); background: var(--a-bg); border-bottom: 1px solid var(--a-border); white-space: nowrap; }
.a-table td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--a-border); color: var(--a-text); vertical-align: middle; }
.a-table tr:last-child td { border-bottom: none; }
.a-table tr:hover td { background: var(--a-bg); }
.a-table img.thumb { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--a-bg); }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.7rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 50px; }
.badge-success { background: rgba(22,163,74,0.1); color: var(--a-success); }
.badge-warn { background: rgba(217,119,6,0.1); color: var(--a-warn); }
.badge-danger { background: rgba(220,38,38,0.1); color: var(--a-danger); }
.badge-info { background: rgba(37,99,235,0.1); color: var(--a-info); }
.badge-neutral { background: var(--a-bg); color: var(--a-muted); }

/* ── FORMS ── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--a-dark); margin-bottom: 0.4rem; }
.form-label .req { color: var(--a-danger); }
.form-control {
  width: 100%; padding: 0.6rem 0.9rem; border: 1px solid var(--a-border);
  border-radius: 6px; font-size: 0.88rem; color: var(--a-dark);
  background: var(--a-card); transition: border-color 0.2s; outline: none;
}
.form-control:focus { border-color: var(--a-sage); box-shadow: 0 0 0 3px rgba(74,124,89,0.12); }
.form-control.error { border-color: var(--a-danger); }
.form-hint { font-size: 0.75rem; color: var(--a-muted); margin-top: 0.3rem; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }
.form-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.form-check input { width: 16px; height: 16px; accent-color: var(--a-sage); cursor: pointer; }

/* ── BUTTONS ── */
.a-btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1.1rem; border-radius: 6px; font-size: 0.85rem; font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: all 0.2s; }
.a-btn svg { width: 16px; height: 16px; }
.a-btn-primary { background: var(--a-sage); color: #fff; border-color: var(--a-sage); }
.a-btn-primary:hover { background: #3A6147; }
.a-btn-danger { background: var(--a-danger); color: #fff; border-color: var(--a-danger); }
.a-btn-danger:hover { background: #B91C1C; }
.a-btn-outline { background: transparent; color: var(--a-dark); border-color: var(--a-border); }
.a-btn-outline:hover { background: var(--a-bg); }
.a-btn-gold { background: var(--a-gold); color: var(--a-dark); border-color: var(--a-gold); }
.a-btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.a-btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* ── TOGGLE SWITCH ── */
.toggle-wrap { display: flex; align-items: center; gap: 0.6rem; }
.toggle { position: relative; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--a-border); border-radius: 22px; cursor: pointer; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; bottom: 3px; left: 3px; transition: 0.3s; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.toggle input:checked + .toggle-slider { background: var(--a-sage); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-label { font-size: 0.85rem; color: var(--a-text); }

/* ── IMAGE UPLOADER ── */
.img-uploader {
  border: 2px dashed var(--a-border); border-radius: var(--a-radius);
  padding: 2rem; text-align: center; cursor: pointer; transition: all 0.2s;
  background: var(--a-bg); position: relative;
}
.img-uploader:hover, .img-uploader.drag-over { border-color: var(--a-sage); background: rgba(74,124,89,0.04); }
.img-uploader input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.img-uploader svg { width: 40px; height: 40px; color: var(--a-muted); margin: 0 auto 0.8rem; }
.img-uploader p { font-size: 0.85rem; color: var(--a-muted); }
.img-uploader span { color: var(--a-sage); font-weight: 500; }
.img-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.6rem; margin-top: 1rem; }
.img-preview-item { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; }
.img-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.img-preview-remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; background: rgba(220,38,38,0.9); color: #fff; border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; }

/* ── TABS ── */
.a-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--a-border); margin-bottom: 1.2rem; }
.a-tab { padding: 0.65rem 1.1rem; font-size: 0.85rem; font-weight: 500; color: var(--a-muted); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; transition: all 0.2s; margin-bottom: -1px; }
.a-tab:hover { color: var(--a-dark); }
.a-tab.active { color: var(--a-sage); border-bottom-color: var(--a-sage); }

/* ── GRID UTILS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.gap-1 { gap: 1rem; }

/* ── ALERTS ── */
.a-alert { display: flex; align-items: flex-start; gap: 0.8rem; padding: 0.8rem 1rem; border-radius: 6px; font-size: 0.85rem; margin-bottom: 1rem; }
.a-alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.a-alert-success { background: rgba(22,163,74,0.08); color: #14532D; border: 1px solid rgba(22,163,74,0.2); }
.a-alert-danger { background: rgba(220,38,38,0.08); color: #7F1D1D; border: 1px solid rgba(220,38,38,0.2); }
.a-alert-warn { background: rgba(217,119,6,0.08); color: #78350F; border: 1px solid rgba(217,119,6,0.2); }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: 0.3rem; }
.page-btn { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--a-border); background: transparent; color: var(--a-text); font-size: 0.82rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.page-btn:hover, .page-btn.active { background: var(--a-sage); color: #fff; border-color: var(--a-sage); }

/* ── RICH TEXT EDITOR ── */
.editor-toolbar { display: flex; gap: 0.3rem; flex-wrap: wrap; padding: 0.5rem; background: var(--a-bg); border: 1px solid var(--a-border); border-radius: 6px 6px 0 0; border-bottom: none; }
.editor-btn { width: 30px; height: 30px; border-radius: 4px; border: none; background: transparent; color: var(--a-text); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; transition: background 0.15s; }
.editor-btn:hover { background: var(--a-border); }
.editor-btn.active { background: var(--a-sage); color: #fff; }
.editor-content { min-height: 200px; padding: 0.8rem; border: 1px solid var(--a-border); border-radius: 0 0 6px 6px; outline: none; font-size: 0.88rem; line-height: 1.7; }

/* ── CHART PLACEHOLDER ── */
.chart-placeholder { height: 200px; background: var(--a-bg); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--a-muted); font-size: 0.85rem; }

/* ── MOBILE SIDEBAR OVERLAY ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 99; opacity: 0; transition: opacity 0.25s;
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* ── RESPONSIVE ── */
@media (max-width: 1280px) {
  .stats-grid[style*="repeat(5"] { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 1024px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .form-row-2 { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
