/**
 * Cloud HMS — Patient Portal styles
 * The patient portal reuses the staff HMS shell (shell.css); this file adds
 * the patient-app experience: mobile bottom navigation, safe-area support,
 * notification centre, settings/security pages, skeletons and a11y helpers.
 */

/* Login page: ensure the overlay fills the viewport even when staff layout is hidden */
.hms-layout.patient-portal-mode {
  margin-left: 0 !important;
  padding-top: 0;
  visibility: visible;
}

.hms-layout.patient-portal-mode #main-content {
  padding: 0;
  margin: 0;
  max-width: 100%;
}

/* Hover lift for dashboard quick-action cards */
.hover-shadow {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hover-shadow:hover {
  transform: translateY(-3px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

/* ── Accessibility: visible focus + touch targets ──────────────────────────── */
.hms-layout a:focus-visible,
.hms-layout button:focus-visible,
.hms-layout .pnotif-item:focus-visible,
.pbottom-item:focus-visible,
.pnotif-chip:focus-visible {
  outline: 3px solid rgba(13, 110, 253, 0.55);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .hover-shadow,
  .pbottom-item,
  .pnotif-chip {
    transition: none !important;
  }
  .hover-shadow:hover { transform: none; }
  .skeleton { animation: none !important; opacity: 0.5; }
}

/* ── Skeleton loading ───────────────────────────────────────────────────────── */
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, #e9ecef 25%, #f8f9fa 50%, #e9ecef 75%);
  background-size: 200% 100%;
  animation: hms-skeleton-shimmer 1.4s infinite;
  border-radius: 6px;
}
.skeleton-text {
  display: block;
  height: 0.85rem;
  margin: 0.5rem 0;
}
.skeleton-item .pnotif-icon.skeleton {
  background-color: #e9ecef;
}
@keyframes hms-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Mobile bottom navigation (app shell) ──────────────────────────────────── */
#patient-bottomnav {
  display: none;
}

@media (max-width: 768px) {
  #patient-bottomnav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    background: #fff;
    border-top: 1px solid #e5e9f2;
    box-shadow: 0 -2px 12px rgba(16, 24, 40, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .pbottom-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    padding: 6px 2px;
    color: #6c757d;
    text-decoration: none;
    font-size: 0.68rem;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .pbottom-item .pbottom-icon-wrap {
    position: relative;
    font-size: 1.25rem;
    line-height: 1;
  }
  .pbottom-item.active {
    color: #0d6efd;
    font-weight: 600;
  }
  .pbottom-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
  }
  /* Content clears the bottom bar on mobile */
  body.has-patient-bottomnav #main-content {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0));
  }
}

/* Safe-area padding for the patient topbar on notched phones */
#patient-topbar {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* ── Notification centre ────────────────────────────────────────────────────── */
.pnotif-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid #eef1f6;
  scrollbar-width: thin;
}
.pnotif-chip {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid #dee2e6;
  background: #fff;
  color: #495057;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pnotif-chip:hover { border-color: #0d6efd; color: #0d6efd; }
.pnotif-chip.active {
  background: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}
.pnotif-chip.active .badge { background: #fff !important; color: #0d6efd; }

.pnotif-date-group {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8a94a6;
  padding: 14px 4px 6px;
}

.pnotif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid #f1f3f8;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.12s ease;
}
.pnotif-item:hover { background: #f6f8fc; }
.pnotif-item.unread { background: #f0f6ff; }
.pnotif-item.unread:hover { background: #e6effd; }
.pnotif-item:last-child { border-bottom: 0; }

.pnotif-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}
.bg-purple-subtle { background: #f3e8fd; }
.text-purple { color: #7c3aed; }

.pnotif-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: #1f2a44;
}
.pnotif-item:not(.unread) .pnotif-title { font-weight: 500; color: #4a5568; }
.pnotif-message {
  font-size: 0.83rem;
  color: #6c757d;
  margin-top: 1px;
  overflow-wrap: anywhere;
}
.pnotif-time {
  font-size: 0.72rem;
  color: #9aa3b2;
  margin-top: 3px;
}
.pnotif-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0d6efd;
  margin-top: 6px;
}
.pnotif-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.pnotif-actions .btn { min-width: 44px; min-height: 44px; }
.min-w-0 { min-width: 0; }

/* ── Security & devices page ────────────────────────────────────────────────── */
.pdevice-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid #f1f3f8;
}
.pdevice-item:last-child { border-bottom: 0; }
.pdevice-item.current { background: #f0fdf6; border-radius: 10px; }
.pdevice-icon {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #eef2f9;
  color: #40506b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.pevent-item {
  display: flex;
  align-items: flex-start;
  padding: 8px 4px;
  border-bottom: 1px solid #f5f6fa;
}
.pevent-item:last-child { border-bottom: 0; }

/* ── Settings page switches ─────────────────────────────────────────────────── */
.form-check.form-switch .form-check-input {
  min-width: 2.6rem;
  min-height: 1.4rem;
  cursor: pointer;
}
.form-check.form-switch .form-check-input:disabled { cursor: not-allowed; }
.form-check.form-switch .form-check-label { padding-top: 2px; }

/* Larger touch targets for patient app controls on small screens */
@media (max-width: 768px) {
  .hms-layout .btn { min-height: 44px; }
  .hms-layout .btn-sm { min-height: 38px; }
  .hms-card { border-radius: 14px; }
}

/* Dashboard quick actions */
.pqa-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 576px) { .pqa-grid { grid-template-columns: repeat(4, 1fr); } }
.pqa-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 92px;
  border: 1px solid #e8ecf4;
  border-radius: 14px;
  background: #fff;
  color: #33415c;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  padding: 10px 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.pqa-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.08);
  border-color: #0d6efd;
  color: #0d6efd;
}
.pqa-card i { font-size: 1.4rem; color: #0d6efd; }

/* Summary tiles */
.psummary-tile {
  border: 1px solid #e8ecf4;
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  height: 100%;
}
.psummary-tile .psummary-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a94a6;
  font-weight: 700;
}
.psummary-tile .psummary-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1f2a44;
  margin-top: 4px;
}
.psummary-tile .psummary-sub {
  font-size: 0.78rem;
  color: #6c757d;
  margin-top: 2px;
}
