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

:root {
  --brand:       #0078d4;
  --brand-dark:  #005a9e;
  --brand-light: #e8f2fb;
  --success:     #107c10;
  --danger:      #c62828;
  --warning:     #f59e0b;
  --text:        #1a1a2e;
  --muted:       #6b7280;
  --border:      #e2e8f0;
  --bg:          #f8fafc;
  --card:        #ffffff;
  --radius:      10px;
  --shadow:      0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--brand);
  color: #fff;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 1.5rem;
  display: flex; align-items: center; gap: 1.5rem; height: 56px;
}
.brand { font-size: 1.15rem; font-weight: 700; color: #fff; white-space: nowrap; }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: 4px; flex: 1; }
nav a {
  color: rgba(255,255,255,.85); padding: 6px 12px; border-radius: 6px;
  font-size: .9rem; transition: background .15s;
}
nav a:hover { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }
.user-selector { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.user-label { font-size: .85rem; color: rgba(255,255,255,.85); }
.user-label.muted { color: rgba(255,255,255,.5); }

/* ─── Main ───────────────────────────────────────────────────────────────── */
.site-main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem;
  font-size: .9rem; font-weight: 500;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ─── Page Header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.page-header p  { color: var(--muted); margin-top: .2rem; }
.header-actions { display: flex; gap: .5rem; align-items: center; }
.page-header-centered { justify-content: space-between; align-items: center; }
.page-header-centered > div { flex: 1; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem 1rem; border-radius: 6px; font-size: .875rem;
  font-weight: 500; cursor: pointer; border: none; transition: all .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--brand);   color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline   { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a31515; }
.btn-sm  { padding: .35rem .75rem; font-size: .8rem; }
.btn-xs  { padding: .2rem .55rem;  font-size: .75rem; }

/* ─── Week Navigation ────────────────────────────────────────────────────── */
.week-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem 1rem; margin-bottom: 1.5rem; box-shadow: var(--shadow);
}
.week-title { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.week-range { font-size: 1.05rem; font-weight: 600; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 20px;
  font-size: .72rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
}
.badge-current  { background: #dcfce7; color: #166534; }
.badge-trade    { background: #fff3cd; color: #856404; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-declined { background: #f8d7da; color: #721c24; }
.badge-pending  { background: #cce5ff; color: #004085; }
.badge-cancelled{ background: #e2e8f0; color: #4a5568; }

/* ─── Schedule Grid ──────────────────────────────────────────────────────── */
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 380px));
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.task-card {
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .75rem;
  transition: box-shadow .15s;
}
.task-card:hover { box-shadow: 0 4px 20px rgba(0,120,212,.12); }
.task-card.overridden { border-color: var(--warning); background: #fffbf0; }

.task-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.task-name { font-weight: 700; font-size: 1rem; }
.task-desc { color: var(--muted); font-size: .875rem; }

.assigned-user {
  display: flex; align-items: center; gap: .75rem;
  background: var(--brand-light); border-radius: 8px; padding: .6rem .75rem;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.user-email { font-size: .8rem; color: var(--muted); }

.rotation-details { font-size: .85rem; color: var(--muted); }
.rotation-details summary { cursor: pointer; user-select: none; }
.rotation-details summary:hover { color: var(--brand); }
.rotation-list { padding: .4rem 0 0 1.4rem; display: flex; flex-direction: column; gap: .2rem; }
.rotation-list .current-user { font-weight: 700; color: var(--brand); }

.trade-btn { margin-top: .25rem; align-self: flex-start; }

/* ─── Upcoming Strip ─────────────────────────────────────────────────────── */
.upcoming-section h2 { font-size: 1.1rem; margin-bottom: .85rem; text-align: center; }
.upcoming-strip {
  display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; justify-content: center; flex-wrap: wrap;
}
.upcoming-card {
  min-width: 200px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .35rem;
}
.upcoming-week-label { font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.upcoming-row { display: flex; justify-content: space-between; font-size: .82rem; gap: .5rem; }
.upcoming-task { color: var(--muted); }
.upcoming-user { font-weight: 600; }
.upcoming-link { font-size: .78rem; margin-top: .4rem; color: var(--brand); }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1.75rem; max-width: 620px;
  box-shadow: var(--shadow);
}
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .875rem; }
.form-control {
  width: 100%; padding: .5rem .75rem; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: .9rem; font-family: var(--font);
  transition: border-color .15s; background: var(--bg);
}
.form-control:focus { outline: none; border-color: var(--brand); background: #fff; }
textarea.form-control { resize: vertical; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }
.form-hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.form-hint.warning { color: #856404; }
.form-error { font-size: .8rem; color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.checkbox-group label { display: flex; align-items: center; gap: .5rem; font-weight: 500; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  background: var(--bg); padding: .6rem .75rem; text-align: left;
  font-weight: 600; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); border-bottom: 2px solid var(--border);
}
.data-table td { padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table .row-inactive td { opacity: .5; }
.data-table .row-actions { display: flex; gap: .35rem; align-items: center; }
.small { font-size: .8rem; }

/* ─── Admin ──────────────────────────────────────────────────────────────── */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
@media (max-width: 768px) { .admin-grid { grid-template-columns: 1fr; } }

.admin-card {
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.admin-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); background: var(--bg);
}
.admin-card-header h2 { font-size: 1rem; font-weight: 700; }
.admin-links { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ─── Trades ─────────────────────────────────────────────────────────────── */
.trade-section { margin-bottom: 2rem; }
.trade-section h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: .85rem; }
.trade-list { display: flex; flex-direction: column; gap: .75rem; }
.trade-card {
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow);
}
.trade-card.trade-pending { border-color: var(--brand); background: #f0f7ff; }
.trade-card.trade-sent    { border-color: var(--warning); background: #fffbf0; }
.trade-meta { display: flex; justify-content: space-between; margin-bottom: .5rem; }
.trade-task { font-weight: 700; }
.trade-week { font-size: .82rem; color: var(--muted); }
.trade-notes { font-size: .875rem; color: var(--muted); font-style: italic; }
.trade-actions { display: flex; gap: .5rem; margin-top: .75rem; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.modal {
  background: var(--card); border-radius: var(--radius);
  padding: 1.75rem; width: 340px; max-width: 95vw; box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: .25rem; }
.user-btn {
  display: block; width: 100%; padding: .6rem .75rem; margin-bottom: .4rem;
  border: 1.5px solid var(--border); border-radius: 6px;
  background: var(--bg); text-align: left; cursor: pointer; font-size: .9rem;
  transition: all .15s;
}
.user-btn:hover, .user-btn.active {
  border-color: var(--brand); background: var(--brand-light); color: var(--brand); font-weight: 600;
}

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
  background: var(--card); border-radius: var(--radius); border: 1px dashed var(--border);
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .schedule-grid { grid-template-columns: 1fr; }
  .week-nav { flex-direction: column; gap: .5rem; text-align: center; }
  .form-row { grid-template-columns: 1fr; }
  .header-inner { gap: .75rem; }
  nav a { padding: 6px 8px; font-size: .82rem; }
}
