/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-bg: #f9fafb;
  --color-sidebar: #1e1b4b;
  --color-sidebar-text: #e0e7ff;
  --color-sidebar-active: #818cf8;
  --color-white: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-success: #059669;
  --color-danger: #dc2626;
  --color-warning: #d97706;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

body.admin-body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
}

.admin-sidebar__brand {
  padding: 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.admin-sidebar__brand a { color: var(--color-white); }
.admin-sidebar__brand a:hover { text-decoration: none; }

.admin-sidebar__nav {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

.admin-nav-link {
  display: block;
  padding: 10px 20px;
  color: var(--color-sidebar-text);
  font-size: 14px;
  transition: background .15s;
}
.admin-nav-link:hover {
  background: rgba(255,255,255,.08);
  text-decoration: none;
}
.admin-nav-link--active {
  background: rgba(255,255,255,.12);
  color: var(--color-sidebar-active);
  font-weight: 600;
}

.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  height: var(--topbar-height);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.admin-topbar__title {
  font-size: 16px;
  font-weight: 600;
}

.admin-topbar__user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-muted);
}

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

/* ===== Login ===== */
.admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.admin-login__card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.admin-login__card h1 {
  font-size: 24px;
  margin-bottom: 24px;
  text-align: center;
}

/* ===== Flash ===== */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.flash--notice { background: #ecfdf5; color: var(--color-success); border: 1px solid #a7f3d0; }
.flash--alert  { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }

/* ===== Forms ===== */
.admin-form { display: flex; flex-direction: column; gap: 16px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.form-control {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--color-primary); }

select.form-control { appearance: auto; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-check input[type="checkbox"] { width: 16px; height: 16px; }

.form-inline {
  display: flex;
  gap: 8px;
  align-items: end;
}

.field-errors {
  color: var(--color-danger);
  font-size: 12px;
  margin-top: 2px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn--primary { background: var(--color-primary); color: var(--color-white); }
.btn--primary:hover { background: var(--color-primary-hover); }

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

.btn--danger { background: var(--color-danger); color: var(--color-white); }
.btn--danger:hover { background: #b91c1c; }

.btn--success { background: var(--color-success); color: var(--color-white); }
.btn--success:hover { background: #047857; }

.btn--small { padding: 4px 10px; font-size: 12px; }

.btn--full { width: 100%; }

.btn-group { display: flex; gap: 8px; }

/* ===== Cards & Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.stat-card__label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.stat-card__value {
  font-size: 28px;
  font-weight: 700;
}

/* ===== Tables ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.admin-table th {
  background: var(--color-bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8fafc; }

/* ===== Page header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 20px; font-weight: 600; }

/* ===== Detail ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}
.detail-grid dt {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.detail-grid dd { font-size: 14px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  text-transform: uppercase;
}
.badge--admin { background: #ede9fe; color: #5b21b6; }
.badge--member { background: #e0f2fe; color: #0369a1; }
.badge--active { background: #ecfdf5; color: var(--color-success); }
.badge--inactive { background: #fef2f2; color: var(--color-danger); }

/* ===== Nested choices ===== */
.choices-list { display: flex; flex-direction: column; gap: 12px; }

.choice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-bg);
  border-radius: var(--radius);
}
.choice-row .form-control { flex: 1; }

/* ===== Search ===== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-bar .form-control { flex: 1; }

/* ===== Section ===== */
.section {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}
.section__title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

/* ===== Weekly Activity ===== */
.weekly-activity {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}
.weekly-activity__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.weekly-activity__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.weekly-activity__dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.weekly-activity__dot--active { background: var(--color-success); }
.weekly-activity__dot--inactive { background: var(--color-border); }
.weekly-activity__count {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  justify-content: center;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}
.pagination .current {
  background: var(--color-primary);
  color: var(--color-white);
}
