/* ==========================================================================
   Invigor Patient Dashboard - Design System & Styles
   Based on invigor-frontend-v2 React application
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Brand Colors */
  --brand-ultra-light: #E9EEFC;
  --brand-light: #AFC5FF;
  --brand-mid: #3F71F4;
  --brand-dark: #1544BE;
  --brand-ultra-dark: #003366;

  /* Status Colors */
  --success: #228403;
  --success-light: #D7F7C2;
  --success-dark: #05690D;

  --critical: #DF1B1B;
  --critical-light: #FFE7F2;
  --critical-dark: #B3063D;

  --attention: #C87801;
  --attention-light: #FCEDB9;
  --attention-dark: #A82C00;

  --info: #0570DE;
  --info-light: #CFF5F6;
  --info-dark: #0055BC;

  /* Neutral Colors */
  --neutral-primary: #30313D;
  --neutral-secondary: #6A7383;
  --neutral-disabled: #A3ACBA;
  --neutral-border: #D5DBE1;
  --neutral-bg-light: #F6F8FA;
  --neutral-bg-lighter: #FAFAFA;
  --neutral-white: #FFFFFF;

  /* Typography */
  --font-primary: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --font-secondary: 'Montserrat', var(--font-primary);

  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */

  /* Spacing */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --header-height: 64px;
  --content-max-width: 1400px; /* Increased for large monitors */
}

/* --------------------------------------------------------------------------
   Reset & Base Styles
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--neutral-primary);
  background-color: var(--neutral-bg-light);
}

a {
  color: var(--brand-mid);
  text-decoration: none;
}

a:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  cursor: pointer;
  font-family: inherit;
}

/* --------------------------------------------------------------------------
   Layout Structure
   -------------------------------------------------------------------------- */
.pd-app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar - extends to top, behind site header */
.pd-sidebar {
  position: fixed;
  top: 0; /* Start at very top */
  left: 0;
  width: var(--sidebar-width);
  height: 100vh; /* Full viewport height */
  background: var(--neutral-white);
  border-right: 1px solid var(--neutral-border);
  display: flex;
  flex-direction: column;
  z-index: 0; /* Behind site header */
  overflow: visible; /* Allow toggle button to extend outside */
}

/* Logo header at top of sidebar */
.pd-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-bottom: 1px solid var(--neutral-border);
  height: 94px; /* 54px logo + 40px padding */
  position: relative;
  flex-shrink: 0;
}

/* Hide sidebar right border for the header area (94px) */
.pd-sidebar__header::after {
  content: '';
  position: absolute;
  top: 0;
  right: -1px;
  width: 1px;
  height: 94px;
  background: var(--neutral-white);
  z-index: 1;
}

.pd-sidebar__logo {
  display: block;
}

.pd-sidebar__logo img {
  height: 54px;
  width: auto;
}

/* Hide mini logo on desktop */
.pd-sidebar__logo-mini {
  display: none;
}

/* Mobile close button - hidden on desktop */
.pd-sidebar__close-mobile {
  display: none;
}

.pd-sidebar__nav {
  flex: 1;
  padding-top: 86px; /* Adjusted - logo header takes 94px now */
  padding-bottom: var(--space-md);
  overflow-y: auto;
}

.pd-sidebar__nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  color: var(--neutral-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.pd-sidebar__nav-item:hover {
  background: var(--neutral-bg-light);
  color: var(--neutral-primary);
  text-decoration: none;
}

.pd-sidebar__nav-item.active {
  background: var(--brand-ultra-light);
  color: var(--brand-mid);
  border-left-color: var(--brand-mid);
}

.pd-sidebar__nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.pd-sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.pd-sidebar__user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--brand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-dark);
  font-weight: 600;
}

.pd-sidebar__user-info {
  flex: 1;
  min-width: 0;
}

