/* Advocate Home Care Services — Portal theme
   Palette: blue (#1f6feb / #2b7de9), dark blue (#0d2a52), gold (#d4a017) */

:root {
  --blue: #2b7de9;
  --blue-dark: #0d2a52;
  --blue-deeper: #08203c;
  --gold: #d4a017;
  --gold-light: #e9c46a;
  --ink: #1a2733;
  --muted: #5b6b7b;
  --bg: #f4f7fb;
  --card: #ffffff;
  --border: #dfe6ef;
  --danger: #c0392b;
  --success: #2e7d32;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(13, 42, 82, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.app { min-height: 100vh; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Auth (login) ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(43,125,233,0.18), transparent 60%),
    linear-gradient(160deg, var(--blue-deeper) 0%, var(--blue-dark) 55%, #123a6b 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
}
.auth-card-wide { max-width: 520px; }

/* --- Registration wizard (elderly-friendly) --- */
.wiz-title {
  font-size: 22px;
  color: var(--blue-dark);
  margin: 0 0 20px;
  line-height: 1.3;
}
.steps { display: flex; gap: 6px; margin-bottom: 24px; }
.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.step-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.step.active .step-num { background: var(--blue); color: #fff; }
.step.active { color: var(--blue-dark); font-weight: 600; }
.step.done .step-num { background: var(--success); color: #fff; }
.step-label { text-align: center; }

.wiz-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}
.wiz-nav .btn { min-height: 48px; font-size: 17px; padding: 12px 20px; }

.review-box {
  background: #f7faff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 16px;
}
.review-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.review-row:last-child { border-bottom: none; }
.review-row span { color: var(--muted); }
.review-row strong { color: var(--blue-dark); text-align: right; overflow-wrap: anywhere; }

.req { color: var(--danger); }

/* Choice cards (registration wizard) */
.choice-list { display: flex; flex-direction: column; gap: 12px; }
.choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--blue); }
.choice-selected { border-color: var(--blue); background: #f0f6ff; }
.choice-title { font-size: 16px; font-weight: 700; color: var(--blue-dark); }
.choice-desc { font-size: 13px; color: var(--muted); }

/* Elderly-friendly: larger inputs within the wizard */
.auth-card .field label { font-size: 15px; }
.auth-card .field input, .auth-card .field textarea {
  font-size: 17px;
  padding: 13px 14px;
}
.auth-card .btn {
  font-size: 16px;
  min-height: 52px;
}

.brand {
  text-align: center;
  margin-bottom: 28px;
}
.brand .logo-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  color: var(--blue-dark);
  letter-spacing: -0.2px;
}
.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--ink);
  background: #fbfcfe;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: transparent;
}
.field textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d63cf; box-shadow: 0 4px 14px rgba(43,125,233,0.35); }
.btn-dark { background: var(--blue-dark); color: #fff; }
.btn-dark:hover { background: var(--blue-deeper); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-gold { background: var(--gold); color: #1a2733; }
.btn-gold:hover { background: var(--gold-light); }
.btn-ghost { background: transparent; color: var(--blue-dark); border: 1px solid var(--border); }
.btn-ghost:hover { background: #eef3fb; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.error-box, .success-box {
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}
.error-box { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }
.success-box { background: #e9f6ea; color: var(--success); border: 1px solid #bfe3c4; }
.hidden { display: none !important; }

.auth-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.auth-foot button {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

/* ---------- App shell / dashboard ---------- */
.topbar {
  background: var(--blue-dark);
  color: #fff;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}
.topbar .brand-inline .logo-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--gold);
  color: var(--blue-deeper);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.topbar .user-chip {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px;
}
.topbar .role-badge {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  text-transform: capitalize;
}
.topbar .btn { height: 36px; padding: 6px 14px; font-size: 13px; }

.nav {
  display: flex;
  gap: 4px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.nav button {
  background: none;
  border: none;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.nav button.active {
  color: var(--blue-dark);
  border-bottom-color: var(--gold);
}

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  font-size: 22px;
  color: var(--blue-dark);
  margin: 0 0 4px;
}
.page-sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.confirm-notice {
  margin: -8px 0 20px;
  padding: 12px 14px;
  background: #fff4e0;
  border: 1px solid #f0d48a;
  border-radius: 8px;
  color: var(--blue-dark);
  font-size: 14px;
  line-height: 1.4;
}

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Caregiver status page: two equal-width columns on wide screens */
.status-grid-2col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--border);
}
.card h3 { margin: 0 0 12px; color: var(--blue-dark); font-size: 16px; }

/* Caregiver cards */
.cg-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.cg-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--gold));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; flex-shrink: 0;
}
.cg-avatar-img { object-fit: cover; }
.cg-name { font-size: 16px; font-weight: 700; color: var(--blue-dark); }
.cg-meta { font-size: 13px; color: var(--muted); }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  margin: 2px 3px 2px 0;
}
.badge-verified { background: #e9f6ea; color: var(--success); }
.badge-pending { background: #fff4e0; color: #a06600; }
.badge-service { background: #eef3fb; color: var(--blue-dark); }
.rate { font-weight: 700; color: var(--blue-dark); }

/* Admin caregiver management list */
.cg-admin-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cg-admin-row:last-child { border-bottom: none; }
.cg-admin-main { display: flex; flex-direction: column; gap: 2px; }
.rates-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.vetting-select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fbfcfe;
}

/* Care recipient rows */
.rc-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.rc-row:last-child { border-bottom: none; }

/* Settings tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  background: none;
  border: none;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab.active { color: var(--blue-dark); border-bottom-color: var(--gold); }

/* Users table */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.users-table th, .users-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.users-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.users-table tr:last-child td { border-bottom: none; }

/* Modal overlay (edit user) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 32, 60, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  width: 100%;
  max-width: 420px;
}

/* Logo preview */
.logo-preview {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.header-logo-preview {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #f4f7fb;
}
.topbar-logo {
  height: 34px;
  width: auto;
  margin-right: 8px;
  vertical-align: middle;
  display: none;
}
.auth-logo {
  width: 180px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  margin: 0 auto 14px;
  display: none;
}

/* Profile photo */
.prof-photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.prof-photo {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--blue);
  background: var(--border);
}
.prof-photo-actions { display: flex; flex-direction: column; }

/* Shift report box */
.shift-report-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

/* Calendar */
.cal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.cal-title { font-size: 18px; font-weight: 700; color: var(--blue-dark); flex: 1; text-align: center; }
.cal-clock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #eef3fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  margin-bottom: 12px;
}
.cal-clock strong { color: var(--blue-dark); font-variant-numeric: tabular-nums; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.cal-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot-pending { background: #d4a017; }
.dot-confirmed { background: #2e7d32; }
.dot-completed { background: #2b7de9; }
.dot-cancelled { background: #9aa5b1; }

#cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  padding: 6px 0;
  text-transform: uppercase;
}
.cal-cell {
  min-height: 84px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  background: #fbfcfe;
  overflow: hidden;
}
.cal-cell:hover { border-color: var(--blue); }
.cal-cell-empty { border: none; background: transparent; cursor: default; }
.cal-today { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.cal-daynum { font-size: 13px; font-weight: 600; color: var(--blue-dark); margin-bottom: 4px; }
.cal-chips { display: flex; flex-direction: column; gap: 3px; }
.cal-chip {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}
.chip-pending { background: #d4a017; }
.chip-confirmed { background: #2e7d32; }
.chip-completed { background: #2b7de9; }
.chip-cancelled { background: #9aa5b1; }
.cal-more { font-size: 10px; color: var(--muted); padding-left: 4px; }

@media (max-width: 640px) {
  .cal-cell { min-height: 56px; padding: 3px; }
  .cal-chip { font-size: 8px; padding: 1px 3px; }
  .cal-daynum { font-size: 11px; }
}

/* Booking form */
.checkbox-list { display: grid; gap: 8px; }
.checkbox-list label {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 14px; line-height: 1.4;
}
.checkbox-list label:hover { background: #f7faff; }
.checkbox-list input { accent-color: var(--blue); width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; }

/* Caregiver status page: module rows (label + optional link/URL controls) */
.status-module-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.status-module-row label { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.4; cursor: pointer; }

/* Quiz score pass/fail badges on the caregiver status page */
.badge-pass { background: #e9f6ea; color: var(--success); border: 1px solid #bfe3c4; }
.badge-fail { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }

/* Booking list rows */
.booking-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.booking-row:last-child { border-bottom: none; }
.bk-datetime {
  font-size: 16px;
  font-weight: 700;
  color: var(--blue-dark);
  width: 100%;
}
.bk-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  width: 100%;
}
.bk-details { color: var(--muted); font-size: 13px; }
.bk-main { display: flex; flex-direction: column; gap: 2px; }
.bk-cartype {
  margin-left: auto;
  font-weight: 700;
  color: var(--blue-dark);
  font-size: 13px;
}
.bk-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.booking-row .bk-status {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px;
}
.status-pending { color: #a06600; }
.status-confirmed { color: var(--success); }
.status-completed { color: var(--blue); }
.status-cancelled { color: var(--muted); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 18px;
}
.toolbar input, .toolbar select {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}

.empty {
  text-align: center; color: var(--muted); padding: 40px 0; font-size: 15px;
}

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------------ */
/* Responsive layout                                                          */
/* ------------------------------------------------------------------------ */

/* Prevent flex/grid children from overflowing narrow screens. */
.card, .toolbar, .booking-row, .cg-head, .topbar, .nav, .checkbox-list label {
  min-width: 0;
}
input, select, textarea, .bk-main, .user-chip {
  max-width: 100%;
}

/* --- Tablet (portrait) and below --- */
@media (max-width: 820px) {
  .content { padding: 18px; }
  .grid-2, .grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
}

/* --- Phone --- */
@media (max-width: 640px) {
  .auth-card { padding: 30px 22px; margin: 12px; }
  .auth-wrap { padding: 12px; }

  .topbar {
    padding: 0 12px;
    height: 58px;
  }
  .topbar .brand-inline { font-size: 14px; }
  .topbar .brand-inline .logo-mark { width: 30px; height: 30px; font-size: 13px; }
  .topbar .user-chip { gap: 8px; }
  .topbar .role-badge { display: none; } /* save space on phone */
  .topbar .btn { padding: 5px 10px; font-size: 12px; }

  .nav {
    padding: 8px 10px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .nav button {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
    scroll-snap-align: start;
    flex: 0 0 auto;
  }

  .content { padding: 14px; }
  .page-title { font-size: 19px; }

  .grid { gap: 14px; }
  .grid-2, .grid-3, .status-grid-2col { grid-template-columns: 1fr; } /* single column on phones */

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select { width: 100%; font-size: 16px; } /* 16px avoids iOS zoom */
  .toolbar .btn { width: 100%; }

  .field input, .field select, .field textarea { font-size: 16px; } /* avoid iOS auto-zoom */

  .bk-cartype { margin-left: 0; }

  .cg-head { flex-wrap: wrap; }

  /* Larger touch targets for interactive elements */
  .btn { min-height: 44px; }
  .checkbox-list label { min-height: 44px; }
}

/* --- Very small phones --- */
@media (max-width: 360px) {
  .auth-card { padding: 24px 16px; }
}
