/* ==========================================================================
   Eligara Sites Mock – Stylesheet (sites.eligara.ai)
   Follows Apple Human Interface Guidelines (HIG) for iPhone & Mobile Web
   and Material Design 3 Design Tokens
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
  color-scheme: light;
  accent-color: var(--sage-dark);

  /* Typography */
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-body:    'Instrument Sans', -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Palette */
  --paper:        #ece8e0;
  --paper-raised: #f7f4ed;
  --ink:          #28342c;
  --sage:         #c8ccb8;
  --sage-deep:    #b7c4a6;
  --sage-dark:    #4f6b4a;
  --clay:         #3a7460;
  --clay-dark:    #2c5a4a;
  --clay-light:   #4f8a72;

  /* Primary Brand (Moss Teal) */
  --brand:        #3a7460;
  --brand-dark:   #2c5a4a;
  --brand-light:  #4f8a72;
  --brand-tint:   #e4f0ea;

  /* Patient Portal Accent: Warm Amber / Terracotta */
  --patient-accent: #92400e;
  --patient-tint:   #fef3c7;
  --patient-border: #fcd34d;

  /* Text */
  --text-primary:   #28342c;
  --text-secondary: #3d4338;
  --text-muted:     #5c6358;
  --text-subtle:    #8a9184;
  --white:          #ffffff;

  /* Surfaces */
  --surface:       #ece8e0;
  --surface-card:  #f7f4ed;
  --surface-subtle:#e8e4d8;

  /* Borders */
  --border:        #ddd8cc;
  --border-subtle: #e8e4d8;
  --border-brand:  #b7c4a6;

  /* Semantic */
  --success:        #3e6b42;
  --success-bg:     #e7efe0;
  --success-border: #b7c4a6;
  --warning:        #b45309;
  --warning-bg:     #f6edd8;
  --warning-border: #e0c48a;
  --error:          #9b2c2c;
  --error-bg:       #f8eaea;
  --error-border:   #e3b2ab;

  /* Shadows & Radius */
  --shadow-sm:    0 1px 3px rgba(40, 52, 44, 0.08);
  --shadow-md:    0 8px 24px rgba(40, 52, 44, 0.08);
  --shadow-lg:    0 16px 40px rgba(40, 52, 44, 0.12);
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-full:  999px;
  --transition:   0.2s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--surface);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  line-height: 1.5;
  touch-action: manipulation;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ---------- Cross-Portal Demo Switcher Bar ---------- */
.demo-switcher-bar {
  background-color: #24342a;
  color: #d1dcce;
  padding: 0.45rem 1.5rem;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.demo-switcher-bar strong {
  color: #ffffff;
}

.demo-switcher-link {
  color: #a7f3d0;
  text-decoration: underline;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  touch-action: manipulation;
}

.demo-switcher-link:hover {
  color: #ffffff;
}

/* ---------- Top Navigation Bar (iOS HIG Navigation Bar) ---------- */
.sites-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 2rem;
  background-color: rgba(247, 244, 237, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: all var(--transition);
}

.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.nav-logo-text {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-badge {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background-color: var(--brand-tint);
  color: var(--brand-dark);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-brand);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-item {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-item:hover {
  color: var(--brand);
  background-color: var(--brand-tint);
}

.nav-item.active {
  color: var(--brand-dark);
  font-weight: 600;
  background-color: var(--brand-tint);
}

.nav-user-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.notification-bell-btn {
  position: relative;
  width: 44px; /* Apple HIG standard touch target */
  height: 44px;
  border-radius: 50%;
  background-color: var(--paper);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--ink);
  touch-action: manipulation;
}

.notification-bell-btn:active {
  transform: scale(0.92);
}

.notification-bell-btn:hover {
  background-color: var(--brand-tint);
  border-color: var(--border-brand);
}

.bell-badge-count {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: #b8483c;
  color: white;
  font-size: 0.68rem;
  font-weight: 800;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.patient-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background-color: var(--paper);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  min-height: 38px;
}

.patient-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--sage-dark);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---------- Apple HIG iOS Bottom Tab Bar ---------- */
.ios-tab-bar {
  display: none; /* hidden on desktop */
}

/* ---------- Container ---------- */
.sites-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  max-width: 760px;
}

/* ---------- Buttons & Inputs (Apple HIG Touch Targets: 44pt min) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px; /* Apple HIG standard touch target */
  padding: 0.55rem 1.35rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  touch-action: manipulation;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
  opacity: 0.88;
}

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

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

.btn-secondary {
  background-color: var(--surface-card);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background-color: var(--sage);
  border-color: var(--sage-dark);
}

.btn-sm {
  min-height: 40px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
}

.card {
  background-color: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--sage-deep);
}