.pd-sidebar__user-name {
  font-weight: 600;
  font-size: var(--font-size-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pd-sidebar__user-email {
  font-size: var(--font-size-xs);
  color: var(--neutral-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Header & Toggle - Hidden on desktop, shown on mobile */
/* Note: .pd-sidebar__header is set to display:none earlier for desktop */

.pd-sidebar__logo {
  display: flex;
  align-items: center;
  padding: 0;
  border-bottom: none;
}

.pd-sidebar__logo-full {
  height: 32px;
  width: auto;
  display: block;
}

.pd-sidebar__logo-mini {
  height: 32px;
  width: 32px;
  display: none;
}

/* Toggle button - positioned on sidebar right edge, vertically centered */
.pd-sidebar__toggle {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--neutral-white);
  border: 1px solid var(--neutral-border);
  border-radius: var(--radius-full);
  color: var(--neutral-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.pd-sidebar__toggle:hover {
  background: var(--neutral-bg-light);
  color: var(--neutral-primary);
}

.pd-sidebar__toggle svg {
  width: 14px;
  height: 14px;
}

.pd-sidebar__toggle-expand {
  display: none;
}

.pd-sidebar__toggle-collapse {
  display: block;
}

/* Sidebar divider */
.pd-sidebar__divider {
  height: 1px;
  background: var(--neutral-border);
  margin: var(--space-sm) var(--space-lg);
}

/* Short divider - indented on both sides */
.pd-sidebar__divider--short {
  margin: var(--space-sm) var(--space-lg);
}

/* Full-width divider - spans entire sidebar */
.pd-sidebar__divider--full {
  margin: var(--space-sm) 0;
}

/* Sidebar footer */
.pd-sidebar__footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--neutral-border);
}

.pd-sidebar__logout {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--neutral-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all 0.15s ease;
}

.pd-sidebar__logout:hover {
  background: var(--critical-light);
  color: var(--critical);
  text-decoration: none;
}

.pd-sidebar__logout svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Collapsible Sidebar */
.pd-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.pd-sidebar.collapsed .pd-sidebar__logo-full {
  display: none;
}

.pd-sidebar.collapsed .pd-sidebar__logo-mini {
  display: block;
}

.pd-sidebar.collapsed .pd-sidebar__toggle-collapse {
  display: none;
}

.pd-sidebar.collapsed .pd-sidebar__toggle-expand {
  display: block;
}

.pd-sidebar.collapsed .pd-sidebar__header {
  justify-content: center;
  padding: 20px;
  height: 94px;
}

.pd-sidebar.collapsed .pd-sidebar__logo {
  margin-right: 0;
}

.pd-sidebar.collapsed .pd-sidebar__toggle {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: var(--neutral-white);
  border: 1px solid var(--neutral-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.pd-sidebar.collapsed .pd-sidebar__nav-item {
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  border-left-width: 0;
  position: relative;
}

.pd-sidebar.collapsed .pd-sidebar__nav-item.active {
  border-left-width: 0;
  border-radius: var(--radius-md);
  margin: 0 var(--space-sm);
  padding: var(--space-sm);
}

.pd-sidebar.collapsed .pd-sidebar__nav-item span {
  display: none;
}

.pd-sidebar.collapsed .pd-sidebar__nav-item svg {
  width: 24px;
  height: 24px;
}

/* Tooltips for collapsed sidebar */
.pd-sidebar.collapsed .pd-sidebar__nav-item::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  padding: var(--space-xs) var(--space-sm);
  background: var(--neutral-primary);
  color: var(--neutral-white);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  margin-left: var(--space-sm);
  pointer-events: none;
  z-index: 1000;
}

.pd-sidebar.collapsed .pd-sidebar__nav-item:hover::after {
  opacity: 1;
  visibility: visible;
}

.pd-sidebar.collapsed .pd-sidebar__divider {
  margin: var(--space-sm);
}

.pd-sidebar.collapsed .pd-sidebar__footer {
  padding: var(--space-md) var(--space-sm);
}

.pd-sidebar.collapsed .pd-sidebar__user {
  justify-content: center;
  padding: var(--space-sm);
}

.pd-sidebar.collapsed .pd-sidebar__user-info {
  display: none;
}

.pd-sidebar.collapsed .pd-sidebar__user-avatar {
  width: 36px;
  height: 36px;
  font-size: var(--font-size-sm);
}

.pd-sidebar.collapsed .pd-sidebar__logout {
  justify-content: center;
  padding: var(--space-sm);
}

.pd-sidebar.collapsed .pd-sidebar__logout span {
  display: none;
}

/* Main content adjusts when sidebar collapsed */
.pd-app.sidebar-collapsed .pd-main {
  margin-left: var(--sidebar-collapsed-width);
}

/* Transitions for smooth collapse/expand */
.pd-sidebar {
  transition: width 0.2s ease;
}

/* Main Content Area */
.pd-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding-top: 0; /* No extra padding - site header handles spacing */
  display: block; /* Changed from flex to allow full width */
  transition: margin-left 0.3s ease;
}

/* When sidebar is collapsed, keep content in same position */
.pd-app.sidebar-collapsed .pd-main {
  margin-left: var(--sidebar-collapsed-width);
}

/* Header */
.pd-header {
  position: sticky;
  top: 0;
  background: var(--neutral-white);
  border-bottom: 1px solid var(--neutral-border);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  z-index: 50;
}

.pd-header__title {
  font-size: var(--font-size-xl);
  font-weight: 600;
}

.pd-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.pd-header__logout {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--neutral-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all 0.15s ease;
  text-decoration: none;
}

.pd-header__logout:hover {
  background: var(--critical-light);
  color: var(--critical);
  text-decoration: none;
}

.pd-header__logout svg {
  flex-shrink: 0;
}

/* Content */
.pd-content {
  padding: var(--space-xl) var(--space-2xl);
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* Hide the dashboard header since we use site header */
.pd-header {
  display: none;
}

/* Hide Breakdance "My Account" heading */
.bde-heading-321293-103 {
  display: none !important;
}

/* Override Breakdance page wrapper - remove all margins and padding */
.brxe-post-content,
.bde-section-321293-100,
.bde-section-321293-100 .section-container,
.bde-section {
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
  width: 100% !important;
}

/* Mobile menu toggle - floating button */
.pd-mobile-menu-toggle {
  display: none; /* Hidden on desktop */
  position: fixed;
  top: 90px; /* Below site header */
  left: var(--space-md);
  z-index: 95; /* Above sidebar but below site header */
  background: var(--neutral-white);
  border: 1px solid var(--neutral-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  max-width: 44px;
}

.pd-mobile-menu-toggle svg {
  display: block;
  color: var(--neutral-primary);
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .pd-mobile-menu-toggle {
    display: flex;
  }
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.pd-card {
  background: var(--neutral-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-border);
}

.pd-card__header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--neutral-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pd-card__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.pd-card__body {
  padding: var(--space-lg);
}

.pd-card__footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--neutral-border);
  background: var(--neutral-bg-lighter);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Clickable card title link (for dashboard sections) */
.pd-card__title-link {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-sm);
  color: var(--brand-mid);
  text-decoration: none;
  transition: color 0.15s ease;
}

.pd-card__title-link:hover {
  color: var(--brand-dark);
  text-decoration: none;
}

.pd-card__title-link .pd-card__title {
  color: inherit;
  margin: 0;
}

.pd-card__title-link svg {
  flex-shrink: 0;
  transition: transform 0.15s ease;
  align-self: center;
  margin-top: 2px;
}

.pd-card__title-link:hover svg {
  transform: translateX(2px);
}

/* --------------------------------------------------------------------------
   Status Badges
   -------------------------------------------------------------------------- */
.pd-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.pd-status--active,
.pd-status--completed {
  background: var(--success-light);
  color: var(--success-dark);
}

.pd-status--on-hold,
.pd-status--pending,
.pd-status--pharmacy,
.pd-status--admin-review {
  background: var(--attention-light);
  color: var(--attention-dark);
}

.pd-status--cancelled,
.pd-status--failed {
  background: var(--critical-light);
  color: var(--critical-dark);
}

.pd-status--expired {
  background: var(--neutral-bg-light);
  color: var(--neutral-secondary);
}

/* --------------------------------------------------------------------------
   Badges (semantic variant for PHP templates)
   -------------------------------------------------------------------------- */
.pd-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  white-space: nowrap;
  vertical-align: baseline;
  line-height: 1.4;
}

.pd-badge--success {
  background: var(--success-light);
  color: var(--success);
}

.pd-badge--attention {
  background: var(--attention-light);
  color: var(--attention);
}

.pd-badge--critical {
  background: var(--critical-light);
  color: var(--critical);
}

.pd-badge--neutral {
  background: var(--neutral-bg-light);
  color: var(--neutral-secondary);
}

.pd-badge--info {
  background: var(--brand-ultra-light);
  color: var(--brand-mid);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.pd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: none;
  transition: all 0.15s ease;
}

.pd-btn--primary {
  background: var(--brand-mid);
  color: var(--neutral-white);
}

.pd-btn--primary:hover {
  background: var(--brand-dark);
}

.pd-btn--secondary {
  background-color: var(--neutral-bg-light) !important;
  color: var(--neutral-primary) !important;
  border: 1px solid var(--neutral-border) !important;
}

.pd-btn--secondary:hover {
  background-color: var(--neutral-border) !important;
}

.pd-btn--danger {
  background: var(--critical);
  color: var(--neutral-white);
}

.pd-btn--danger:hover {
  background: var(--critical-dark);
}

.pd-btn--ghost {
  background: transparent;
  color: var(--brand-mid);
}

.pd-btn--ghost:hover {
  background: var(--brand-ultra-light);
}

.pd-btn--critical {
  background: var(--critical);
  color: var(--neutral-white);
}

.pd-btn--critical:hover {
  background: var(--critical-dark);
}

.pd-btn--sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
}

.pd-btn--lg {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-base);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.pd-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto; /* Let columns size naturally based on content */
}

.pd-table th,
.pd-table td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--neutral-border);
}

