/* ============================================
   DevPolok Portfolio CMS - Admin Styles
   ============================================ */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --accent: #f59e0b;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --radius: 10px;
  --radius-lg: 16px;
  --transition: all 0.25s ease;
  --sidebar-width: 260px;
}

[data-theme="dark"] {
  --bg: #0a0a0f;
  --bg-secondary: #0f0f18;
  --bg-card: #13131e;
  --bg-card-hover: #1a1a28;
  --border: rgba(255,255,255,0.07);
  --text: #e8e8f0;
  --text-muted: #7b7b95;
  --text-secondary: #b0b0c8;
  --sidebar-bg: #0d0d18;
  --topbar-bg: rgba(13, 13, 24, 0.9);
  --shadow: rgba(0,0,0,0.5);
  --input-bg: #0f0f18;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); line-height: 1.6; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { max-width: 100%; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.4); border-radius: 3px; }

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

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-text { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; }
.sidebar-logo .accent { color: var(--primary); }
.sidebar-logo span.sub { font-size: 0.72rem; color: var(--text-muted); display: block; font-weight: 500; letter-spacing: 1px; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-section-label {
  font-size: 0.68rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.75rem 1.5rem 0.3rem;
  font-weight: 600;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition);
  position: relative;
}
.sidebar-link i { width: 18px; text-align: center; font-size: 0.95rem; }
.sidebar-link:hover { color: var(--text); background: rgba(99,102,241,0.08); }
.sidebar-link.active {
  color: white;
  background: rgba(99,102,241,0.15);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}
.sidebar-link .badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
.sidebar-footer .view-site {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color 0.2s;
}
.sidebar-footer .view-site:hover { color: var(--primary); }
.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 0.75rem;
  padding: 0.5rem 0;
  transition: opacity 0.2s;
}
.logout-btn:hover { opacity: 0.8; }

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

/* TOP BAR */
.topbar {
  position: sticky;
  top: 0;
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
}
.topbar-left h1 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }
.topbar-left p { font-size: 0.8rem; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.admin-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
}
.topbar-username { font-size: 0.85rem; font-weight: 600; }

/* PAGE CONTENT */
.page-content { padding: 2rem; flex: 1; }

/* ===== CARDS & GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}
.stat-card:hover { border-color: rgba(99,102,241,0.3); transform: translateY(-2px); }
.stat-icon {
  width: 50px; height: 50px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}
.stat-icon.purple { background: rgba(99,102,241,0.15); color: var(--primary); }
.stat-icon.amber { background: rgba(245,158,11,0.15); color: var(--accent); }
.stat-icon.green { background: rgba(34,197,94,0.15); color: var(--success); }
.stat-icon.red { background: rgba(239,68,68,0.15); color: var(--danger); }
.stat-icon.cyan { background: rgba(6,182,212,0.15); color: var(--info); }
.stat-num-lg { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label-sm { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; }
.card-body { padding: 1.5rem; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.form-label i { margin-right: 0.3rem; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-select option { background: var(--bg-card); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }

/* Image preview */
.img-preview-wrap { margin-top: 0.75rem; }
.img-preview {
  width: 100px; height: 100px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  display: none;
}
.img-preview.show { display: block; }
.img-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.img-upload-area:hover { border-color: var(--primary); }
.img-upload-area i { font-size: 2rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.img-upload-area p { color: var(--text-muted); font-size: 0.85rem; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.65rem 1.25rem; border-radius: var(--radius); font-size: 0.88rem; font-weight: 600; transition: var(--transition); cursor: pointer; border: 1px solid transparent; font-family: var(--font-body); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--bg-card-hover); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 8px; }
.w-full { width: 100%; justify-content: center; }
.mt-4 { margin-top: 1rem; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { border-bottom: 1px solid var(--border); }
thead th { padding: 0.85rem 1rem; text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:hover { background: var(--bg-card-hover); }
tbody td { padding: 0.85rem 1rem; font-size: 0.88rem; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }
.td-actions { display: flex; gap: 0.4rem; }
.table-img { width: 48px; height: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.table-placeholder { width: 48px; height: 36px; background: rgba(99,102,241,0.1); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }

/* ===== BADGES ===== */
.badge-active { display: inline-block; background: rgba(34,197,94,0.1); color: var(--success); border: 1px solid rgba(34,197,94,0.3); padding: 2px 8px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-inactive { display: inline-block; background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); padding: 2px 8px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-tag { display: inline-block; background: rgba(99,102,241,0.1); color: var(--primary); border: 1px solid rgba(99,102,241,0.2); padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; margin: 1px; }

/* ===== ALERTS ===== */
.alert { padding: 0.85rem 1.25rem; border-radius: var(--radius); font-size: 0.88rem; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.5rem; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: var(--success); }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--danger); }
.alert-info { background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.2); color: var(--primary); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.25s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; }
.modal-close { color: var(--text-muted); font-size: 1.2rem; transition: color 0.2s; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* ===== SETTINGS TABS ===== */
.settings-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 2rem; overflow-x: auto; }
.settings-tab {
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: var(--transition);
  margin-bottom: -1px;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* ===== TOGGLE SWITCH ===== */
.toggle-switch { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider { width: 42px; height: 22px; background: var(--border); border-radius: 11px; position: relative; transition: background 0.25s; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; background: white; border-radius: 50%; top: 3px; left: 3px; transition: transform 0.25s; }
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-label { font-size: 0.85rem; font-weight: 500; }

/* ===== MESSAGES ===== */
.message-row.unread { background: rgba(99,102,241,0.05); }
.message-row.unread td:first-child { border-left: 3px solid var(--primary); }
.unread-dot { width: 8px; height: 8px; background: var(--primary); border-radius: 50%; display: inline-block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-content { padding: 1rem; }
}

/* ===== MISC UTILITIES ===== */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.color-swatch { width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--border); display: inline-block; }