/* ---------- Case Table & Elements ---------- */
.cases-table-wrap {
  background-color: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cases-table {
  width: 100%;
  border-collapse: collapse;
}

.cases-table th {
  padding: 0.85rem 1.25rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background-color: var(--paper);
  border-bottom: 1px solid var(--border);
}

.cases-table td {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.cases-table tbody tr:hover {
  background-color: rgba(200, 204, 184, 0.25);
}

.case-symbolic-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.inquiry-alert-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
  touch-action: manipulation;
}

/* ---------- Recruiter Inquiry Highlight Card ---------- */
.inquiry-card {
  background: linear-gradient(135deg, #fdfbf7 0%, #f0f7f3 100%);
  border: 2px solid var(--brand);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  position: relative;
}

.inquiry-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-brand);
}

.coordinator-profile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.coordinator-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  flex-shrink: 0;
}

.trial-quote-box {
  background-color: var(--white);
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.6;
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.privacy-guarantee-panel {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background-color: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
}

.sites-footer {
  margin-top: 5rem;
  padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ==========================================================================
   Apple HIG iPhone Form Factor Responsive Rules
   ========================================================================== */

@media (max-width: 768px) {
  body {
    /* Accommodate the fixed iOS bottom tab bar + home indicator safe area */
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 20px));
  }

  /* Compact iOS Top Bar */
  .demo-switcher-bar {
    padding: 0.4rem 0.85rem;
    font-size: 0.72rem;
  }

  .demo-switcher-left {
    display: none; /* Keep switcher clean on small iPhone screen */
  }

  .demo-switcher-bar div:last-child {
    width: 100%;
    text-align: center;
  }

  .sites-nav {
    padding: 0.65rem 1rem;
    padding-top: max(0.65rem, env(safe-area-inset-top, 0px));
  }

  .nav-logo-text {
    font-size: 1.5rem;
  }

  .nav-menu {
    display: none !important; /* Replaced by native bottom tab bar */
  }

  .patient-name-label {
    display: none; /* Icon avatar only on iPhone */
  }

  /* Native Apple HIG Bottom Tab Bar */
  .ios-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(54px + env(safe-area-inset-bottom, 20px));
    padding-bottom: env(safe-area-inset-bottom, 20px);
    background: rgba(247, 244, 237, 0.94);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top: 0.5px solid rgba(40, 52, 44, 0.15);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
  }

  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 48px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s ease, transform 0.1s ease;
    touch-action: manipulation;
  }

  .tab-item:active {
    transform: scale(0.92);
  }

  .tab-item.active {
    color: var(--brand-dark);
  }

  .tab-item.active .tab-icon {
    stroke-width: 2.5;
    color: var(--brand);
  }

  .tab-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
  }

  .tab-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  .tab-badge-count {
    position: absolute;
    top: -4px;
    right: -10px;
    background-color: #b8483c;
    color: white;
    font-size: 0.62rem;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
  }

  /* Inset Grouped iPhone Page Container */
  .sites-container {
    padding: 1.25rem 1rem;
  }

  .page-title {
    font-size: 1.85rem;
  }

  .page-subtitle {
    font-size: 0.9rem;
  }

  /* Cards have 16px radius */
  .card {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
  }

  /* Prevent iOS Safari auto-zoom with 16px font size */
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px !important;
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
    padding: 0.6rem 1.15rem;
    font-size: 0.95rem;
  }

  /* Hero search box stacks cleanly on mobile */
  div[style*="max-width: 760px; margin: 0 auto 3rem"] {
    flex-direction: column !important;
    padding: 1rem !important;
    gap: 0.85rem !important;
  }

  div[style*="max-width: 760px; margin: 0 auto 3rem"] div {
    border-left: none !important;
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0 !important;
  }

  div[style*="max-width: 760px; margin: 0 auto 3rem"] a.btn {
    width: 100% !important;
    min-height: 48px;
  }

  /* Table transforms to iOS Inset Grouped Card Rows */
  .cases-table-wrap {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
  }

  .cases-table, 
  .cases-table thead, 
  .cases-table tbody, 
  .cases-table th, 
  .cases-table td, 
  .cases-table tr {
    display: block;
    width: 100%;
  }

  .cases-table thead {
    display: none; /* Hide header row on phone */
  }

  .cases-table tbody tr {
    background-color: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
  }

  .cases-table tbody tr td {
    padding: 0.35rem 0;
    border-bottom: none;
  }

  .cases-table tbody tr td:last-child {
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 0.5rem;
    text-align: left !important;
  }

  .cases-table tbody tr td:last-child div {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .cases-table tbody tr td:last-child a.btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* Inquiry card on mobile */
  .inquiry-card {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .inquiry-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .js-inquiry-actions {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  .js-inquiry-actions button {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  /* Grid layouts in case detail stack in 1 column */
  div[style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .sites-footer {
    padding-bottom: 2rem;
  }
}