.pd-table th {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neutral-secondary);
  background: var(--neutral-bg-lighter);
}

.pd-table tr:hover {
  background: var(--neutral-bg-lighter);
}

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

/* --------------------------------------------------------------------------
   Subscription Card
   -------------------------------------------------------------------------- */
.pd-subscription-card {
  display: flex;
  align-items: center; /* Vertically center all items including the button */
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--neutral-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-border);
  transition: box-shadow 0.15s ease;
}

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

.pd-subscription-card__image {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  background: var(--neutral-bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pd-subscription-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.pd-subscription-card__content {
  flex: 1;
  min-width: 0;
}

.pd-subscription-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.pd-subscription-card__title {
  font-weight: 600;
  font-size: var(--font-size-base);
}

.pd-subscription-card__id {
  font-size: var(--font-size-sm);
  color: var(--neutral-secondary);
}

.pd-subscription-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-lg);
  margin-top: var(--space-sm);
}

.pd-subscription-card__meta-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-xs);
}

/* Details link styled inline with meta */
.pd-subscription-card__meta .pd-details-link {
  color: var(--brand-mid);
  text-decoration: underline;
  font-weight: 500;
  font-size: var(--font-size-sm);
}

.pd-subscription-card__meta .pd-details-link:hover {
  color: var(--brand-dark);
}

.pd-subscription-card__meta-label {
  font-size: var(--font-size-xs);
  color: var(--neutral-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pd-subscription-card__meta-value {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.pd-subscription-card__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0; /* Prevent button from shrinking */
}

/* --------------------------------------------------------------------------
   Dashboard Stats
   -------------------------------------------------------------------------- */
.pd-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.pd-stat {
  background: var(--neutral-white);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--neutral-border);
}

.pd-stat__label {
  font-size: var(--font-size-sm);
  color: var(--neutral-secondary);
  margin-bottom: var(--space-xs);
}

.pd-stat__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--neutral-primary);
}

.pd-stat__change {
  font-size: var(--font-size-xs);
  margin-top: var(--space-xs);
}

.pd-stat__change--positive {
  color: var(--success);
}

.pd-stat__change--negative {
  color: var(--critical);
}

/* Compact Clickable Stat Cards */
.pd-stat-card {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  background: var(--neutral-white);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--neutral-border);
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}

.pd-stat-card--clickable {
  cursor: pointer;
}

.pd-stat-card--clickable:hover {
  border-color: var(--brand-mid);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.pd-stat-card--clickable:active {
  transform: scale(0.98);
}

.pd-stat-card__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--brand-mid);
  line-height: 1;
}

.pd-stat-card__label {
  font-size: var(--font-size-sm);
  color: var(--neutral-secondary);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Empty States
   -------------------------------------------------------------------------- */
.pd-empty {
  text-align: center;
  padding: var(--space-2xl);
}

.pd-empty__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-lg);
  color: var(--neutral-disabled);
}

.pd-empty__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.pd-empty__description {
  color: var(--neutral-secondary);
  max-width: 400px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.pd-form-group {
  margin-bottom: var(--space-lg);
}

.pd-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.pd-input,
.pd-select,
.pd-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--neutral-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pd-input:focus,
.pd-select:focus,
.pd-textarea:focus {
  outline: none;
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px var(--brand-ultra-light);
}

.pd-input::placeholder {
  color: var(--neutral-disabled);
}

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

/* --------------------------------------------------------------------------
   Payment Method Card
   -------------------------------------------------------------------------- */
.pd-payment-method {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--neutral-white);
  border: 1px solid var(--neutral-border);
  border-radius: var(--radius-md);
}

