/* ===== HomeCare — Shared UI Components =====
   Include on pages that use these: <link rel="stylesheet" href="/css/components.css">
   ============================================= */

/* ===== TABS (used in client, caregiver, admin dashboards) ===== */
.dash-tabs, .tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: var(--shadow-soft);
  overflow-x: auto;
}

.dash-tab, .tab {
  padding: 12px 20px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-tab:hover, .tab:hover { color: var(--text-primary); }

.dash-tab.active {
  background: linear-gradient(135deg, var(--gentle-coral), var(--warm-terra));
  color: white;
}

/* Admin tabs — dark style */
.tab.active {
  background: var(--deep-brown);
  color: white;
}

.dash-tab .tab-badge, .tab .badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.dash-tab.active .tab-badge, .tab.active .badge {
  background: rgba(255, 255, 255, 0.25);
}

.dash-tab:not(.active) .tab-badge, .tab:not(.active) .badge {
  background: var(--soft-peach);
  color: var(--warm-terra);
}

/* ===== PANELS (tab content) ===== */
.dash-panel, .panel { display: none; }
.dash-panel.active, .panel.active { display: block; animation: fadeIn 0.3s ease; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-soft);
  transition: var(--transition);
  margin-bottom: 16px;
}

.card:hover { box-shadow: var(--shadow-card); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card-title { font-weight: 700; font-size: 1.05rem; }
.card-subtitle { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }

.card-body { display: flex; flex-wrap: wrap; gap: 12px; }

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(92, 61, 46, 0.06);
}

/* ===== STATUS BADGES ===== */
.status, .st {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
}

.st { padding: 3px 10px; font-size: 0.75rem; }

