@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

:root {
  color-scheme: light;
  /* Color Palette - HSL */
  --p-indigo: 226, 70%, 25%;    /* #12286D - Deep Indigo */
  --p-indigo-soft: 226, 40%, 95%;
  --p-teal: 164, 71%, 38%;      /* #1DB992 - Fresh Teal */
  --p-teal-soft: 164, 40%, 96%;
  --p-gray: 210, 10%, 45%;
  --p-gray-light: 210, 15%, 95%;
  --p-gray-border: 210, 15%, 88%;
  --p-red: 0, 75%, 60%;
  --p-bg: 0, 0%, 100%;
  
  /* Brand Tokens */
  --brand-primary: hsl(var(--p-indigo));
  --brand-accent: hsl(var(--p-teal));
  --brand-bg: hsl(var(--p-bg));
  --brand-surface: hsl(var(--p-indigo-soft));
  
  /* Status Colors */
  --status-success: hsl(var(--p-teal));
  --status-pending: hsl(var(--p-gray));
  --status-error: hsl(var(--p-red));
  
  /* Typography */
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  
  /* Shadows & Spacing */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --spacing-base: 16px;
  
  /* Safe Area */
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: hsl(var(--p-gray-light));
  color: #1a1a1a;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: calc(70px + var(--safe-bottom)); /* For bottom nav */
}

/* Typography Scale */
h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; color: var(--brand-primary); }
h2 { font-size: 1.25rem; font-weight: 700; color: #333; }
h3 { font-size: 1rem; font-weight: 700; color: #444; }
p { font-size: 0.95rem; }
.caption { font-size: 0.8rem; color: hsl(var(--p-gray)); font-weight: 500; }

/* Layout Containers */
.app-container {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
}

/* Sticky Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid hsl(var(--p-gray-border));
}

.header-logo {
  display: flex;
  align-items: center;
  min-width: 0;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  text-align: right;
}

/* Hero Section */
.hero {
  padding: 2rem 1.25rem;
  background: white;
}

.view-panel {
  padding-bottom: 1rem;
}

/* Card Component */
.card {
  background: white;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid hsl(var(--p-gray-border));
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:active {
  transform: scale(0.98);
}

.card.is-done {
  border-left: 6px solid var(--status-success);
}

/* Form Elements */
.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--brand-primary);
}

input, textarea, select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1.5px solid hsl(var(--p-gray-border));
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: hsl(var(--p-gray-light));
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px hsla(var(--p-indigo), 0.1);
  background: white;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  gap: 0.5rem;
}

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

.btn-primary:active {
  background: hsl(226, 70%, 20%);
  transform: translateY(1px);
}

.btn-secondary {
  background: hsl(var(--p-gray-light));
  color: var(--brand-primary);
  border: 1px solid hsl(var(--p-gray-border));
}

.btn-block {
  width: 100%;
}

.btn-compact {
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(70px + var(--safe-bottom));
  background: white;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid hsl(var(--p-gray-border));
  z-index: 500;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.03);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: hsl(var(--p-gray));
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  gap: 4px;
  cursor: pointer;
}

.nav-item.is-active {
  color: var(--brand-primary);
}

.nav-item .icon {
  width: 24px;
  height: 24px;
  opacity: 0.6;
}

.nav-item.is-active .icon {
  opacity: 1;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-lg);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.badge-success { background: hsl(var(--p-teal-soft)); color: var(--status-success); }
.badge-pending { background: hsl(var(--p-gray-light)); color: var(--status-pending); }

/* Utilities */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.text-center { text-align: center; }

.subtab-bar {
  overflow-x: auto;
  align-items: stretch;
}

.subtab-bar .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* QR Scanner UI Overlay */
#portable-camera-preview {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: #000;
}

/* Patient List Styles */
.patient-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.patient-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.patient-info {
  display: flex;
  flex-direction: column;
}

.patient-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--brand-primary);
}

.patient-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.meta-chip {
  background: hsl(var(--p-gray-light));
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--p-gray));
}