.pd-payment-method__icon {
  width: 48px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-bg-light);
  border-radius: var(--radius-sm);
}

.pd-payment-method__details {
  flex: 1;
}

.pd-payment-method__brand {
  font-weight: 500;
}

.pd-payment-method__number {
  font-size: var(--font-size-sm);
  color: var(--neutral-secondary);
}

.pd-payment-method__expiry {
  font-size: var(--font-size-xs);
  color: var(--neutral-secondary);
}

.pd-payment-method__default {
  font-size: var(--font-size-xs);
  color: var(--success);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Address Card
   -------------------------------------------------------------------------- */
.pd-address {
  padding: var(--space-md);
  background: var(--neutral-bg-lighter);
  border-radius: var(--radius-md);
}

.pd-address__type {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neutral-secondary);
  margin-bottom: var(--space-sm);
}

.pd-address__name {
  font-weight: 500;
}

.pd-address__line {
  font-size: var(--font-size-sm);
  color: var(--neutral-secondary);
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.pd-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
}

.pd-pagination__btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--neutral-white);
  border: 1px solid var(--neutral-border);
  color: var(--neutral-primary);
  font-size: var(--font-size-sm);
  transition: all 0.15s ease;
}

.pd-pagination__btn:hover {
  background: var(--neutral-bg-light);
}

.pd-pagination__btn.active {
  background: var(--brand-mid);
  color: var(--neutral-white);
  border-color: var(--brand-mid);
}

.pd-pagination__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Loading States
   -------------------------------------------------------------------------- */
.pd-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
}

.pd-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--neutral-border);
  border-top-color: var(--brand-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */

/* Tablet: Always show collapsed sidebar */
@media (max-width: 1024px) and (min-width: 769px) {
  /* Force collapsed state on tablet */
  .pd-sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .pd-sidebar .pd-sidebar__logo-full {
    display: none;
  }

  .pd-sidebar .pd-sidebar__logo-mini {
    display: block;
  }

  .pd-sidebar .pd-sidebar__toggle {
    display: none;
  }

  .pd-sidebar .pd-sidebar__header {
    justify-content: center;
    padding: var(--space-md);
  }

  .pd-sidebar .pd-sidebar__nav-item {
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    border-left-width: 0;
    position: relative;
  }

  .pd-sidebar .pd-sidebar__nav-item.active {
    border-left-width: 0;
    border-radius: var(--radius-md);
    margin: 0 var(--space-sm);
    padding: var(--space-sm);
  }

  .pd-sidebar .pd-sidebar__nav-item span {
    display: none;
  }

  .pd-sidebar .pd-sidebar__nav-item svg {
    width: 24px;
    height: 24px;
  }

  /* Tooltips on tablet */
  .pd-sidebar .pd-sidebar__nav-item::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    padding: var(--space-xs) var(--space-sm);
    background: var(--neutral-primary);
    color: var(--neutral-white);
    font-size: var(--font-size-xs);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    margin-left: var(--space-sm);
    pointer-events: none;
    z-index: 1000;
  }

  .pd-sidebar .pd-sidebar__nav-item:hover::after {
    opacity: 1;
    visibility: visible;
  }

  .pd-sidebar .pd-sidebar__divider {
    margin: var(--space-sm);
  }

  .pd-sidebar .pd-sidebar__footer {
    padding: var(--space-md) var(--space-sm);
  }

  .pd-sidebar .pd-sidebar__user {
    justify-content: center;
    padding: var(--space-sm);
  }

  .pd-sidebar .pd-sidebar__user-info {
    display: none;
  }

  .pd-sidebar .pd-sidebar__user-avatar {
    width: 36px;
    height: 36px;
    font-size: var(--font-size-sm);
  }

  .pd-sidebar .pd-sidebar__logout {
    justify-content: center;
    padding: var(--space-sm);
  }

  .pd-sidebar .pd-sidebar__logout span {
    display: none;
  }

  /* Main content adjusts for collapsed sidebar */
  .pd-main {
    margin-left: var(--sidebar-collapsed-width);
  }

  .pd-app.sidebar-collapsed .pd-main {
    margin-left: var(--sidebar-collapsed-width);
  }

  .pd-header {
    padding: var(--space-md);
  }

  .pd-content {
    padding: var(--space-md);
  }
}

