/* CaseLog — Design System */
/* Precision medical instrumentation aesthetic */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ── */
:root {
  --steel-900:    #0D1117;
  --steel-800:    #161B22;
  --steel-750:    #1C2128;
  --steel-700:    #21262D;
  --steel-600:    #30363D;
  --steel-500:    #484F58;
  --steel-400:    #6E7681;

  --accent-blue:  #2F81F7;
  --accent-blue-dim: #1F5FA6;
  --accent-green: #3FB950;
  --accent-amber: #F0883E;
  --accent-red:   #F85149;
  --accent-purple:#BC8CFF;
  --accent-cyan:  #79C0FF;

  /* Procedure category colors (signature element) */
  --cat-fracture:    #F0883E;  /* amber */
  --cat-joint:       #2F81F7;  /* blue */
  --cat-spine:       #BC8CFF;  /* purple */
  --cat-hand:        #3FB950;  /* green */
  --cat-pediatric:   #79C0FF;  /* cyan */
  --cat-arthroscopy: #F85149;  /* red */
  --cat-trauma:      #E3B341;  /* yellow */
  --cat-other:       #6E7681;  /* muted */

  --text-primary: #E6EDF3;
  --text-secondary:#C9D1D9;
  --text-muted:   #8B949E;
  --text-subtle:  #484F58;

  --border:       #30363D;
  --border-subtle:#21262D;

  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --radius-xl:    20px;

  --nav-height:   64px;
  --header-height:56px;

  --shadow-card:  0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.7);
}

/* Light mode overrides */
[data-theme="light"] {
  --steel-900:    #FFFFFF;
  --steel-800:    #F6F8FA;
  --steel-750:    #EAEEF2;
  --steel-700:    #D0D7DE;
  --steel-600:    #BFC7D0;
  --steel-500:    #9198A1;
  --steel-400:    #656C76;
  --text-primary: #1F2328;
  --text-secondary:#36393D;
  --text-muted:   #636C76;
  --text-subtle:  #9198A1;
  --border:       #D0D7DE;
  --border-subtle:#EAEEF2;
  --shadow-card:  0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--steel-900);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; }
h4 { font-size: 0.875rem; font-weight: 600; }

.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }

/* ── Layout Shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  background: var(--steel-900);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.page-content {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(var(--nav-height) + 1rem);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--nav-height);
  background: var(--steel-800);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  color: var(--text-subtle);
  text-decoration: none;
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-item svg { width: 22px; height: 22px; }

.nav-item.active {
  color: var(--accent-blue);
}

.nav-item:active { opacity: 0.7; }

/* ── Cards ── */
.card {
  background: var(--steel-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-card);
}

/* Signature: procedure category left border */
.case-card {
  position: relative;
  padding-left: 1.25rem;
  border-left: none;
  overflow: hidden;
}

.case-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}

.case-card[data-category="Complex Fracture"]::before  { background: var(--cat-fracture); }
.case-card[data-category="Joint Replacement"]::before { background: var(--cat-joint); }
.case-card[data-category="Spine"]::before             { background: var(--cat-spine); }
.case-card[data-category="Hand"]::before              { background: var(--cat-hand); }
.case-card[data-category="Pediatric"]::before         { background: var(--cat-pediatric); }
.case-card[data-category="Arthroscopy"]::before       { background: var(--cat-arthroscopy); }
.case-card[data-category="Trauma"]::before            { background: var(--cat-trauma); }
.case-card[data-category="Other"]::before             { background: var(--cat-other); }

.case-card + .case-card { margin-top: 0.75rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover { background: #388bfd; }

.btn-secondary {
  background: var(--steel-700);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--steel-600); }

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem;
}
.btn-ghost:hover { background: var(--steel-700); color: var(--text-primary); }

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
}

.btn-block { width: 100%; }

/* FAB — Floating Action Button */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 1rem);
  right: 1rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(47, 129, 247, 0.4);
  transition: all 0.2s ease;
  z-index: 30;
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 24px; height: 24px; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  letter-spacing: 0.02em;
}

