/*
 * App layout on top of theme.css (Good Shepherd brand tokens & components).
 * Keep brand colors in theme.css; this file only uses its variables.
 */
:root {
  --color-danger: #b3261e;
  --color-danger-bg: #fbe8e6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
h1 { font-size: 1.6rem; margin: .2em 0 .4em; }
h2 { font-size: 1.15rem; margin: 0; }
main { max-width: 960px; margin: 0 auto; padding: 20px 16px; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

/* ---------- Header / footer ---------- */
.site-header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.site-header .brand a:hover { text-decoration: none; }
.brand a { display: flex; }
.brand img { width: 44px; height: 44px; border-radius: 50%; background: var(--gs-white); padding: 2px; }
.brand small { display: block; font-weight: 400; font-size: .8rem; opacity: .9; }
.site-header nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.site-header button.link { color: var(--color-text-on-dark); }
.site-footer { text-align: center; font-size: .9rem; padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); }
.site-footer p { margin: 0; }

/* ---------- Cards ---------- */
.slots { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 10px; }
.card.full { border-top-color: var(--gs-gray-500); }
.admin-card { margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.time { margin: 2px 0 0; color: var(--color-text-muted); }
.task { margin: 4px 0 0; font-weight: 600; color: var(--color-secondary-hover); }
.desc { margin: 0; color: var(--color-text-muted); white-space: pre-line; }
.badge { white-space: nowrap; }
.badge-full { background: var(--gs-gray-100); color: var(--gs-gray-500); }
.names { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.names li { padding: 6px 10px; border-radius: var(--radius); background: var(--gs-green-50); border-left: 4px solid var(--color-secondary); }
.names li.open-spot { background: transparent; border: 1px dashed var(--color-border); color: var(--color-text-muted); font-style: italic; }
.card > .btn { margin-top: auto; text-align: center; }
.capacity-form { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.capacity-form label { font-weight: 600; font-size: .9rem; }
.capacity-form input { width: 4.5rem; padding: .3rem .5rem; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 6px; border-top: 1px solid var(--color-border); }

/* ---------- Buttons ---------- */
.btn { font: inherit; font-weight: 600; }
.btn.small { padding: .35rem .8rem; font-size: .9rem; }
.btn-danger { background: var(--color-danger); color: var(--color-text-on-dark); }
.btn-danger:hover { background: #8c1d17; color: var(--color-text-on-dark); }
.site-header .btn-outline { color: var(--color-text-on-dark); border-color: var(--color-text-on-dark); }
.site-header .btn-outline:hover { background: var(--color-text-on-dark); color: var(--color-primary); text-decoration: none; }
button.link { background: none; border: 0; padding: 0; color: var(--color-link); font: inherit; cursor: pointer; text-decoration: underline; }
button.link.danger { color: var(--color-danger); }
form.inline { display: inline; }

/* ---------- Panels & forms ---------- */
.panel { background: var(--color-bg); border: 1px solid var(--color-border); border-top: 4px solid var(--color-primary);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; max-width: 560px; }
.panel.narrow { max-width: 400px; margin: 24px auto; }
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .95rem; }
.form input, .form textarea, .form select { width: 100%; font-weight: 400; background: var(--color-bg); color: var(--color-text); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Alerts (flash messages) ---------- */
.alert { margin: 0 0 14px; }
.alert-error { border-left-color: var(--color-danger); background: var(--color-danger-bg); color: var(--color-danger); }
.muted { color: var(--color-text-muted); }
.small { font-size: .85rem; }
.empty { color: var(--color-text-muted); padding: 24px 0; }

/* ---------- Admin ---------- */
.admin-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--color-border); }
.tabs a { text-decoration: none; color: var(--color-text-muted); padding-bottom: 6px; }
.tabs a.active { color: var(--color-primary); border-bottom: 3px solid var(--color-accent); font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
th { background: var(--gs-blue-50); color: var(--color-primary); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.row-actions { white-space: nowrap; display: flex; gap: 10px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 .panel { max-width: none; }
ul.plain { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Classes list / chips ---------- */
.class-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 12px; }
.class-card { text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s; }
.class-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(12, 74, 140, .2); color: inherit; }
.class-card h2 { font-size: 1.3rem; }
.class-card .go { margin-top: auto; color: var(--color-primary); font-weight: 600; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 2px 0 0; }
.chip { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px;
  background: var(--gs-blue-50); color: var(--gs-blue-700); margin-bottom: 4px; }
.role-super { background: var(--gs-green-50); color: var(--gs-green-700); }
.flash-highlight { animation: hl 1.6s ease-out; }
@keyframes hl { 0%, 40% { box-shadow: 0 0 0 4px var(--color-accent); } 100% { box-shadow: var(--shadow); } }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px 12px; }
.check-all { flex-direction: row !important; align-items: center; gap: 6px; font-weight: 400 !important; margin-bottom: 6px; }
.check-all input { width: auto; }
.checks label { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.checks input { width: auto; }
fieldset.form-field { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
fieldset.form-field legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: 4px; }
.hint { font-weight: 400; font-size: .85rem; color: var(--color-text-muted); }
.inline-edit { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-edit input { flex: 1; min-width: 140px; }

/* ---------- Calendar popup ---------- */
.dp-input { position: relative; }
.dp-input input { padding-right: 2.6rem; }
.dp-trigger { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none;
  color: var(--color-primary); padding: 6px; cursor: pointer; border-radius: var(--radius); line-height: 0; }
.dp-trigger:hover, .dp-trigger:focus-visible { background: var(--gs-blue-50); }
.dp-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(27, 42, 58, .35); }
.dp { position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(340px, calc(100vw - 32px));
  background: var(--color-bg); border: 1px solid var(--color-border); border-top: 4px solid var(--color-primary);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(12, 74, 140, .25); padding: 12px; }
.dp.dp-anchored { position: absolute; transform: none; }
.dp-backdrop:has(+ .dp-anchored) { background: transparent; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--color-primary); }
.dp-nav { border: 0; background: none; font-size: 1.5rem; line-height: 1; width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; color: var(--color-primary); }
.dp-nav:hover { background: var(--gs-blue-50); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.dp-dow { font-size: .75rem; font-weight: 600; color: var(--color-text-muted); padding: 4px 0; }
.dp-day { aspect-ratio: 1; border: 0; border-radius: 50%; background: none; font: inherit; color: var(--color-text); cursor: pointer; position: relative; }
.dp-day:hover:not([disabled]) { background: var(--gs-blue-50); }
.dp-day[disabled] { color: #b9c0c9; cursor: default; }
.dp-today { font-weight: 700; box-shadow: inset 0 0 0 2px var(--gs-blue-100); }
.dp-available { background: var(--gs-green-50); color: var(--gs-green-900); font-weight: 600; }
.dp-available::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 5px; height: 5px; margin-left: -2.5px;
  border-radius: 50%; background: var(--color-secondary); }
.dp-selected, .dp-selected:hover:not([disabled]) { background: var(--color-primary); color: var(--color-text-on-dark); }
.dp-day:focus-visible, .dp-nav:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.dp-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.dp-foot > span:last-child { display: flex; gap: 6px; }
.dp-legend { font-size: .85rem; color: var(--color-text-muted); display: flex; align-items: center; gap: 6px; }
.dp-legend i { width: 14px; height: 14px; border-radius: 50%; background: var(--gs-green-50); box-shadow: inset 0 0 0 2px var(--color-secondary); }

/* Stack the admin table into cards on phones */
@media (max-width: 640px) {
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr { border: 1px solid var(--color-border); border-left: 4px solid var(--color-secondary); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 10px; }
  td { border: 0; padding: 3px 0; }
  td[data-label]:not(:empty)::before { content: attr(data-label) ": "; color: var(--color-text-muted); font-size: .85rem; }
  td[data-label]:empty { display: none; }
  .row { grid-template-columns: 1fr; }
}