.status-new, .st-new { background: #FEF3C7; color: #92400E; }
.status-contacted, .st-contacted { background: var(--soft-blue-light); color: #2563EB; }
.status-matched, .st-matched { background: var(--trust-green-light); color: #065F46; }
.status-completed, .st-completed { background: #D1FAE5; color: #047857; }
.status-cancelled, .st-cancelled { background: #FEE2E2; color: #991B1B; }
.st-active { background: var(--trust-green-light); color: #065F46; }
.st-inactive { background: #FEE2E2; color: #991B1B; }

/* ===== ROLE BADGES (admin) ===== */
.role-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}

.role-client { background: var(--soft-blue-light); color: #2563EB; }
.role-caregiver { background: var(--soft-peach); color: var(--warm-terra); }
.role-admin { background: var(--deep-brown); color: white; }

/* ===== INFO PILLS ===== */
.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--warm-cream);
  border-radius: 50px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== TAGS ===== */
.tag {
  padding: 6px 14px;
  background: var(--trust-green-light);
  color: #4A8B6F;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
}

.tag.blue { background: var(--soft-blue-light); color: #5A8BA0; }

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gentle-coral), var(--warm-terra));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 133, 107, 0.3);
}

.btn-outline {
  background: transparent;
  border: 2px solid rgba(92, 61, 46, 0.15);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--warm-terra);
  color: var(--warm-terra);
}

.btn-danger {
  background: transparent;
  border: 2px solid #FCA5A5;
  color: #DC2626;
}

.btn-danger:hover { background: #FEE2E2; }

.btn-green { background: var(--trust-green); color: white; }
.btn-green:hover { background: #5A9B7E; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* Admin action buttons */
.act-btn {
  padding: 6px 12px;
  border: 1px solid rgba(92, 61, 46, 0.15);
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-secondary);
  transition: var(--transition);
}

.act-btn:hover { border-color: var(--warm-terra); color: var(--warm-terra); }
.act-btn.save { background: var(--trust-green); color: white; border-color: var(--trust-green); }
.act-btn.save:hover { background: #5A9B7E; }

/* ===== FORMS ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.field { margin-bottom: 0; }

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid rgba(92, 61, 46, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--warm-cream);
  color: var(--text-primary);
  transition: var(--transition);
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--warm-terra);
  background: var(--white);
}

.field textarea { resize: vertical; min-height: 100px; }

.field input::placeholder { color: var(--text-light); }

/* ===== CHIP SELECTOR ===== */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 8px 16px;
  border: 2px solid rgba(92, 61, 46, 0.1);
  border-radius: 50px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
  background: var(--warm-cream);
  color: var(--text-secondary);
  font-family: inherit;
}

.chip:hover, .chip.active {
  border-color: var(--warm-terra);
  background: rgba(212, 133, 107, 0.1);
  color: var(--warm-terra);
}

.chip-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 2px solid rgba(92, 61, 46, 0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
  background: var(--warm-cream);
}

.chip-check:hover, .chip-check.active {
  border-color: var(--trust-green);
  background: var(--trust-green-light);
  color: #065F46;
}

/* ===== STATS ROW ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  text-align: center;
  padding: 20px 16px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.stat-val { font-size: 1.5rem; font-weight: 700; color: var(--warm-terra); }
.stat-lbl { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }

/* Admin stats — wider grid */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.stat .stat-val { font-size: 1.8rem; }
.stat.green .stat-val { color: var(--trust-green); }
.stat.blue .stat-val { color: var(--soft-blue); }

/* ===== MODALS ===== */
.modal-overlay, .modal-bg {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.active, .modal-bg.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 36px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal.wide { max-width: 640px; }

.modal h3 { font-size: 1.2rem; margin-bottom: 20px; }

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--warm-cream);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

[dir="ltr"] .modal-close { right: auto; left: 16px; }

.modal-close:hover { background: var(--soft-peach); }

/* Modal form fields */
.modal-field { margin-bottom: 16px; }

.modal-field label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.modal-field input, .modal-field select, .modal-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid rgba(92, 61, 46, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--warm-cream);
}

.modal-field textarea { min-height: 80px; resize: vertical; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== STAR RATING ===== */
.star-rating { display: flex; gap: 8px; margin-bottom: 16px; direction: ltr; }

.star-btn {
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #E5E7EB;
  transition: var(--transition);
}

.star-btn.filled { color: #F59E0B; }
.star-btn:hover { transform: scale(1.15); }

/* ===== EMPTY STATE ===== */
.empty-state, .empty {
  text-align: center;
  padding: 60px 20px;
}

.empty { padding: 80px 20px; }

.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty .empty-icon { font-size: 3.5rem; }

.empty-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.empty .empty-title { font-size: 1.3rem; }

.empty-desc {
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 auto;
}

.empty-state .empty-desc { margin-bottom: 24px; }

/* ===== LOADING / SPINNER ===== */
.loading { text-align: center; padding: 40px; color: var(--text-light); }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(92, 61, 46, 0.1);
  border-top-color: var(--warm-terra);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

/* ===== DASHBOARD WELCOME ===== */
.dash-welcome { margin-bottom: 32px; }
.dash-welcome h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.dash-welcome p { color: var(--text-secondary); font-size: 0.95rem; }

/* ===== DASHBOARD MAIN ===== */
.dash-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 24px 40px;
}

.dash-main.narrow { max-width: 900px; }

/* ===== SAVE BAR (caregiver profile) ===== */
.save-bar {
  position: sticky;
  bottom: 0;
  background: rgba(255, 248, 240, 0.95);
  backdrop-filter: blur(10px);
  padding: 16px 0;
  border-top: 1px solid rgba(92, 61, 46, 0.08);
  text-align: center;
  margin-top: 24px;
}

.save-msg {
  color: var(--trust-green);
  font-weight: 600;
  font-size: 0.9rem;
  display: none;
  margin-bottom: 8px;
}

.save-msg.visible { display: block; }

/* ===== PROFILE SECTIONS ===== */
.profile-section {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 20px;
}

.profile-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== ADMIN TABLES ===== */
.tbl-wrap {
  overflow-x: auto;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

th {
  background: var(--warm-cream);
  padding: 12px 16px;
  text-align: right;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

[dir="ltr"] th { text-align: left; }

td {
  padding: 12px 16px;
  border-top: 1px solid rgba(92, 61, 46, 0.06);
  vertical-align: middle;
}

tr:hover td { background: rgba(244, 168, 149, 0.04); }

/* ===== ADMIN TOOLBAR ===== */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input, .toolbar select {
  padding: 10px 16px;
  border: 2px solid rgba(92, 61, 46, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--white);
  color: var(--text-primary);
}

.toolbar input:focus, .toolbar select:focus {
  outline: none;
  border-color: var(--warm-terra);
}

.toolbar input { flex: 1; min-width: 200px; }

/* ===== INLINE SELECT (admin) ===== */
.inline-select {
  padding: 4px 8px;
  border: 1px solid rgba(92, 61, 46, 0.15);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--warm-cream);
  cursor: pointer;
}

/* ===== ADMIN RECENT CARDS ===== */
.recent {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}

.recent-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.recent-card h4 { font-size: 0.95rem; margin-bottom: 12px; color: var(--text-secondary); }

.recent-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(92, 61, 46, 0.06);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recent-item:last-child { border: none; }

/* ===== REVIEW COMPONENTS ===== */
.review-card { position: relative; }
.review-stars { color: #F59E0B; font-size: 1.1rem; margin-bottom: 8px; }

.review-comment {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  font-style: italic;
}

.review-date { font-size: 0.8rem; color: var(--text-light); margin-top: 8px; }

.review-textarea {
  width: 100%;
  padding: 14px;
  border: 2px solid rgba(92, 61, 46, 0.1);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--warm-cream);
  resize: vertical;
  min-height: 100px;
  color: var(--text-primary);
}

.review-textarea:focus {
  outline: none;
  border-color: var(--warm-terra);
  background: var(--white);
}

/* ===== CAREGIVER MINI CARD (client dashboard) ===== */
.cg-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--warm-cream);
  border-radius: var(--radius-sm);
}

.cg-mini-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--soft-peach), var(--gentle-coral));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.cg-mini-name { font-weight: 600; font-size: 0.95rem; }
.cg-mini-meta { font-size: 0.8rem; color: var(--text-secondary); }
.cg-mini-rating { color: #F59E0B; font-weight: 700; }

/* ===== FAVORITE CARD (client dashboard) ===== */
.fav-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}