/* Mobile: Sidebar as slide-out drawer */
@media (max-width: 768px) {
  /* Mobile sidebar - slides in from left, below site header + close button space */
  .pd-sidebar,
  .pd-sidebar.collapsed {
    position: fixed;
    top: 135px; /* Start below site header + space for close button */
    left: 0;
    width: 280px !important;
    height: calc(100vh - 135px); /* Full height minus header + close button */
    background: #ffffff !important;
    border-right: 1px solid var(--neutral-border);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 90; /* Below site header */
    display: flex;
    flex-direction: column;
  }

  .pd-sidebar.open,
  .pd-sidebar.collapsed.open {
    transform: translateX(0);
  }

  /* Hide menu toggle button when sidebar is open */
  .pd-sidebar.open ~ .pd-mobile-menu-toggle,
  .pd-sidebar.collapsed.open ~ .pd-mobile-menu-toggle {
    display: none !important;
  }

  /* Remove all padding on mobile - content handles its own spacing */
  .pd-main {
    padding: 0;
  }

  /* Mobile close button in sidebar */
  .pd-sidebar__close-mobile {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--neutral-border);
    color: var(--neutral-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
  }

  .pd-sidebar__close-mobile:hover {
    background: var(--neutral-bg-light);
    color: var(--neutral-primary);
  }

  .pd-sidebar__close-mobile svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  /* Hide sidebar header on mobile too - no logo needed */
  .pd-sidebar .pd-sidebar__header,
  .pd-sidebar.collapsed .pd-sidebar__header {
    display: none;
  }

  /* Hide logo on mobile too */
  .pd-sidebar .pd-sidebar__logo-full,
  .pd-sidebar.collapsed .pd-sidebar__logo-full {
    display: none !important;
  }

  .pd-sidebar .pd-sidebar__logo-mini,
  .pd-sidebar.collapsed .pd-sidebar__logo-mini {
    display: none !important;
  }

  .pd-sidebar .pd-sidebar__logo img {
    display: none;
  }

  /* Hide desktop toggle on mobile */
  .pd-sidebar__toggle {
    display: none !important;
  }

  /* Mobile nav styling */
  .pd-sidebar .pd-sidebar__nav,
  .pd-sidebar.collapsed .pd-sidebar__nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
  }

  .pd-sidebar .pd-sidebar__nav-item,
  .pd-sidebar.collapsed .pd-sidebar__nav-item {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 12px;
    padding: 12px 20px !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: 3px solid transparent;
    color: var(--neutral-secondary);
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    transition: all 0.15s ease;
  }

  /* Show text labels on mobile */
  .pd-sidebar .pd-sidebar__nav-item span,
  .pd-sidebar.collapsed .pd-sidebar__nav-item span {
    display: inline !important;
  }

  .pd-sidebar .pd-sidebar__nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .pd-sidebar .pd-sidebar__nav-item:hover,
  .pd-sidebar.collapsed .pd-sidebar__nav-item:hover {
    background: var(--neutral-bg-light);
    color: var(--neutral-primary);
  }

  .pd-sidebar .pd-sidebar__nav-item.active,
  .pd-sidebar.collapsed .pd-sidebar__nav-item.active {
    background: var(--brand-ultra-light);
    color: var(--brand-mid);
    border-left-color: var(--brand-mid);
  }

  /* Hide tooltips on mobile */
  .pd-sidebar .pd-sidebar__nav-item::after,
  .pd-sidebar.collapsed .pd-sidebar__nav-item::after {
    display: none !important;
  }

  /* Mobile sidebar footer */
  .pd-sidebar .pd-sidebar__footer,
  .pd-sidebar.collapsed .pd-sidebar__footer {
    padding: 16px 20px;
    border-top: 1px solid var(--neutral-border);
    margin-top: auto;
  }

  .pd-sidebar .pd-sidebar__user,
  .pd-sidebar.collapsed .pd-sidebar__user {
    display: flex;
    align-items: center;
    justify-content: flex-start !important;
    gap: 12px;
    padding: 0 0 12px 0;
  }

  .pd-sidebar .pd-sidebar__user-avatar,
  .pd-sidebar.collapsed .pd-sidebar__user-avatar {
    width: 40px !important;
    height: 40px !important;
    font-size: 14px !important;
  }

  .pd-sidebar .pd-sidebar__user-info,
  .pd-sidebar.collapsed .pd-sidebar__user-info {
    display: block !important;
  }

  .pd-sidebar .pd-sidebar__logout,
  .pd-sidebar.collapsed .pd-sidebar__logout {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: 8px;
    padding: 10px 12px;
    color: var(--critical);
    font-size: 14px;
    border-radius: 6px;
    transition: background 0.15s ease;
  }

  .pd-sidebar .pd-sidebar__logout span,
  .pd-sidebar.collapsed .pd-sidebar__logout span {
    display: inline !important;
  }

  .pd-sidebar .pd-sidebar__logout:hover {
    background: rgba(223, 27, 27, 0.1);
  }

  /* Main content - full width on mobile */
  .pd-main {
    margin-left: 0 !important;
  }

  .pd-app.sidebar-collapsed .pd-main {
    margin-left: 0 !important;
  }

  .pd-header {
    padding: var(--space-md);
  }

  .pd-content {
    padding: var(--space-md);
  }

  /* Dark overlay when sidebar open */
  .pd-sidebar.open::before,
  .pd-sidebar.collapsed.open::before {
    content: '';
    position: fixed;
    top: 135px; /* Start below site header - matches mobile sidebar */
    left: 280px;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
  }

  /* Adjust mobile menu toggle position */
  .pd-mobile-menu-toggle {
    top: 190px; /* Below mobile site header + button height */
  }
}

