/* ── Fonts ──────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@700;800;900&family=Inter:wght@400;500;600;700&display=swap');

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --r: #e6f4ea;
  --r-border: #a8d5b5;
  --z: #e8f0fe;
  --z-border: #a8c0f0;
  --partner: #fce4ec;
  --partner-border: #f48fb1;
  --partner-self: #27a085;  /* teal — partner has kids */
  --partner-free: #1a73e8;  /* blue — partner is free */
  --text: #202124;
  --muted: #5f6368;
  --tagbg: #fff3cd;
  --tagbd: #f0c36d;
  --orange: #fb8c00;
  --surface: #f8f9fa;
  --border: #dadce0;
  --radius: 12px;
  --blue: #1a73e8;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  /* Inter for all body/utility text; falls back to system-ui */
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

body {
  font-family: inherit;
  color: var(--text);
  margin: 0;
  padding: 20px 24px;
  background: #fff;
}

/* Browsers don't inherit font into form controls by default — force it */
button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text);
}

/* ── Calendar grid ─────────────────────────────────────────────────────── */
.calendar-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.month {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  background: white;
  overflow: hidden;
}

.month-title {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid #eef0f2;
  background: var(--surface);
}

table.month-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 5px;
  table-layout: fixed;
}

th {
  padding: 6px 2px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid #eef0f2;
  text-align: center;
}

td {
  height: 82px;
  vertical-align: top;
  border-bottom: 1px solid #f3f4f6;
  border-right: 1px solid #f3f4f6;
  padding: 5px;
  position: relative;
  cursor: default;
}

td:last-child, th:last-child { border-right: none; }

.day-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.label {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  border: 1px solid var(--tagbd);
  background: var(--tagbg);
  font-weight: 600;
}