.fav-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--soft-peach), var(--gentle-coral));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.fav-info h3 { font-size: 1rem; font-weight: 700; }

.fav-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.fav-tag {
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--trust-green-light);
  color: #4A8B6F;
}

.fav-tag.blue { background: var(--soft-blue-light); color: #5A8BA0; }

.fav-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .recent { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .dash-tabs, .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dash-tab, .tab { font-size: 0.85rem; padding: 10px 14px; }
  .fav-card { grid-template-columns: 1fr; text-align: center; }
  .fav-actions { flex-direction: row; justify-content: center; }
  .card-header { flex-direction: column; gap: 8px; }
}

/* ===== MOBILE OVERRIDES ===== */
@media (max-width: 640px) {
  .hc-tabs { gap: 4px; padding: 4px; flex-wrap: nowrap; overflow-x: auto; }
  .hc-tab { padding: 8px 12px; font-size: 0.75rem; white-space: nowrap; flex-shrink: 0; }
  .hc-tab .hc-tab-count { font-size: 0.6rem; min-width: 16px; height: 16px; }
  .hc-card { padding: 16px; }
  .hc-card-header { flex-direction: column; gap: 8px; }
  .hc-toolbar { flex-direction: column; gap: 8px; }
  .hc-table { font-size: 0.8rem; }
  .hc-table th, .hc-table td { padding: 8px 10px; }
  .hc-modal-content { width: 95vw; max-height: 90vh; padding: 20px 16px; }
}