/* Mobile content adjustments */
@media (max-width: 768px) {
  .pd-stats {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  .pd-stat-card {
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-md);
    text-align: center;
  }

  .pd-stat-card__value {
    font-size: var(--font-size-xl);
  }

  .pd-stat-card__label {
    font-size: var(--font-size-xs);
  }

  .pd-table {
    display: block;
    overflow-x: auto;
  }

  .pd-grid-2,
  .pd-grid-3 {
    grid-template-columns: 1fr;
  }

  .pd-modal__content {
    margin: var(--space-md);
    max-height: calc(100vh - var(--space-xl));
  }

  /* Adjust card footer buttons for mobile */
  .pd-card__footer {
    flex-direction: column;
  }

  .pd-card__footer .pd-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  :root {
    --space-xl: 1.5rem;
    --space-lg: 1rem;
  }

  /* Keep stats as 2x2 grid on small screens */
  .pd-stats {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  .pd-card__header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .pd-header__title {
    font-size: var(--font-size-lg);
  }

  /* Keep Sign Out visible on mobile */
  .pd-header__actions {
    display: flex !important;
  }

  .pd-btn--sm {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
  }
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.pd-mt-sm { margin-top: var(--space-sm); }
.pd-mt-md { margin-top: var(--space-md); }
.pd-mt-lg { margin-top: var(--space-lg); }
.pd-mt-xl { margin-top: var(--space-xl); }

.pd-mb-sm { margin-bottom: var(--space-sm); }
.pd-mb-md { margin-bottom: var(--space-md); }
.pd-mb-lg { margin-bottom: var(--space-lg); }
.pd-mb-xl { margin-bottom: var(--space-xl); }

.pd-text-center { text-align: center; }
.pd-text-right { text-align: right; }

.pd-text-secondary { color: var(--neutral-secondary); }
.pd-text-success { color: var(--success); }
.pd-text-critical { color: var(--critical); }
.pd-text-attention { color: var(--attention); }

.pd-flex { display: flex; }
.pd-flex-center { align-items: center; }
.pd-flex-between { justify-content: space-between; }
.pd-gap-sm { gap: var(--space-sm); }
.pd-gap-md { gap: var(--space-md); }
.pd-gap-lg { gap: var(--space-lg); }

.pd-grid { display: grid; }
.pd-grid-2 { grid-template-columns: repeat(2, 1fr); }
.pd-grid-3 { grid-template-columns: repeat(3, 1fr); }

.pd-hidden { display: none; }

@media (max-width: 768px) {
  .pd-hide-mobile { display: none; }
}

@media (min-width: 769px) {
  .pd-hide-desktop { display: none; }
}

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */
.pd-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pd-modal.open {
  opacity: 1;
  visibility: visible;
}

.pd-modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.pd-modal__content {
  position: relative;
  background: var(--neutral-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.pd-modal.open .pd-modal__content {
  transform: translateY(0);
}

.pd-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--neutral-border);
}

.pd-modal__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0;
}

.pd-modal__close {
  background: none;
  border: none;
  padding: var(--space-xs);
  color: var(--neutral-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.pd-modal__close:hover {
  background: var(--neutral-bg-light);
  color: var(--neutral-primary);
}

.pd-modal__body {
  padding: var(--space-lg);
}

.pd-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--neutral-border);
  background: var(--neutral-bg-lighter);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Payment Options (radio-style cards) */
.pd-payment-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.pd-payment-option {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border: 2px solid var(--neutral-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pd-payment-option:hover {
  border-color: var(--brand-light);
  background: var(--brand-ultra-light);
}

.pd-payment-option.selected {
  border-color: var(--brand-mid);
  background: var(--brand-ultra-light);
}

.pd-payment-option__radio {
  width: 20px;
  height: 20px;
  border: 2px solid var(--neutral-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pd-payment-option.selected .pd-payment-option__radio {
  border-color: var(--brand-mid);
}

.pd-payment-option.selected .pd-payment-option__radio::after {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--brand-mid);
  border-radius: 50%;
}

.pd-payment-option__icon {
  width: 48px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-bg-light);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.pd-payment-option__details {
  flex: 1;
}

.pd-payment-option__brand {
  font-weight: 500;
}

.pd-payment-option__number {
  font-size: var(--font-size-sm);
  color: var(--neutral-secondary);
}

/* Divider with text */
.pd-divider {
  display: flex;
  align-items: center;
  color: var(--neutral-secondary);
  font-size: var(--font-size-sm);
}

.pd-divider::before,
.pd-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--neutral-border);
}

.pd-divider span {
  padding: 0 var(--space-md);
}

/* Static input display */
.pd-input-static {
  padding: var(--space-sm) var(--space-md);
  background: var(--neutral-bg-light);
  border-radius: var(--radius-md);
  font-weight: 500;
  color: var(--neutral-primary);
}

/* Alerts */
.pd-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.pd-alert svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.pd-alert--info {
  background: var(--info-light);
  color: var(--info-dark);
}

.pd-alert--warning {
  background: var(--attention-light);
  color: var(--attention-dark);
}

.pd-alert--success {
  background: var(--success-light);
  color: var(--success-dark);
}

.pd-alert--error {
  background: var(--critical-light);
  color: var(--critical-dark);
}

/* Loading Overlay */
.pd-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

/* Empty States (alternate styling) */
.pd-empty-state {
  text-align: center;
  padding: var(--space-2xl);
}

.pd-empty-state__icon {
  color: var(--neutral-disabled);
  margin-bottom: var(--space-md);
}

.pd-empty-state__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.pd-empty-state__description {
  color: var(--neutral-secondary);
  max-width: 400px;
  margin: 0 auto;
}

/* Card body no padding variant */
.pd-card__body--no-padding {
  padding: 0;
}

/* Payment methods list */
.pd-payment-methods-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Sections */
.pd-section {
  margin-bottom: var(--space-lg);
}

.pd-section__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--neutral-primary);
  margin-bottom: var(--space-md);
}

/* ==========================================================================
   Mobile-First Improvements for Elderly Patients
   - Larger fonts (18px base on mobile)
   - 44px minimum touch targets
   - Stacked layouts on mobile
   - Table-to-card conversion
   ========================================================================== */

/* --------------------------------------------------------------------------
   Detail Page Layout (Subscription/Order Details)
   Replaces inline style="grid-template-columns: 1fr 300px;"
   -------------------------------------------------------------------------- */
.pd-detail-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--space-lg);
}

/* Ensure children fill their grid cells */
.pd-detail-layout > div {
  min-width: 0; /* Prevent grid blowout */
  width: 100%;
}

/* Cards in detail layout should fill available width */
.pd-detail-layout .pd-card {
  width: 100%;
}

@media (max-width: 768px) {
  .pd-detail-layout {
    grid-template-columns: 1fr;
  }

  /* Sidebar content (payment method, addresses) comes after main on mobile */
  .pd-detail-layout > div:last-child {
    order: 0;
  }
}

/* --------------------------------------------------------------------------
   Mobile Typography & Touch Targets (Elderly-Friendly)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Increase base font size for elderly readability */
  html {
    font-size: 18px;
  }

  /* Larger buttons with 44px minimum touch target */
  .pd-btn {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-base);
  }

  .pd-btn--sm {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
  }

  /* Larger badges on mobile for readability */
  .pd-badge {
    padding: 4px 12px;
    font-size: var(--font-size-sm);
  }

  /* Back link improvements - larger touch target */
  .pd-back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    min-height: 44px;
    padding: var(--space-sm);
    margin: 0 calc(-1 * var(--space-sm));
    font-size: var(--font-size-base);
    color: var(--neutral-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: background 0.15s ease, color 0.15s ease;
  }

  .pd-back-link:hover {
    background: var(--neutral-bg-light);
    color: var(--brand-mid);
    text-decoration: none;
  }
}

