/* Portal Reusable Components */

/* ========================================
   STATUS BADGES
   ======================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  line-height: 1.4;
  white-space: nowrap;
}

.status-pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-text);
}

.status-confirmed {
  background: var(--status-confirmed-bg);
  color: var(--status-confirmed-text);
}

.status-in-review,
.status-in_review {
  background: var(--status-in-review-bg);
  color: var(--status-in-review-text);
}

.status-completed {
  background: var(--status-completed-bg);
  color: var(--status-completed-text);
}

.status-cancelled,
.status-canceled {
  background: var(--status-cancelled-bg);
  color: var(--status-cancelled-text);
}

.status-no-show,
.status-no_show {
  background: var(--status-no-show-bg);
  color: var(--status-no-show-text);
}

.status-breached {
  background: var(--status-breached-bg);
  color: var(--status-breached-text);
}

.status-assigned {
  background: var(--status-assigned-bg);
  color: var(--status-assigned-text);
}

.status-paid {
  background: var(--status-paid-bg);
  color: var(--status-paid-text);
}

.status-unpaid {
  background: var(--status-unpaid-bg);
  color: var(--status-unpaid-text);
}

/* ========================================
   PORTAL CARDS
   ======================================== */
.portal-card {
  background: var(--white);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-standard), transform var(--transition-standard);
}

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

.portal-card.clickable:hover {
  transform: translateY(-2px);
  cursor: pointer;
}

.portal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid #f3f4f6;
}

.portal-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark-gray);
  margin: 0;
}

.portal-card-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.portal-card-body {
  padding: 0;
}

.portal-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid #f3f4f6;
}

/* Stat Cards */
.stat-card {
  background: var(--white);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
  text-align: center;
  transition: box-shadow var(--transition-standard), transform var(--transition-standard);
}

.stat-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--medical-blue);
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card.stat-teal .stat-value {
  color: var(--accent-teal);
}

.stat-card.stat-warning .stat-value {
  color: var(--warning);
}

.stat-card.stat-danger .stat-value {
  color: var(--danger);
}

/* ========================================
   BUTTONS
   ======================================== */
.p-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-standard);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.p-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.p-btn-primary {
  background: var(--medical-blue);
  color: var(--white);
}

.p-btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.p-btn-teal {
  background: var(--accent-teal);
  color: var(--white);
}

.p-btn-teal:hover:not(:disabled) {
  background: var(--accent-teal-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.p-btn-secondary {
  background: transparent;
  color: var(--medical-blue);
  border: 2px solid var(--medical-blue);
}

.p-btn-secondary:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.08);
}

.p-btn-danger {
  background: var(--status-cancelled);
  color: var(--white);
}

.p-btn-danger:hover:not(:disabled) {
  background: #dc2626;
  transform: translateY(-1px);
}

.p-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 16px;
}

.p-btn-ghost:hover:not(:disabled) {
  background: #f3f4f6;
  color: var(--text-primary);
}

.p-btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.p-btn-lg {
  padding: 14px 32px;
  font-size: 16px;
}

.p-btn-block {
  width: 100%;
}

.p-btn-icon {
  padding: 10px;
  border-radius: var(--radius-md);
}

.p-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ========================================
   FORM COMPONENTS
   ======================================== */
.p-form-group {
  margin-bottom: var(--space-2);
}

.p-form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 6px;
}

.p-form-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.p-form-input,
.p-form-select,
.p-form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.p-form-input:focus,
.p-form-select:focus,
.p-form-textarea:focus {
  border-color: var(--medical-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.p-form-input.error,
.p-form-select.error,
.p-form-textarea.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.p-form-textarea {
  min-height: 120px;
  resize: vertical;
}

.p-form-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}

.p-form-group.has-error .p-form-error {
  display: block;
}

.p-form-group.has-error .p-form-input,
.p-form-group.has-error .p-form-select,
.p-form-group.has-error .p-form-textarea {
  border-color: var(--danger);
}

/* Checkbox / Radio */
.p-checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.p-checkbox-group:hover {
  border-color: var(--medical-blue);
  background: #fafbff;
}

.p-checkbox-group.checked {
  border-color: var(--medical-blue);
  background: #eff6ff;
}

.p-checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--medical-blue);
  flex-shrink: 0;
}

/* ========================================
   ALERTS / TOASTS
   ======================================== */
.p-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: var(--space-2);
}

.p-alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.p-alert-content {
  flex-grow: 1;
}

.p-alert-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.p-alert-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: 0.5;
  font-size: 18px;
  line-height: 1;
}

.p-alert-close:hover {
  opacity: 1;
}

.p-alert-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.p-alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.p-alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.p-alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Toast notification */
.p-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-standard);
  max-width: 400px;
  color: var(--white);
}

.p-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.p-toast-success {
  background: var(--success);
}

.p-toast-error {
  background: var(--danger);
}

.p-toast-info {
  background: var(--medical-blue);
}

/* ========================================
   MODAL / DIALOG
   ======================================== */
.p-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalOverlayIn 0.2s ease;
}

.p-modal-overlay.active {
  display: flex;
}

