/* ================================================================
   LadiCMS Admin Panel — Design System
   Modern Dark Sidebar + Clean Content Area
================================================================ */

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

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --sidebar-bg:      #0f172a;
  --sidebar-hover:   #1e293b;
  --sidebar-active:  #1d4ed8;
  --sidebar-text:    #94a3b8;
  --sidebar-text-active: #fff;
  --sidebar-width:   250px;

  --topbar-bg:       #fff;
  --topbar-border:   #e2e8f0;
  --topbar-height:   64px;

  --bg-body:         #f1f5f9;
  --bg-card:         #fff;
  --bg-card-hover:   #f8fafc;
  --border:          #e2e8f0;

  --text-primary:    #0f172a;
  --text-secondary:  #475569;
  --text-muted:      #94a3b8;

  --primary:         #1d4ed8;
  --primary-hover:   #1e40af;
  --primary-light:   #dbeafe;
  --success:         #059669;
  --success-light:   #d1fae5;
  --warning:         #d97706;
  --warning-light:   #fef3c7;
  --danger:          #dc2626;
  --danger-light:    #fee2e2;
  --info:            #0891b2;
  --info-light:      #cffafe;

  --radius:          10px;
  --radius-sm:       6px;
  --radius-lg:       16px;
  --shadow:          0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:       0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg:       0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);

  --transition:      all .2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'Inter', sans-serif; background: var(--bg-body); color: var(--text-primary); min-height: 100vh; display: flex; }

/* ── Layout Shell ───────────────────────────────────────────── */
.admin-layout { display: flex; width: 100%; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: var(--transition);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1e293b;
  display: flex; align-items: center; gap: 12px;
  text-decoration: none;
}
.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-logo-text { color: #fff; font-size: .95rem; font-weight: 700; line-height: 1.2; }
.sidebar-logo-sub  { color: var(--sidebar-text); font-size: .72rem; font-weight: 400; }

.sidebar-nav { padding: 12px 10px; flex: 1; }
.nav-section-label {
  color: #475569;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .87rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: #cbd5e1; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #1e293b;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name  { color: #e2e8f0; font-size: .83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { color: var(--sidebar-text); font-size: .72rem; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 50;
  gap: 16px;
}
.topbar-left  { display: flex; align-items: center; gap: 12px; flex: 1; }
.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--text-primary); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.topbar-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: .83rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.topbar-btn-ghost { color: var(--text-secondary); background: transparent; }
.topbar-btn-ghost:hover { background: var(--bg-body); color: var(--text-primary); }

/* ── Page Content ───────────────────────────────────────────── */
.page-content { padding: 28px; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.page-subtitle { color: var(--text-muted); font-size: .85rem; margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body  { padding: 20px; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: flex-start; gap: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.yellow { background: var(--warning-light); }
.stat-icon.red    { background: var(--danger-light); }
.stat-body {}
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .82rem; color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { background: var(--bg-body); color: var(--text-primary); }
.btn-ghost     { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-body); }
.btn-sm   { padding: 6px 12px; font-size: .8rem; }
.btn-lg   { padding: 12px 24px; font-size: .95rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-ai   { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border: none; }
.btn-ai:hover { background: linear-gradient(135deg, #4f46e5, #7c3aed); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .83rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  transition: var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th {
  background: var(--bg-body);
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tr:hover td { background: var(--bg-card-hover); }
.table tr:last-child td { border-bottom: none; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-danger   { background: var(--danger-light); color: var(--danger); }
.badge-info     { background: var(--info-light); color: var(--info); }
.badge-default  { background: var(--bg-body); color: var(--text-muted); }
.badge-primary  { background: var(--primary-light); color: var(--primary); }
.badge-ai       { background: #ede9fe; color: #6d28d9; }

/* ── Flash Messages ─────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: .87rem;
  font-weight: 500;
  animation: fadeIn .3s ease;
}
.flash-success { background: var(--success-light); color: var(--success); border-left: 3px solid var(--success); }
.flash-error   { background: var(--danger-light); color: var(--danger); border-left: 3px solid var(--danger); }
.flash-info    { background: var(--info-light); color: var(--info); border-left: 3px solid var(--info); }
.flash-close   { margin-left: auto; cursor: pointer; opacity: .6; font-size: 1rem; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs { border-bottom: 1px solid var(--border); margin-bottom: 24px; display: flex; gap: 2px; }
.tab-btn {
  padding: 10px 18px;
  font-size: .87rem;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); border-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 20px; }
.page-link {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .83rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}
.page-link:hover { background: var(--bg-body); }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Dropdown ───────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 1000;
  display: none;
  overflow: hidden;
}
.dropdown:hover .dropdown-menu,
.dropdown.open .dropdown-menu { display: block; animation: fadeIn .15s ease; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-size: .85rem;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}
.dropdown-item:hover { background: var(--bg-body); color: var(--text-primary); }
.dropdown-item.danger:hover { background: var(--danger-light); color: var(--danger); }

/* ── Color Picker ───────────────────────────────────────────── */
.color-input-wrap { display: flex; align-items: center; gap: 10px; }
input[type="color"] { width: 44px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; cursor: pointer; }
.color-hex { font-size: .85rem; font-weight: 600; color: var(--text-secondary); }

/* ── Tooltip ────────────────────────────────────────────────── */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: .76rem;
  padding: 5px 10px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
}

/* ── Utilities ──────────────────────────────────────────────── */
.flex         { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: .82rem; }
.text-xs      { font-size: .75rem; }
.font-bold    { font-weight: 700; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full       { width: 100%; }
.hidden       { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin    { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
}