/* Back link base styles (desktop) */
.pd-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--neutral-secondary);
  font-size: var(--font-size-sm);
  text-decoration: none;
  padding: var(--space-xs) 0;
  transition: color 0.15s ease;
}

.pd-back-link:hover {
  color: var(--brand-mid);
  text-decoration: none;
}

.pd-back-link svg {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Mobile Table-to-Card Conversion
   Tables convert to stacked cards on mobile/tablet for easier reading
   Using 1024px breakpoint to cover more devices
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  /* Hide table headers on mobile */
  .pd-table--mobile-cards thead {
    display: none;
  }

  .pd-table--mobile-cards tbody {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: 0 var(--space-sm);
  }

  .pd-table--mobile-cards tr {
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    background: var(--neutral-white);
    border: 1px solid var(--neutral-border);
    border-radius: var(--radius-md);
  }

  .pd-table--mobile-cards td {
    display: flex;
    flex-direction: column;  /* Stack label above value */
    align-items: flex-start; /* Left-align */
    gap: var(--space-xs);    /* Small gap between label and value */
    padding: var(--space-sm) 0;
    border-bottom: none;
  }

  .pd-table--mobile-cards td:last-child {
    border-bottom: none;
    padding-top: var(--space-xs);
  }

  /* Reduce card body padding on mobile for mobile-card tables only */
  .pd-card__body--no-padding:has(.pd-table--mobile-cards) {
    padding: var(--space-sm) 0;
  }

  /* Add labels before each cell value on mobile */
  .pd-table--mobile-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--neutral-secondary);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  /* Action buttons take full width on mobile */
  .pd-table--mobile-cards td:last-child .pd-btn {
    width: 100%;
    justify-content: center;
  }

  /* Hide data-label on action column */
  .pd-table--mobile-cards td[data-label=""]::before {
    display: none;
  }

  /* Right-aligned text cells need special handling */
  .pd-table--mobile-cards td.pd-text-right {
    text-align: left;
  }
}

/* --------------------------------------------------------------------------
   Subscription Card - Mobile (Clean Rewrite)
   Simple stacked layout without width issues
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pd-subscription-card {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
    padding: var(--space-md);
  }

  .pd-subscription-card__image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
  }

  .pd-subscription-card__content {
    width: 100%;
  }

  .pd-subscription-card__header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .pd-subscription-card__meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-top: var(--space-md);
  }

  .pd-subscription-card__meta-item {
    flex-direction: row;
    gap: var(--space-sm);
  }

  /* Details link on its own line on mobile */
  .pd-subscription-card__meta .pd-details-link {
    margin-top: var(--space-sm);
  }
}

/* --------------------------------------------------------------------------
   Info Grid Stacking (Mobile)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pd-grid-2,
  .pd-grid-3 {
    grid-template-columns: 1fr !important;
    gap: var(--space-sm);
  }

  /* Make info items more readable on mobile */
  .pd-grid-2 > div,
  .pd-grid-3 > div {
    padding: var(--space-md);
    background: var(--neutral-bg-lighter);
    border-radius: var(--radius-md);
  }
}

/* --------------------------------------------------------------------------
   Stat Cards (Dashboard Home) - Better Mobile Layout
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pd-stat-card {
    padding: var(--space-md);
  }

  .pd-stat-card__icon {
    width: 40px;
    height: 40px;
  }

  .pd-stat-card__icon svg {
    width: 20px;
    height: 20px;
  }

  .pd-stat-card__value {
    font-size: var(--font-size-xl);
  }

  .pd-stat-card__label {
    font-size: var(--font-size-sm);
  }
}

/* --------------------------------------------------------------------------
   Welcome Section (Dashboard Home) - Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pd-welcome__title {
    font-size: var(--font-size-xl);
  }

  .pd-welcome__subtitle {
    font-size: var(--font-size-base);
  }
}

/* --------------------------------------------------------------------------
   Card Footer Buttons - Mobile Stacking
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pd-card__footer {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .pd-card__footer .pd-btn {
    width: 100%;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Modal Improvements - Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pd-modal__content {
    margin: var(--space-md);
    max-height: calc(100vh - var(--space-lg));
    border-radius: var(--radius-lg);
  }

  .pd-modal__footer {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .pd-modal__footer .pd-btn {
    width: 100%;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Payment Method Cards - Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pd-payment-method {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .pd-payment-method__actions {
    width: 100%;
    display: flex;
    gap: var(--space-sm);
  }

  .pd-payment-method__actions .pd-btn {
    flex: 1;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Table Footer (Totals) - Mobile Improvements
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pd-table tfoot td {
    padding: var(--space-sm) var(--space-md);
  }

  .pd-table tfoot tr:last-child td {
    padding-top: var(--space-md);
    font-size: var(--font-size-lg);
  }
}

/* --------------------------------------------------------------------------
   Mobile Header Improvements
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Hide page title on mobile (Dashboard, Orders, etc.) */
  .pd-header__title {
    display: none;
  }

  /* Keep header bar visible with menu and sign out */
  .pd-header {
    justify-content: space-between;
  }

  /* Make sure Sign Out is visible on mobile */
  .pd-header__actions {
    display: flex !important;
  }

  .pd-header__logout {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
  }
}

/* --------------------------------------------------------------------------
   Clickable Order/Subscription Numbers in Tables
   Hide 'Details' button on mobile when number is clickable
   -------------------------------------------------------------------------- */
.pd-table-link {
  color: var(--brand-mid);
  font-weight: 600;
  text-decoration: none;
}