@keyframes modalOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.p-modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.p-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #f3f4f6;
}

.p-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark-gray);
  margin: 0;
}

.p-modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  font-size: 20px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.p-modal-close:hover {
  background: #f3f4f6;
  color: var(--text-primary);
}

.p-modal-body {
  padding: 24px;
}

.p-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
  padding: 16px 24px;
  border-top: 1px solid #f3f4f6;
}

/* ========================================
   TABS
   ======================================== */
.p-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: var(--space-3);
  overflow-x: auto;
}

.p-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.p-tab::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--medical-blue);
  transform: scaleX(0);
  transition: transform var(--transition-standard);
}

.p-tab:hover {
  color: var(--medical-blue);
}

.p-tab.active {
  color: var(--medical-blue);
}

.p-tab.active::after {
  transform: scaleX(1);
}

.p-tab-panel {
  display: none;
}

.p-tab-panel.active {
  display: block;
}

/* ========================================
   TABLE
   ======================================== */
.p-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid #e5e7eb;
}

.p-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.p-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.p-table td {
  padding: 14px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.p-table tr:last-child td {
  border-bottom: none;
}

.p-table tr:hover td {
  background: #fafbff;
}

.p-table .cell-bold {
  font-weight: 600;
  color: var(--dark-gray);
}

.p-table .cell-muted {
  font-size: 13px;
  color: var(--text-muted);
}

/* ========================================
   TIMELINE
   ======================================== */
.p-timeline {
  position: relative;
  padding-left: 32px;
}

.p-timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e5e7eb;
}

.p-timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.p-timeline-item:last-child {
  padding-bottom: 0;
}

.p-timeline-dot {
  position: absolute;
  left: -32px;
  top: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--white);
  border: 3px solid var(--medical-blue);
  z-index: 1;
}

.p-timeline-dot.completed {
  background: var(--medical-blue);
}

.p-timeline-dot.active {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.2);
}

.p-timeline-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 2px;
}

.p-timeline-date {
  font-size: 13px;
  color: var(--text-muted);
}

.p-timeline-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.p-empty {
  text-align: center;
  padding: var(--space-8) var(--space-3);
  color: var(--text-secondary);
}

.p-empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-2);
  opacity: 0.4;
}

.p-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: var(--space-1);
}

.p-empty-text {
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto var(--space-3);
}

/* ========================================
   AVATAR
   ======================================== */
.p-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--deep-blue), var(--medical-blue));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.p-avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.p-avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 22px;
}

.p-avatar-xl {
  width: 96px;
  height: 96px;
  font-size: 32px;
}

/* ========================================
   DIVIDER
   ======================================== */
.p-divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: var(--space-3) 0;
}

/* ========================================
   PRICE ROW (for payment pages)
   ======================================== */
.p-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 15px;
}

.p-price-row .label {
  color: var(--text-secondary);
}

.p-price-row .value {
  font-weight: 600;
  color: var(--dark-gray);
}

.p-price-row.total {
  padding: 14px 0;
  margin-top: 8px;
  border-top: 2px solid #e5e7eb;
  font-size: 18px;
}

.p-price-row.total .label {
  font-weight: 700;
  color: var(--dark-gray);
}

.p-price-row.total .value {
  font-weight: 800;
  color: var(--medical-blue);
  font-size: 22px;
}

/* ========================================
   STAR RATING (display)
   ======================================== */
.p-stars {
  display: inline-flex;
  gap: 2px;
}

.p-stars .star {
  color: #f59e0b;
  font-size: 14px;
}

.p-stars .star.empty {
  color: #d1d5db;
}

/* ========================================
   ANALYTICS DASHBOARD COMPONENTS
   ======================================== */

/* Attention banners */
.attention-banner { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.attention-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; text-decoration: none; color: inherit;
  transition: all 0.2s;
}
.attention-danger { background: #fef2f2; border: 1px solid #fca5a5; color: #dc2626; }
.attention-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #d97706; }
.attention-muted { background: #f3f4f6; border: 1px solid #d1d5db; color: #6b7280; }
.attention-item:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* KPI clickable cards */
a.kpi-card-link { display: block; text-decoration: none; color: inherit; transition: transform 0.2s, box-shadow 0.2s; border-radius: 12px; }
a.kpi-card-link:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

/* Chart empty states */
.chart-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 200px; color: var(--text-muted, #94a3b8); gap: 8px; }
.chart-empty p { margin: 0; font-size: 14px; font-weight: 500; }
.chart-empty span { font-size: 12px; }

/* Action buttons in lists */
.btn-small { padding: 4px 8px; font-size: 11px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; }
.btn-primary { background: var(--owner-primary, #2563eb); color: white; border: none; }
.btn-outline { background: transparent; border: 1px solid var(--owner-border-light, #e5e7eb); color: var(--text-primary); }

/* Health bar pills */
.health-bar { display: flex; gap: 12px; flex-wrap: wrap; }
.health-item { display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.health-ok { background: #ecfdf5; color: #059669; }
.health-warn { background: #fffbeb; color: #d97706; }
.health-bad { background: #fef2f2; color: #dc2626; }
