/* assets/css/admin.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1D9E75;
  --primary-dk: #157a5c;
  --ink:        #0d2b38;
  --muted:      #526672;
  --line:       #e4eaed;
  --bg:         #f4f7f9;
  --white:      #ffffff;
  --sidebar-w:  240px;
  --danger:     #dc3545;
  --warning:    #f59e0b;
  --success:    #1D9E75;
  --purple:     #534AB7;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(13,43,56,0.08);
}

body {
  font-family: 'Manrope', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
}

/* ─── Layout ─── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px;
  max-width: 100%;
  overflow-x: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 6px;
  background: white;
  padding: 2px;
}

.brand-text {
  color: white;
  font-weight: 700;
  font-size: 1rem;
}

.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

/* ── Collapsed sidebar (desktop) ── */
.sidebar.collapsed {
  width: 60px;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .admin-info div,
.sidebar.collapsed .logout-btn,
.sidebar.collapsed .badge {
  display: none;
}
.sidebar.collapsed .brand-logo-img {
  margin: 0 auto;
}
.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 20px 8px;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}
.sidebar.collapsed .nav-icon {
  width: auto;
}
.sidebar.collapsed .sidebar-footer {
  padding: 12px 8px;
}
.sidebar.collapsed .admin-info {
  justify-content: center;
}
.sidebar.collapsed .admin-avatar {
  margin: 0;
}

/* Shift main content when sidebar collapses */
.main-content {
  transition: margin-left 0.25s ease;
}
body.sidebar-collapsed .main-content {
  margin-left: 60px;
}

/* ── Mobile overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
  backdrop-filter: blur(1px);
}
.sidebar-overlay.active {
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.18s;
  position: relative;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: var(--primary); color: white; }

.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-label { flex: 1; }

.nav-item .badge {
  background: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

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

.admin-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0;
}

.admin-name { color: white; font-weight: 600; font-size: 0.82rem; }
.admin-role { color: rgba(255,255,255,0.45); font-size: 0.72rem; }

.logout-btn {
  display: block;
  text-align: center;
  padding: 8px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.6);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.82rem;
  transition: all 0.18s;
}
.logout-btn:hover { background: rgba(220,53,69,0.3); color: #ff8a90; }

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 { font-size: 1.5rem; font-weight: 800; }
.page-subtitle { color: var(--muted); font-size: 0.83rem; margin-top: 3px; }
.header-date { color: var(--muted); font-size: 0.82rem; }

/* ─── Stats ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}

.stat-blue   { border-color: #3b82f6; }
.stat-yellow { border-color: var(--warning); }
.stat-green  { border-color: var(--primary); }
.stat-purple { border-color: var(--purple); }

.stat-icon {
  font-size: 1.8rem;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: 10px;
  flex-shrink: 0;
}

.stat-number { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat-label  { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.stat-sub    { font-size: 0.72rem; color: var(--warning); font-weight: 600; margin-top: 2px; }

/* ─── Dashboard Grid ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card-full { grid-column: 1 / -1; }

/* ─── Card ─── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.card-header h3 { font-size: 0.92rem; font-weight: 700; }
.card-link { font-size: 0.78rem; color: var(--primary); text-decoration: none; font-weight: 600; }
.card-body { padding: 16px 18px; }
.card-body.p0 { padding: 0; }

/* ─── Course Bars ─── */
.course-bar-item { margin-bottom: 14px; }
.course-bar-label {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; margin-bottom: 5px;
  color: var(--muted);
}
.course-bar-label strong { color: var(--ink); }

.progress-bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.6s ease; }

/* ─── Table ─── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table-compact th,
.table-compact td {
  white-space: nowrap;
}

.table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: #fafcfd; }
.row-unread { background: #fffbf0 !important; }

.cell-name { font-weight: 600; }
.cell-sub  { color: var(--muted); font-size: 0.76rem; }

.id-cell { color: var(--muted); font-size: 0.78rem; }
.address-cell { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.date-cell { white-space: nowrap; color: var(--muted); }
.msg-preview { max-width: 300px; color: var(--muted); }

.empty-state { text-align: center; color: var(--muted); padding: 30px !important; }

/* ─── Status Badges ─── */
.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-reviewed { background: #dbeafe; color: #1e40af; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* ─── Course Tag ─── */
.course-tag {
  background: #e4f2f0;
  color: var(--primary-dk);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ─── Actions ─── */
.actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.btn-action {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.btn-view   { background: #dbeafe; color: #1e40af; }
.btn-view:hover { background: #bfdbfe; }
.btn-delete { background: #fee2e2; color: #991b1b; }
.btn-delete:hover { background: #fecaca; }

.inline-select {
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: inherit;
  background: white;
  cursor: pointer;
}

/* ─── Filters ─── */
.filter-card { margin-bottom: 16px; }
.filter-form {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  flex-wrap: wrap;
}

.filter-input, .filter-select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.83rem;
  color: var(--ink);
  background: white;
  outline: none;
  transition: border-color 0.15s;
}

.filter-input { flex: 1; min-width: 200px; }
.filter-input:focus, .filter-select:focus { border-color: var(--primary); }

/* ─── Buttons ─── */
.btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-outline { background: white; color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; justify-content: center; padding: 12px; }

/* ─── Alerts ─── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  font-weight: 500;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ─── Messages List ─── */
.messages-list { display: flex; flex-direction: column; gap: 12px; }

.message-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-left: 4px solid var(--line);
}

.message-unread { border-left-color: var(--primary); }

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}

.message-sender {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sender-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0;
}

.sender-name { font-weight: 700; font-size: 0.88rem; }
.sender-email { color: var(--muted); font-size: 0.76rem; }

.unread-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.message-date { color: var(--muted); font-size: 0.76rem; }

.message-actions { display: flex; gap: 6px; }
.message-body { padding: 14px 18px; color: var(--ink); line-height: 1.65; }

/* ─── Export ─── */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 700px;
}

.export-card { text-align: center; padding: 32px 24px !important; }
.export-card .card-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.export-icon { font-size: 2.5rem; }
.export-card h3 { font-size: 1.1rem; }
.export-card p { color: var(--muted); font-size: 0.83rem; }
.export-desc { max-width: 260px; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13,43,56,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.modal-box {
  background: white;
  border-radius: var(--radius);
  width: 540px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(13,43,56,0.2);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1.4rem; cursor: pointer;
  color: var(--muted); line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-full { grid-column: 1 / -1; }

.detail-item label {
  display: block; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; color: var(--muted); letter-spacing: 0.3px; margin-bottom: 4px;
}
.detail-item span { font-size: 0.88rem; color: var(--ink); }

/* ─── Login Page ─── */
.login-page { background: var(--ink); display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-wrapper { width: 100%; max-width: 400px; padding: 20px; }

.login-card {
  background: white;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo { text-align: center; margin-bottom: 28px; }

.logo-img {
  width: 120px;
  height: 80px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 12px;
}

.login-logo h1 { font-size: 1.3rem; font-weight: 800; }
.login-logo p  { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; }

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--primary); }

.login-hint { text-align: center; margin-top: 14px; color: var(--muted); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .export-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  /* Sidebar hidden off-screen by default on mobile */
  .sidebar {
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.25s ease, width 0.25s ease;
  }
  /* Slide in when open */
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  /* Main content takes full width on mobile */
  .main-content {
    margin-left: 0 !important;
    padding: 16px;
  }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-form { flex-direction: column; }
  .filter-input { min-width: 100%; }
}
