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

:root {
  --green:   #22c55e;
  --green-l: #dcfce7;
  --amber:   #f59e0b;
  --amber-l: #fef3c7;
  --red:     #ef4444;
  --red-l:   #fee2e2;
  --blue:    #3b82f6;
  --blue-l:  #dbeafe;
  --grey:    #6b7280;
  --grey-l:  #f3f4f6;
  --dark:    #111827;
  --border:  #e5e7eb;
  --radius:  6px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--dark);
  background: #fafafa;
}

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

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
}
header h1 { font-size: 1.25rem; font-weight: 700; }
header h1 a { color: var(--dark); }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.admin-header nav { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  padding: 1rem 0;
  color: var(--grey);
  font-size: 0.85rem;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.alert-success { background: var(--green-l); border: 1px solid var(--green); color: #166534; }
.alert-warning { background: var(--amber-l); border: 1px solid var(--amber); color: #92400e; }
.alert-danger  { background: var(--red-l);   border: 1px solid var(--red);   color: #991b1b; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  background: none;
}
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; text-decoration: none; }
.btn-danger  { background: var(--red);  color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; text-decoration: none; }
.btn-ghost   { background: #fff; border-color: var(--border); color: var(--dark); }
.btn-ghost:hover { background: var(--grey-l); text-decoration: none; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.available   { background: var(--green-l); color: #166534; }
.badge.unavailable { background: var(--amber-l); color: #92400e; }
.badge.tentative   { background: var(--amber-l); color: #92400e; }
.badge.busy        { background: var(--red-l);   color: #991b1b; }
.badge.pending     { background: var(--blue-l);  color: #1e40af; }
.badge.approved    { background: var(--green-l); color: #166534; }
.badge.rejected,
.badge.auto_rejected { background: var(--red-l); color: #991b1b; }

.badge-count {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

/* ── Gift banner ─────────────────────────────────────────────────────────── */
.gift-banner {
  background: var(--green-l);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: #166534;
}
.gift-banner ol {
  margin: 0.3rem 0 0 1.25rem;
  padding: 0;
}
.gift-banner a { color: #166534; font-weight: 600; }

/* ── Calendar ────────────────────────────────────────────────────────────── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.cal-nav h2 { font-size: 1.15rem; }

.legend {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-header {
  background: var(--grey-l);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--grey);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.cal-cell {
  min-height: 80px;
  padding: 0.4rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other-month { background: #f9fafb; }
.cal-cell.other-month .day-num { color: #9ca3af; }
.cal-cell.today { background: var(--blue-l); }
.cal-cell.today .day-num { color: var(--blue); font-weight: 700; }

.day-num {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.cal-cell .badge {
  display: block;
  text-align: center;
  font-size: 0.72rem;
  padding: 0.15rem 0.3rem;
}
.cal-cell .badge.available {
  cursor: pointer;
  transition: filter 0.15s;
}
.cal-cell .badge.available:hover { filter: brightness(0.93); text-decoration: none; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-card, .login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 540px;
  margin: 0 auto;
}
.login-card { margin-top: 4rem; }

.form-card h2, .login-card h2 { margin-bottom: 1rem; font-size: 1.15rem; }

.slot-info {
  background: var(--grey-l);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.field { display: flex; flex-direction: column; margin-bottom: 0.9rem; }
.field label { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
.field input, .field textarea, .field select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  background: #fff;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.req { color: var(--red); }
.opt { color: var(--grey); font-weight: 400; }
.char-hint { color: var(--grey); font-size: 0.78rem; margin-top: 0.2rem; }
.muted { color: var(--grey); }

.actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* ── Admin table ─────────────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.admin-table th { background: var(--grey-l); font-weight: 600; font-size: 0.8rem; color: var(--grey); }
.admin-table tr:hover td { background: #f9fafb; }
.actions-cell { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }

/* ── Request cards ───────────────────────────────────────────────────────── */
.request-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.request-card.pending { border-left: 4px solid var(--blue); }

.request-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.request-slot   { font-size: 0.9rem; margin-bottom: 0.4rem; }
.request-message { background: var(--grey-l); border-radius: var(--radius);
                   padding: 0.5rem; font-size: 0.9rem; margin: 0.5rem 0; }
.request-note   { color: var(--grey); font-size: 0.85rem; margin-bottom: 0.4rem; }
.request-meta   { color: var(--grey); font-size: 0.8rem; margin-bottom: 0.6rem; }

.request-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.inline-form { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.inline-form input[type="text"] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  width: 200px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .cal-cell { min-height: 60px; }
  .cal-header { font-size: 0.7rem; padding: 0.3rem 0; }
  .cal-cell .badge { font-size: 0.65rem; }
  .field-row { grid-template-columns: 1fr; }
  .admin-table { font-size: 0.8rem; }
}
