:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-card: rgba(22, 31, 51, 0.75);
  --bg-card-hover: rgba(30, 42, 69, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #3b82f6 50%, #06b6d4 100%);
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-purple: #a855f7;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.15);
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

.app-container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header .subtitle {
  font-size: 0.825rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.drive-folder-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.drive-folder-link:hover {
  background: rgba(16, 185, 129, 0.25);
  color: #ffffff;
  border-color: #34d399;
  transform: translateY(-1px);
}

.stats-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--accent-cyan);
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Search Section */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
}

.search-box input {
  width: 100%;
  padding: 16px 48px 16px 50px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1.05rem;
  font-family: inherit;
  outline: none;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-glow);
}

.search-box input:focus {
  border-color: var(--border-focus);
  background: rgba(22, 31, 51, 0.95);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2), 0 0 30px rgba(99, 102, 241, 0.25);
}

.search-box input:focus + .search-icon {
  color: var(--accent-cyan);
}

.clear-btn {
  position: absolute;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.clear-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.search-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-container {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-container input {
  display: none;
}

.toggle-slider {
  width: 38px;
  height: 22px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  position: relative;
  transition: background-color 0.25s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.25s;
}

.toggle-container input:checked + .toggle-slider {
  background: var(--accent-gradient);
}

.toggle-container input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.result-count {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  }
}

.patient-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.patient-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.2s;
}

.patient-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.patient-card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.patient-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
}

.patient-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-sex, .badge-age, .badge-folder {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.badge-sex.F {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.3);
}

.badge-sex.M {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

/* File / ID Section */
.file-info-box {
  background: rgba(11, 15, 25, 0.7);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.file-name-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-cyan);
  word-break: break-all;
  line-height: 1.3;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-copy:hover {
  background: rgba(99, 102, 241, 0.3);
  color: #ffffff;
  border-color: var(--accent-cyan);
  transform: scale(1.02);
}

.btn-copy:active {
  transform: scale(0.98);
}

.btn-drive {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  font-size: 0.825rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-drive:hover {
  background: rgba(16, 185, 129, 0.3);
  color: #ffffff;
  border-color: #34d399;
  transform: scale(1.02);
}

.btn-drive:active {
  transform: scale(0.98);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 4px;
}

.empty-state h3 {
  font-size: 1.2rem;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 420px;
}

.quick-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

.tag-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tag-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
  border-color: var(--border-focus);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #10b981;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.hidden {
  display: none !important;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .stats-badge {
    align-self: flex-start;
  }

  .search-box input {
    font-size: 0.95rem;
    padding: 14px 40px 14px 44px;
  }

  .patient-card {
    padding: 14px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