/* ── Day ownership colors ─────────────────────────────────────────────── */
td.r  { background: var(--r); }
td.z  { background: var(--z); }
td.empty { background: #fafafa; }

/* ── Partner overlay dots ─────────────────────────────────────────────── */
.partner-dots {
  position: absolute;
  bottom: 5px;
  left: 5px;
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot.partner-self  { background: var(--partner-self); }  /* teal: partner has kids */
.dot.partner-free  { background: var(--partner-free); }  /* blue: partner free */

/* ── Both free frame ──────────────────────────────────────────────────── */
td.bothfree { box-shadow: inset 0 0 0 3px var(--orange); }

/* ── Today highlight ─────────────────────────────────────────────────── */
td.today .day-num {
  background: var(--blue);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Proposed change (pending approval) ──────────────────────────────── */
td.proposed {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(251,140,0,0.12) 4px,
    rgba(251,140,0,0.12) 8px
  );
  outline: 2px dashed var(--orange);
  outline-offset: -2px;
}

/* ── Visibility toggles ──────────────────────────────────────────────── */
body.hide-r    td.r    { background: white; }
body.hide-z    td.z    { background: white; }
body.hide-partner .partner-dots { display: none; }
body.hide-frames td.bothfree   { box-shadow: none; }

/* ── Controls bar ─────────────────────────────────────────────────────── */
.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.controls-title { font-weight: 600; font-size: 13px; color: var(--muted); }

.toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .3s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider { background-color: var(--blue); }
input:checked + .slider:before { transform: translateX(18px); }

.toggle-label { font-size: 13px; user-select: none; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: filter 0.15s;
}

.btn:hover { filter: brightness(0.92); }
.btn-primary  { background: var(--blue); color: var(--btn-primary-text, white); }
.btn-green    { background: #34a853; color: white; }
.btn-purple   { background: #9c27b0; color: white; }
.btn-gray     { background: #5f6368; color: white; }
.btn-outline  { background: transparent; color: var(--text, #e2e2e2); border: 1.5px solid var(--border, rgba(226,226,226,0.08)); }
.btn-danger   { background: #d93025; color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Summary bar ──────────────────────────────────────────────────────── */
.summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.summary-stat { display: flex; align-items: center; gap: 8px; }
.summary-swatch {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid var(--border);
}
.summary-count { font-size: 17px; font-weight: 700; }

/* ── Legend ───────────────────────────────────────────────────────────── */
.legend {
  margin: 0 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  align-items: center;
}

.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }

/* ── Edit mode notices ────────────────────────────────────────────────── */
.edit-notice {
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 14px;
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.edit-notice.active { display: flex; }
.notice-custody   { background: #e8f5e9; border: 1px solid #81c784; color: #2e7d32; }
.notice-holiday   { background: #fff3e0; border: 1px solid #ffb74d; color: #e65100; }
.notice-partner   { background: #e3f2fd; border: 1px solid #64b5f6; color: #0d47a1; }

/* ── Notification badge ───────────────────────────────────────────────── */
.notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #d93025;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 0 4px;
}

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: 12px;
  padding: 28px;
  max-width: 440px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal h2 { font-size: 18px; margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Connections panel ────────────────────────────────────────────────── */
.connections-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.connection-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #eef0f2;
  font-size: 13px;
}

.connection-row:last-child { border-bottom: none; }

.conn-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.conn-status.approved { background: #e8f5e9; color: #2e7d32; }
.conn-status.pending  { background: #fff3e0; color: #e65100; }
.conn-status.expired  { background: #fce4ec; color: #b71c1c; }
.conn-status.rejected { background: #f3f4f6; color: #5f6368; }

/* ── Wizard (onboarding) ──────────────────────────────────────────────── */
.wizard {
  max-width: 560px;
  margin: 40px auto;
  padding: 0 16px;
}

.wizard-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.wizard-step { display: none; }
.wizard-step.active { display: block; }

.wizard-title { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.wizard-sub   { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.progress-bar {
  height: 4px;
  background: #e8eaed;
  border-radius: 2px;
  margin-bottom: 28px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.radio-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.radio-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.radio-option:hover { border-color: var(--blue); background: #f0f6ff; }
.radio-option input[type="radio"] { margin-top: 2px; accent-color: var(--blue); }
.radio-option.selected { border-color: var(--blue); background: #f0f6ff; }

.radio-label { font-size: 14px; font-weight: 600; }
.radio-desc  { font-size: 12px; color: var(--muted); margin-top: 2px; }

.field-group { margin-bottom: 20px; }
.field-label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 6px; }

.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.field-input:focus { outline: none; border-color: var(--blue); }

.day-checkboxes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.day-check {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.day-check input { display: none; }

.day-pill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s;
}

.day-check input:checked + .day-pill {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.day-pill-label { font-size: 10px; color: var(--muted); }

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #eef0f2;
}

/* ── Mini preview calendar (wizard) ──────────────────────────────────── */
.mini-calendar-preview {
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 12px;
  overflow: hidden;
  margin: 16px 0;
  background: #0a0a0a;
}

.mini-cal-title {
  background: #131313;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
  color: #eeeef8;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  letter-spacing: -0.01em;
}

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.mini-cal-head {
  padding: 6px 2px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: rgba(238,238,248,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: #131313;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.mini-cal-day {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: rgba(238,238,248,0.75);
  border-right: 1px solid rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background .12s;
}
.mini-cal-day:hover { background: rgba(167,139,250,0.10); }

.mini-cal-day.self     { background: rgba(124,92,191,0.28); color: #c4b5fd; font-weight: 800; }
.mini-cal-day.coparent { background: rgba(99,102,241,0.15); color: rgba(238,238,248,0.45); }
.mini-cal-day.empty    { background: transparent; color: transparent; cursor: default; }
.mini-cal-day.empty:hover { background: transparent; }

/* ── Success state ────────────────────────────────────────────────────── */
.success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #e8f5e9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}

.pending-state {
  text-align: center;
  padding: 32px 0;
}

.pending-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* ── Partner overlay in calendar ─────────────────────────────────────── */
.partner-overlay-banner {
  background: linear-gradient(135deg, #e8f5e9, #f0fdf4);
  border: 1px solid var(--r-border);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Utility ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.flex-gap { display: flex; gap: 10px; align-items: center; }
.divider { border-left: 2px solid var(--border); height: 28px; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--muted); font-size: 13px; }
.text-sm { font-size: 13px; }
.bold { font-weight: 700; }
.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
