/* ===== Admin Panel Styles — PFMECT ===== */
:root {
  --primary: #0d3b66;
  --primary-2: #1d5f96;
  --accent: #f4a261;
  --accent-2: #ffd6a5;
  --bg: #f0f4f8;
  --text: #1f2937;
  --muted: #5b6472;
  --card: #ffffff;
  --border: #e2e8f0;
  --success: #2a9d8f;
  --danger: #c44536;
  --warning: #e9c46a;
  --purple: #7c3aed;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 24px rgba(13,59,102,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 260px;
  --header-h: 64px;
  --transition: .2s ease;
}

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

html, body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input { font: inherit; }

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
}

.login-wrapper { width: 100%; max-width: 420px; padding: 1.5rem; }

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
}

.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand img { width: 72px; height: 72px; object-fit: contain; margin: 0 auto 1rem; }
.login-brand h1 { font-size: 1.5rem; color: var(--primary); margin-bottom: .25rem; }
.login-subtitle { font-size: .85rem; color: var(--muted); }

.login-form .form-group { margin-bottom: 1.25rem; }
.login-form label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--text);
}

.login-form input[type="text"],
.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  padding: .7rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  transition: border-color var(--transition);
  outline: none;
}

.login-form input:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(29,95,150,.12);
}

.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 2.8rem; }
.password-toggle {
  position: absolute;
  right: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  padding: .2rem;
}

.form-error {
  background: #fef2f2;
  color: var(--danger);
  font-size: .85rem;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: .85rem;
  color: var(--muted);
}
.login-footer a:hover { color: var(--primary-2); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .65rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  transition: all var(--transition);
  border: 1.5px solid transparent;
}

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

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); border-color: var(--primary-2); }

.btn-block { width: 100%; }
.btn-sm { padding: .45rem 1rem; font-size: .82rem; }

/* ===== Admin Layout ===== */
.admin-body { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--primary);
  color: #e8f3ff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition), width .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand img { width: 36px; height: 36px; object-fit: contain; }
.sidebar-brand span { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; }
.sidebar-nav .nav-list { list-style: none; }

.sidebar-nav .nav-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 1.5rem .25rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  margin-top: .4rem;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
.sidebar-nav .nav-group-label:hover { color: rgba(255,255,255,.6); }
.sidebar-nav .nav-group-label .chevron {
  width: 14px;
  height: 14px;
  transition: transform .2s ease;
  opacity: .5;
}
.sidebar-nav .nav-group-label.collapsed .chevron {
  transform: rotate(-90deg);
}

.nav-group-items {
  overflow: hidden;
  max-height: 500px;
  transition: max-height .25s ease;
}
.nav-group-items.collapsed {
  max-height: 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.5rem;
  font-size: .9rem;
  color: rgba(255,255,255,.7);
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-left-color: var(--accent);
}
.sidebar-nav a svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.1);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: rgba(255,255,255,.7);
  font-size: .88rem;
  padding: .5rem 0;
  transition: color var(--transition);
}
.btn-logout:hover { color: #fff; }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  transition: margin-left .25s ease;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.sidebar-toggle { display: none; color: var(--text); }

.page-title { font-size: 1.2rem; font-weight: 700; flex: 1; }

.header-actions { display: flex; align-items: center; gap: 1rem; }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
}

