/* ==========================================
   PikZo Admin Panel — Design System
   Clean White + Blue-Purple (matching app)
   ========================================== */

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

:root {
  --primary: #5B5FEF;
  --primary-light: #7B7FF5;
  --primary-dark: #4347D3;
  --secondary: #8B5CF6;
  --accent: #06B6D4;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --bg-base: #F3F4F6;
  --bg-surface: #FFFFFF;
  --bg-muted: #F9FAFB;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.10);
  --shadow-primary: 0 8px 24px rgba(91,95,239,0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --sidebar-w: 260px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---- LAYOUT ---- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
  box-shadow: var(--shadow-sm);
}
.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: var(--shadow-primary);
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: 18px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.sidebar-logo .logo-sub {
  font-size: 11px; color: var(--text-muted); font-weight: 500;
  -webkit-text-fill-color: var(--text-muted);
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 8px 8px 4px;
  margin-top: 8px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.18s;
  margin-bottom: 2px;
  cursor: pointer;
}
.nav-link:hover { background: var(--bg-muted); color: var(--text-primary); }
.nav-link.active {
  background: linear-gradient(135deg, rgba(91,95,239,0.12), rgba(139,92,246,0.08));
  color: var(--primary);
  font-weight: 600;
}
.nav-link .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-link .nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--primary); color: #fff;
  padding: 2px 8px; border-radius: 30px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ---- MAIN AREA ---- */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- TOPBAR ---- */
.admin-topbar {
  background: rgba(255,255,255,0.90);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0; z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.topbar-btn {
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
  transition: all 0.18s;
}
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); background: rgba(91,95,239,0.06); }
.topbar-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; border-color: transparent;
  box-shadow: var(--shadow-primary);
}
.topbar-btn.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(91,95,239,0.35); }
.topbar-btn.danger { background: var(--danger); color: #fff; border-color: transparent; }

/* ---- CONTENT ---- */
.admin-content { padding: 24px; flex: 1; }

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
}
.stat-value { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-card .stat-glow {
  position: absolute;
  top: -20px; right: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  opacity: 0.08;
}
.stat-blue .stat-icon { background: rgba(91,95,239,0.12); color: var(--primary); }
.stat-blue .stat-glow { background: var(--primary); }
.stat-purple .stat-icon { background: rgba(139,92,246,0.12); color: var(--secondary); }
.stat-purple .stat-glow { background: var(--secondary); }
.stat-green .stat-icon { background: rgba(16,185,129,0.12); color: var(--success); }
.stat-green .stat-glow { background: var(--success); }
.stat-orange .stat-icon { background: rgba(245,158,11,0.12); color: var(--warning); }
.stat-orange .stat-glow { background: var(--warning); }

/* ---- PANEL ---- */
.panel {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.panel-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 0; }

/* ---- TABLE ---- */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  background: var(--bg-muted);
  padding: 11px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr { transition: background 0.15s; }
.admin-table tbody tr:hover { background: var(--bg-muted); }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 30px;
  font-size: 11px; font-weight: 700;
}
.badge-green { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-red   { background: rgba(239,68,68,0.12);  color: var(--danger); }
.badge-blue  { background: rgba(91,95,239,0.12);  color: var(--primary); }
.badge-yellow{ background: rgba(245,158,11,0.12); color: var(--warning); }

/* ---- ACTION BUTTONS ---- */
.action-btns { display: flex; gap: 6px; }
.btn-sm {
  height: 30px; padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  transition: all 0.18s;
}
.btn-edit  { background: rgba(91,95,239,0.10); color: var(--primary); border: 1px solid rgba(91,95,239,0.20); }
.btn-edit:hover { background: var(--primary); color: #fff; }
.btn-del   { background: rgba(239,68,68,0.10); color: var(--danger); border: 1px solid rgba(239,68,68,0.20); }
.btn-del:hover { background: var(--danger); color: #fff; }
.btn-toggle { background: rgba(16,185,129,0.10); color: var(--success); border: 1px solid rgba(16,185,129,0.20); }
.btn-toggle:hover { background: var(--success); color: #fff; }

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.form-control {
  height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  transition: all 0.2s;
  width: 100%;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,95,239,0.12); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-control.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff;
  border-radius: var(--radius-xl);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-muted);
  transition: all 0.18s;
}
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ---- BUTTONS (Full) ---- */
.btn {
  height: 42px; padding: 0 20px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.18s;
  cursor: pointer; border: none;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; box-shadow: var(--shadow-primary); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(91,95,239,0.35); }
.btn-secondary { background: var(--bg-muted); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

/* ---- TOAST ---- */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  width: 320px;
}
.toast {
  background: #fff; border-radius: var(--radius-md);
  padding: 14px 16px; border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 12px;
  transform: translateX(30px); opacity: 0;
  transition: all 0.3s cubic-bezier(0.32,0.72,0,1);
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.leaving { transform: translateX(30px); opacity: 0; }
.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-size: 14px; font-weight: 700; }
.toast-msg { font-size: 12px; color: var(--text-muted); }
.toast-close-btn { font-size: 16px; color: var(--text-muted); flex-shrink: 0; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; color: var(--border); }
.empty-state .empty-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .l-icon {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #fff;
  margin: 0 auto 12px;
  box-shadow: var(--shadow-primary);
}
.login-logo h1 { font-size: 24px; font-weight: 900; }
.login-logo .l-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.input-icon-wrap { position: relative; }
.input-icon-wrap .i-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 16px; pointer-events: none;
}
.input-icon-wrap .form-control { padding-left: 38px; }
.login-btn {
  width: 100%; height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; font-size: 15px; font-weight: 700;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s;
  box-shadow: var(--shadow-primary);
  margin-top: 20px;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(91,95,239,0.4); }
.error-msg {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}

/* ---- ICON PREVIEW ---- */
.icon-preview { font-size: 22px; color: var(--primary); }
.color-swatch {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: inline-block;
  vertical-align: middle;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); --sidebar-w: 260px; }
  .admin-main { margin-left: 0; }
  .mobile-menu-btn { display: flex !important; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-content { padding: 16px; }
}
.mobile-menu-btn { display: none; }

/* ---- DRAG INDICATOR ---- */
.drag-handle { cursor: grab; color: var(--text-muted); padding: 0 6px; }
.drag-handle:active { cursor: grabbing; }

/* ---- URL truncation ---- */
.url-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; font-size: 12px; color: var(--text-muted); }
