/* ═════════════════════════════════════════════════════════════
   Groups Dashboard — Stylesheet
═════════════════════════════════════════════════════════════ */

:root {
  --blue:       #1a3c5e;
  --blue-mid:   #2563a8;
  --blue-light: #e8f0fb;
  --accent:     #f0a500;
  --green:      #16a34a;
  --red:        #dc2626;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;
  --bg:         #f5f7fb;
  --card:       #ffffff;
  --radius:     12px;
  --shadow:     0 2px 16px rgba(26,60,94,.07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--blue-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--blue); }
.muted { color: var(--muted); }
code { background: #eef2f7; padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* ─── Auth page ──────────────────────────────────────────── */
body.auth {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a3c5e 0%, #2563a8 100%);
  padding: 24px;
}
.auth-card {
  background: #fff; padding: 36px;
  border-radius: 16px; max-width: 420px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head h1 { margin: 12px 0 4px; font-size: 22px; }
.auth-head p { color: var(--muted); margin: 0; font-size: 14px; }
.brand-icon.big { font-size: 48px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ─── App shell ──────────────────────────────────────────── */
body.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  overflow-x: hidden;
  transition: grid-template-columns .25s ease;
}
body.app.sidebar-collapsed { grid-template-columns: 68px minmax(0, 1fr); }
.sidebar {
  background: var(--blue);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 24px 0;
  position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  transition: width .25s ease, transform .25s ease;
}

/* Sidebar toggle button */
.sidebar-toggle {
  position: fixed;
  top: 14px; left: 14px;
  z-index: 100;
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: none; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--blue);
  transition: background .15s;
}
.sidebar-toggle:hover { background: var(--blue-light); }
.sidebar-toggle.is-visible { display: inline-flex; }

/* Backdrop is hidden on desktop; only the mobile drawer activates it. */
.sidebar-backdrop { display: none; }

/* Collapsed state — hide labels, keep icons */
body.app.sidebar-collapsed .brand-title,
body.app.sidebar-collapsed .brand-sub,
body.app.sidebar-collapsed .nav-section,
body.app.sidebar-collapsed .nav-item span:not(.nav-ico),
body.app.sidebar-collapsed .user-info,
body.app.sidebar-collapsed .logout-btn {
  display: none;
}
body.app.sidebar-collapsed .brand { justify-content: center; padding: 0 10px 24px; }
body.app.sidebar-collapsed .nav { padding: 0 8px; }
body.app.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 6px; }
body.app.sidebar-collapsed .user-card { justify-content: center; padding: 10px 0; }
body.app.sidebar-collapsed .sidebar-foot { padding: 10px 8px 0; }
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px 24px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 16px;
}
.brand-icon { font-size: 28px; }
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.brand-sub { font-size: 11px; opacity: .65; text-transform: uppercase; letter-spacing: .8px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 8px;
  color: rgba(255,255,255,.78);
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.is-active { background: rgba(255,255,255,.14); color: #fff; }
.nav-ico { width: 20px; text-align: center; font-size: 16px; }
.nav-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  opacity: .45; margin: 16px 14px 6px;
}

.sidebar-foot {
  padding: 16px 16px 0;
  border-top: 1px solid rgba(255,255,255,.1);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; margin-bottom: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 11px; opacity: .65; text-transform: uppercase; letter-spacing: .5px; }
.logout-form { margin: 0; }
.logout-btn {
  width: 100%; background: rgba(255,255,255,.08); color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500;
  transition: background .15s;
}
.logout-btn:hover { background: rgba(255,255,255,.18); }

.main { padding: 32px 36px; width: 100%; max-width: none; min-width: 0; }
.main .card-body { overflow-x: auto; }
.form-grid > .field:last-child { justify-content: center !important; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.page-head p { margin: 0; }

/* ─── Flash ──────────────────────────────────────────────── */
.flash-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash {
  padding: 12px 16px; border-radius: 8px; font-size: 14px;
  border: 1px solid;
}
.flash-success { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.flash-error   { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.flash-info    { background: #d1ecf1; color: #0c5460; border-color: #bee5eb; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #fafbfd, #f3f6fa);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.grid-2 {
  display: grid; gap: 20px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

/* ─── Stat cards ─────────────────────────────────────────── */
.stat-grid {
  display: grid; gap: 16px; margin-bottom: 20px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat-card {
  --accent: var(--blue-mid);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); position: relative;
  border-left: 4px solid var(--accent);
}
.stat-ico { font-size: 22px; }
.stat-num { font-size: 28px; font-weight: 700; color: var(--blue); margin-top: 6px; }
.stat-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }

/* ─── Tables ─────────────────────────────────────────────── */
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th {
  background: #f1f5f9; padding: 10px 12px; text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.data tbody tr:hover { background: #f8faff; }
table.data tbody tr.row-present { background: #f0fdf4; }

table.detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.detail-table th {
  text-align: left; padding: 8px 12px 8px 0;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600; width: 160px;
  vertical-align: top;
}
table.detail-table td { padding: 8px 0; }

/* ─── Forms ──────────────────────────────────────────────── */
.input, .form-grid input, .form-grid select, .form-grid textarea,
.field input, .field select, .field textarea {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px; color: var(--text); background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-mid); box-shadow: 0 0 0 3px rgba(37,99,168,.12);
}
.inline-form {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field > span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.form-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.form-grid .field { display: flex; flex-direction: column; gap: 6px; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border: none; border-radius: 8px;
  background: #e2e8f0; color: var(--text);
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .15s;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-mid); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { background: #fee2e2; color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; line-height: 1.4;
  border: none; cursor: pointer; font-family: inherit;
}
.badge-yes { background: #d4edda; color: #155724; }
.badge-no  { background: #f8d7da; color: #721c24; }
.badge-status { background: #e8f4fd; color: #0c5460; }

/* ─── Charts / Bars ─────────────────────────────────────── */
.bar {
  width: 100%; height: 8px; background: #f1f5f9;
  border-radius: 4px; overflow: hidden; margin-bottom: 4px;
}
.bar span {
  display: block; height: 100%; background: var(--blue-mid);
  border-radius: 4px;
}

ol.rank { list-style: none; padding: 0; margin: 0; counter-reset: rank; }
ol.rank li {
  counter-increment: rank;
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #f1f5f9;
}
ol.rank li::before {
  content: counter(rank);
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue-light); color: var(--blue);
  font-weight: 700; font-size: 12px; margin-right: 10px;
}
.rank-name { flex: 1; font-weight: 500; }
.rank-val { color: var(--muted); font-size: 13px; }

/* ═════════════════════════════════════════════════════════════
   Attendance form (carried over from plugin)
═════════════════════════════════════════════════════════════ */
.g15-app { padding-top: 0; }
.g15-full { margin-bottom: 24px; }
.g15-bottom-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px; margin-bottom: 24px;
}
.g15-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; border: 1px solid var(--border);
}
.g15-card-header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px; background: var(--blue); color: #fff;
}
.g15-header-icon { font-size: 28px; }
.g15-card-header h2 { margin: 0; font-size: 18px; color: #fff; font-weight: 600; }
.g15-subtitle { margin: 2px 0 0; font-size: 13px; opacity: .7; font-weight: 300; }
.g15-stat-pill {
  margin-left: auto;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3);
  border-radius: 20px; padding: 6px 16px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.g15-date-row {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px; background: var(--blue-light);
  border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 500;
}
.g15-date-row input[type="date"] {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  font-family: inherit; font-size: 14px; color: var(--text); background: #fff;
}
.req { color: var(--red); }

.g15-table-wrap { overflow-x: auto; }
.g15-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.g15-table thead th {
  background: #f1f5f9; text-align: left;
  padding: 10px 14px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.g15-table tbody tr { transition: background .15s; }
.g15-table tbody tr:hover { background: #f8faff; }
.g15-table tbody tr.is-present { background: #f0fdf4; }
.g15-table tbody tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.g15-table td { padding: 9px 14px; vertical-align: middle; }
.col-check   { width: 52px; text-align: center; }
.col-name    { min-width: 110px; font-weight: 600; }
.col-status  { min-width: 130px; }
.col-invited { width: 90px; text-align: center; }
.col-who     { min-width: 140px; }
.col-notes   { min-width: 200px; }
.g15-name { font-weight: 600; }

.g15-checkbox { display: inline-flex; cursor: pointer; position: relative; }
.g15-checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.g15-checkmark {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-radius: 5px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.g15-checkbox input:checked + .g15-checkmark { background: var(--green); border-color: var(--green); }
.g15-checkbox input:checked + .g15-checkmark::after {
  content: ''; display: block; width: 5px; height: 9px;
  border: 2px solid #fff; border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.g15-select, .g15-input, .g15-textarea {
  width: 100%; box-sizing: border-box;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px;
  font-family: inherit; font-size: 13px; color: var(--text); background: #fff;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.g15-select:focus, .g15-input:focus, .g15-textarea:focus {
  border-color: var(--blue-mid); box-shadow: 0 0 0 3px rgba(37,99,168,.12);
}
.g15-textarea { resize: vertical; }
.g15-card-header-small {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
}
.g15-card-header-small h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--blue); }
.g15-icon { font-size: 20px; }
.g15-fields { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.g15-field { display: flex; flex-direction: column; gap: 5px; }
.g15-field label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.g15-submit-bar { display: flex; justify-content: flex-end; gap: 16px; padding: 20px 0; flex-wrap: wrap; }
.g15-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--blue); color: #fff; border: none; border-radius: 10px;
  padding: 14px 28px; font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .2s;
  box-shadow: 0 4px 14px rgba(26,60,94,.3);
}
.g15-btn:hover { background: var(--blue-mid); transform: translateY(-1px); }
.g15-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ─── Search bar (card-head right side) ─────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 6px;
  margin: 0; flex-wrap: wrap;
}
.search-bar .input {
  width: 240px; max-width: 100%;
  padding: 7px 10px; font-size: 13px;
}

/* ─── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 16px 20px; border-top: 1px solid var(--border);
  background: #fafbfd;
  justify-content: space-between;
}
.pagination-info { font-size: 13px; color: var(--muted); }
.pagination-links { display: flex; flex-wrap: wrap; gap: 4px; }
.pagination-links a,
.pagination-links span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: 7px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  color: var(--text); background: #fff;
  transition: background .15s, border-color .15s;
}
.pagination-links a:hover { background: var(--blue-light); border-color: var(--blue-mid); text-decoration: none; }
.pagination-links .is-current { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination-links .is-disabled { opacity: .45; cursor: not-allowed; }
.pagination-links .gap { border: none; background: transparent; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .main { padding: 24px 24px 24px 70px; }
  .sidebar-toggle { display: inline-flex; }
  body.app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: min(85vw, 320px);
    height: 100vh; height: 100dvh;
    z-index: 90;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
  }
  body.app:not(.sidebar-collapsed) .sidebar { transform: translateX(0); }
  body.app.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  body.app.sidebar-collapsed { grid-template-columns: 1fr; }
  /* keep labels visible when sidebar is opened on mobile */
  body.app.sidebar-collapsed .brand-title,
  body.app.sidebar-collapsed .brand-sub,
  body.app.sidebar-collapsed .nav-section,
  body.app.sidebar-collapsed .nav-item span:not(.nav-ico),
  body.app.sidebar-collapsed .user-info,
  body.app.sidebar-collapsed .logout-btn { display: revert; }
  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0; background: rgba(15,23,42,.45);
    z-index: 80; opacity: 0; pointer-events: none;
    transition: opacity .25s;
  }
  body.app:not(.sidebar-collapsed) .sidebar-backdrop {
    opacity: 1; pointer-events: auto;
  }
}
@media (max-width: 760px) {
  .main { padding: 70px 16px 24px; }
  .page-head h1 { font-size: 20px; }
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat-num { font-size: 22px; }
  .grid-2 { grid-template-columns: 1fr; gap: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form > * { width: 100%; }
  /* responsive tables — horizontal scroll on small screens */
  .card-body { overflow-x: auto; }
  table.data { min-width: 560px; }
  .pagination { flex-direction: column; align-items: stretch; gap: 10px; }
  .pagination-info { text-align: center; }
  .pagination-links { justify-content: center; }
  .g15-card-header { flex-wrap: wrap; }
  .g15-stat-pill { margin-left: 0; }
  .g15-table thead th, .g15-table tbody td { padding: 8px 10px; }
}
@media (max-width: 480px) {
  .main { padding: 64px 10px 20px; }
  .sidebar { width: 100vw; }
  .btn { padding: 8px 14px; font-size: 13px; }
  h1 { font-size: 18px; }
  .pagination-links a,
  .pagination-links span { min-width: 30px; height: 30px; padding: 0 8px; font-size: 12px; }
}