/* Dashboard */
.dashboard-content { padding: 1.5rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon--blue  { background: #e0edff; color: var(--primary-2); }
.stat-icon--green { background: #d1fae5; color: var(--success); }
.stat-icon--orange{ background: #fff0db; color: #d97706; }
.stat-icon--purple{ background: #ede9fe; color: var(--purple); }

.stat-value { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.stat-label { display: block; font-size: .82rem; color: var(--muted); margin-top: .15rem; }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.action-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  transition: all var(--transition);
  border: 1px solid var(--border);
}
.action-btn:hover {
  border-color: var(--primary-2);
  color: var(--primary);
  background: #e8f0fe;
}

/* Activity list */
.activity-list { list-style: none; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: .35rem;
  flex-shrink: 0;
}
.activity-dot--green  { background: var(--success); }
.activity-dot--blue   { background: var(--primary-2); }
.activity-dot--orange { background: var(--accent); }
.activity-dot--purple { background: var(--purple); }

.activity-content p { font-size: .88rem; margin-bottom: .15rem; }
.activity-content time { font-size: .78rem; color: var(--muted); }

/* Data table */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.data-table th {
  text-align: left;
  padding: .65rem .75rem;
  font-weight: 600;
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge--live  { background: #d1fae5; color: #065f46; }
.badge--draft { background: #fef3c7; color: #92400e; }

/* ===== Sidebar Collapsed (desktop) ===== */
.sidebar.collapsed {
  width: 64px;
}
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-nav .nav-group-label,
.sidebar.collapsed .sidebar-nav .link-text,
.sidebar.collapsed .sidebar-footer .btn-logout span {
  display: none;
}
.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 1.25rem .5rem;
}
.sidebar.collapsed .sidebar-nav a {
  justify-content: center;
  padding: .7rem;
}
.sidebar.collapsed .sidebar-nav a svg {
  margin: 0;
}
.sidebar.collapsed .nav-group-items {
  max-height: 500px !important;
}
.sidebar.collapsed .sidebar-footer {
  padding: 1rem .5rem;
  text-align: center;
}
.sidebar.collapsed .btn-logout {
  justify-content: center;
}
.sidebar.collapsed ~ .main-content {
  margin-left: 64px;
}

/* Collapse toggle button */
.sidebar-collapse-btn {
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-2);
  border: 2px solid var(--bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
  transition: transform .2s ease, background .2s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.sidebar-collapse-btn:hover { background: var(--accent); }
.sidebar-collapse-btn svg { width: 14px; height: 14px; transition: transform .2s ease; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open .sidebar-brand span,
  .sidebar.open .sidebar-nav .nav-group-label,
  .sidebar.open .sidebar-nav .link-text,
  .sidebar.open .sidebar-footer .btn-logout span { display: revert; }
  .sidebar.open .sidebar-nav a { justify-content: flex-start; padding: .7rem 1.5rem; }
  .sidebar.open .sidebar-brand { justify-content: flex-start; padding: 1.25rem 1.5rem; }
  .sidebar-collapse-btn { display: none; }

  .sidebar-toggle { display: block; }

  .main-content { margin-left: 0 !important; }

  .stat-grid { grid-template-columns: 1fr 1fr; }

  .quick-actions { grid-template-columns: 1fr; }

  .admin-header { padding: 0 1rem; }
  .dashboard-content { padding: 1rem; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }

  .login-card { padding: 2rem 1.5rem; }
}

/* ===== Modal System ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal--lg { max-width: 800px; }
.modal--sm { max-width: 520px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  padding: .25rem .5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--danger); }

.modal-body { padding: 1.5rem; }

.modal-body .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .modal-body .form-row { grid-template-columns: 1fr; }
}

.modal-body .form-group { margin-bottom: 1rem; }
.modal-body .form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.modal-body .form-group input,
.modal-body .form-group textarea,
.modal-body .form-group select {
  width: 100%;
  padding: .6rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.modal-body .form-group input:focus,
.modal-body .form-group textarea:focus,
.modal-body .form-group select:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(29,95,150,.12);
}
.modal-body .form-group textarea { resize: vertical; min-height: 60px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ===== Rich Text Editor ===== */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .5rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  flex-wrap: wrap;
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: .85rem;
  color: var(--text);
  transition: all var(--transition);
}
.toolbar-btn:hover { background: var(--border); }

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 .25rem;
}

.rich-editor {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  padding: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: .9rem;
  line-height: 1.7;
  outline: none;
}
.rich-editor:focus { border-color: var(--primary-2); }
.rich-editor:empty::before {
  content: attr(placeholder);
  color: var(--muted);
  pointer-events: none;
}
.rich-editor img { max-width: 100%; border-radius: 8px; margin: .5rem 0; }

/* ===== Delete / Danger outline button ===== */
.btn-danger-outline { border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: #fef2f2; }

/* ===== Actions cell ===== */
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-right: .25rem; }

/* ===== Upload Progress ===== */
.upload-progress { margin-top: 1rem; }
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary-2);
  border-radius: 999px;
  transition: width .3s ease;
}
.progress-text {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  margin-top: .35rem;
  text-align: center;
}

/* ===== Upload zone drag state ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--muted);
  margin-bottom: 1.5rem;
  transition: all var(--transition);
  cursor: pointer;
}
.upload-zone:hover { border-color: var(--primary-2); background: #f0f6ff; }
.upload-zone svg { margin: 0 auto 1rem; display: block; }
.upload-zone.drag-over { border-color: var(--primary-2); background: #e8f0fe; }

/* ===== Media Grid ===== */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.media-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem;
  text-align: center;
}
.media-item img { border-radius: 6px; width: 100%; height: 120px; object-fit: cover; margin-bottom: .5rem; }
.media-item span { font-size: .78rem; color: var(--muted); word-break: break-all; display: block; margin-bottom: .5rem; }
.media-item .media-actions { display: flex; gap: .35rem; justify-content: center; }
.media-item .media-actions .btn { font-size: .72rem; padding: .3rem .6rem; }
.media-file-icon { height: 120px; display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all .3s ease;
  z-index: 300;
}
.toast.show { transform: translateY(0); opacity: 1; }