.form-label .required { color: var(--accent-red); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--steel-750);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  padding: 0.625rem 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.15);
}

.form-input::placeholder { color: var(--text-subtle); }
.form-textarea { min-height: 96px; resize: vertical; }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238B949E' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.5rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--accent-red);
  margin-top: 0.25rem;
}

/* ── Badges / Tags ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-blue   { background: rgba(47,129,247,0.15);  color: var(--accent-blue); }
.badge-green  { background: rgba(63,185,80,0.15);   color: var(--accent-green); }
.badge-amber  { background: rgba(240,136,62,0.15);  color: var(--accent-amber); }
.badge-red    { background: rgba(248,81,73,0.15);   color: var(--accent-red); }
.badge-purple { background: rgba(188,140,255,0.15); color: var(--accent-purple); }
.badge-muted  { background: var(--steel-700);       color: var(--text-muted); }

/* Category badges */
.cat-badge { font-family: var(--font-mono); font-size: 0.625rem; }
.cat-fracture   { background: rgba(240,136,62,0.15);  color: var(--cat-fracture); }
.cat-joint      { background: rgba(47,129,247,0.15);  color: var(--cat-joint); }
.cat-spine      { background: rgba(188,140,255,0.15); color: var(--cat-spine); }
.cat-hand       { background: rgba(63,185,80,0.15);   color: var(--cat-hand); }
.cat-pediatric  { background: rgba(121,192,255,0.15); color: var(--cat-pediatric); }
.cat-arthroscopy{ background: rgba(248,81,73,0.15);   color: var(--cat-arthroscopy); }
.cat-trauma     { background: rgba(227,179,65,0.15);  color: var(--cat-trauma); }
.cat-other      { background: var(--steel-700);       color: var(--text-muted); }

/* Case status */
.status-active    { color: var(--accent-blue); }
.status-completed { color: var(--accent-green); }
.status-complicated { color: var(--accent-red); }
.status-closed    { color: var(--text-muted); }

/* ── Dividers ── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 1rem 0;
}

/* ── Stats / Metrics ── */
.stat-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ── Modals / Sheets ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-sheet {
  background: var(--steel-800);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--steel-500);
  border-radius: 2px;
  margin: 0 auto 1.25rem;
}

/* ── Loading / Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--steel-700) 25%, var(--steel-600) 50%, var(--steel-700) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: 0.75rem;
}

.empty-state svg { color: var(--text-subtle); opacity: 0.5; }
.empty-state h3 { color: var(--text-secondary); }
.empty-state p  { color: var(--text-muted); font-size: 0.875rem; max-width: 24ch; }

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: calc(100% - 2rem);
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: var(--steel-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-modal);
  animation: toast-in 0.3s ease;
  pointer-events: auto;
}

.toast-success { border-left: 3px solid var(--accent-green); }
.toast-error   { border-left: 3px solid var(--accent-red); }
.toast-info    { border-left: 3px solid var(--accent-blue); }
.toast-warning { border-left: 3px solid var(--accent-amber); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Search Bar ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--steel-750);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.875rem;
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.9375rem;
  width: 100%;
}
.search-bar input::placeholder { color: var(--text-subtle); }
.search-bar svg { color: var(--text-subtle); flex-shrink: 0; }

/* ── Photo Grid ── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.photo-thumb {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--steel-700);
  cursor: pointer;
  transition: opacity 0.15s;
}
.photo-thumb:active { opacity: 0.7; }

.photo-add {
  aspect-ratio: 1;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
  color: var(--text-subtle);
  font-size: 0.6875rem;
  transition: all 0.15s;
}
.photo-add:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

/* ── Financial Summary ── */
.financial-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.875rem;
}

.financial-row + .financial-row {
  border-top: 1px solid var(--border-subtle);
}

.financial-row.total {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.financial-row.due { color: var(--accent-red); }
.financial-row.paid { color: var(--accent-green); }

/* ── Utility ── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.p-0 { padding: 0; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