.pd-table-link:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

@media (max-width: 1024px) {
  /* Hide the Details button column on mobile/tablet */
  .pd-table--mobile-cards td[data-label=""] {
    display: none;
  }

  /* Hide Items column on mobile/tablet for Orders/Subscriptions lists */
  .pd-table--mobile-cards td[data-label="Items"] {
    display: none;
  }

  /* Hide Total/Amount column on mobile for cleaner view */
  .pd-table--mobile-cards td[data-label="Total"] {
    display: none;
  }

  /* Make order/subscription number row more prominent - USE -1 to ensure it's FIRST */
  .pd-table--mobile-cards td[data-label="Order"],
  .pd-table--mobile-cards td[data-label="Subscription"] {
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--neutral-border);
    order: -1;
  }

  .pd-table--mobile-cards td[data-label="Order"] .pd-table-link,
  .pd-table--mobile-cards td[data-label="Subscription"] .pd-table-link {
    font-size: var(--font-size-lg);
  }

  /* Reorder fields: Status before Date/Renewal */
  .pd-table--mobile-cards td[data-label="Status"] {
    order: 2;
  }

  .pd-table--mobile-cards td[data-label="Date"],
  .pd-table--mobile-cards td[data-label="Next Renewal"],
  .pd-table--mobile-cards td[data-label="Started"] {
    order: 3;
  }

  /* Hide Product column on mobile for subscriptions (too long) */
  .pd-table--mobile-cards td[data-label="Product"] {
    display: none;
  }

  /* Hide Amount column on mobile for subscriptions */
  .pd-table--mobile-cards td[data-label="Amount"] {
    display: none;
  }

  /* Remove min-width constraints on tables for mobile */
  .pd-table {
    min-width: 0 !important;
    width: 100%;
  }

  .pd-table th,
  .pd-table td {
    min-width: 0 !important;
  }
}

/* --------------------------------------------------------------------------
   Subscription Detail Button Spacing
   -------------------------------------------------------------------------- */
.pd-card__footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.pd-card__footer .pd-btn {
  margin: 0;
}

@media (max-width: 768px) {
  .pd-card__footer {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .pd-card__footer .pd-btn {
    width: 100%;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Address Element Styling (WooCommerce Addresses)
   The <address> tag is used by WooCommerce for billing/shipping addresses
   -------------------------------------------------------------------------- */
address {
  font-style: normal;
  line-height: 1.6;
}

/* Address within cards - clean readable styling */
.pd-card address,
.woocommerce-Address address {
  font-style: normal;
  line-height: 1.8;
  color: var(--neutral-primary);
}

.pd-card address p,
.woocommerce-Address address p {
  margin: 0;
}

/* Address cards - two column layout on desktop */
.woocommerce-Addresses {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.woocommerce-Address {
  background: var(--neutral-white);
  border: 1px solid var(--neutral-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.woocommerce-Address-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--neutral-border);
}

.woocommerce-Address-title h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin: 0;
}

.woocommerce-Address-title .edit {
  color: var(--brand-mid);
  font-size: var(--font-size-sm);
}

@media (max-width: 768px) {
  .woocommerce-Addresses {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .woocommerce-Address {
    padding: var(--space-md);
  }

  .pd-card address,
  .woocommerce-Address address {
    font-size: var(--font-size-base);
    line-height: 1.8;
  }
}

/* --------------------------------------------------------------------------
   Large Monitor Support - Fluid Content Width
   Allow content to expand and fill available space on large monitors
   -------------------------------------------------------------------------- */

/* Scale padding on larger screens */
@media (min-width: 1400px) {
  .pd-content {
    padding: var(--space-lg) var(--space-xl);
  }
}

@media (min-width: 1600px) {
  .pd-content {
    padding: var(--space-lg) var(--space-2xl);
  }
}

@media (min-width: 1920px) {
  .pd-content {
    padding: var(--space-xl) calc(var(--space-2xl) * 1.5);
  }
}

/* --------------------------------------------------------------------------
   Card Body Table Fix - Ensure tables fill card width
   -------------------------------------------------------------------------- */
.pd-card .pd-table,
.pd-card__body .pd-table,
.pd-card__body--no-padding .pd-table {
  width: 100%;
  table-layout: auto;
}

/* --------------------------------------------------------------------------
   Clickable Cards & Rows
   Make entire cards and table rows clickable for better mobile UX
   -------------------------------------------------------------------------- */
.pd-clickable {
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.pd-clickable:hover {
  background-color: var(--neutral-50);
}

/* Subscription cards - add subtle shadow lift on hover */
.pd-subscription-card.pd-clickable:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Table rows - apply background to all cells */
tr.pd-clickable:hover td {
  background-color: var(--neutral-50);
}

/* --------------------------------------------------------------------------
   Detail Page Items Table - Compact Mobile Style
   Keep the clean table look from tablet on mobile for line items
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Target tables in detail layout that aren't mobile-cards style */
  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) {
    font-size: var(--font-size-sm);
  }

  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) th,
  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) td {
    padding: var(--space-sm) var(--space-md);
  }

  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) th {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--neutral-secondary);
  }

  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) tfoot td {
    padding: var(--space-sm) var(--space-md);
  }

  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) tfoot tr:last-child td {
    font-size: var(--font-size-base);
    padding-top: var(--space-md);
  }

  /* Right-align table content to fill the card better */
  .pd-detail-layout .pd-card__body--no-padding .pd-table:not(.pd-table--mobile-cards),
  .pd-detail-layout .pd-card .pd-table:not(.pd-table--mobile-cards) {
    width: auto;
    margin-left: auto;
  }

  /* Ensure table elements don't force full width */
  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) thead,
  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) tbody,
  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) tfoot,
  .pd-detail-layout .pd-table:not(.pd-table--mobile-cards) tr {
    display: table;
    width: 100%;
  }
}
