/* Doctor Serial Cloud — Reusable Premium Components */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  user-select: none;
  outline: none;
}
.btn:focus-visible {
  box-shadow: var(--focus-ring);
}
.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--text-inverse);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-control);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.btn-accent {
  background: var(--accent);
  color: var(--text-inverse);
}
.btn-accent:hover {
  background: var(--accent-hover);
  color: var(--text-inverse);
}
.btn-danger {
  background: var(--danger);
  color: var(--text-inverse);
}
.btn-danger:hover {
  background: var(--danger-hover);
  color: var(--text-inverse);
}
.btn-ghost {
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-divider);
  color: var(--text-primary);
}
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-glass);
}
[data-theme="dark"] .card-glass {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(30, 41, 59, 0.5);
}

/* Stat Cards */
.stat-card {
  position: relative;
  overflow: hidden;
}


.stat-card-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 8px;
  color: var(--text-primary);
}
.stat-card-title {
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.stat-card-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
}
.stat-card-trend.up { color: var(--success); }
.stat-card-trend.down { color: var(--danger); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

.badge-pulse::before {
  content: '';
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: var(--focus-ring);
}
.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Premium Tables */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.table-premium {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  background: var(--bg-surface);
}
.table-premium th {
  padding: 14px 18px;
  background: var(--bg-primary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--bg-border);
  letter-spacing: 0.05em;
}
.table-premium td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--bg-border);
  font-size: 14px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}
.table-premium tr:last-child td {
  border-bottom: none;
}
.table-premium tr:hover td {
  background: var(--bg-divider);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--scrim);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.modal-container {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}
.modal-overlay.active .modal-container {
  transform: scale(1);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
}
.modal-body {
  padding: 24px;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--bg-border);
  background: var(--bg-primary);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-col: column;
  gap: 12px;
  z-index: var(--z-toast);
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  transform: translateY(20px);
  opacity: 0;
  animation: slideIn 0.3s forwards cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--primary); }

.toast-message {
  font-size: 13px;
  font-weight: 500;
}
.toast-undo {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  color: var(--primary);
  cursor: pointer;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-border) 25%, var(--bg-divider) 50%, var(--bg-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}
.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 16px; }
.skeleton-avatar { width: 48px; height: 48px; border-radius: 50%; }

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  border: 2px dashed var(--bg-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}
.empty-state-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 320px;
  margin-bottom: 20px;
}

/* Floating Action Button (FAB) */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xl);
  cursor: pointer;
  transition: all var(--transition-normal);
  z-index: 99;
}
.fab:hover {
  transform: rotate(90deg) scale(1.1);
  background: var(--primary-hover);
}

/* Custom Vanilla JS Autocomplete Dropdown */
.rx-autocomplete-dropdown {
  position: absolute;
  z-index: 1000;
  background: var(--bg-surface);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xl);
  max-height: 250px;
  overflow-y: auto;
  min-width: 200px;
  margin-top: 4px;
}
.rx-autocomplete-item {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rx-autocomplete-item:last-child {
  border-bottom: none;
}
.rx-autocomplete-item:hover,
.rx-autocomplete-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.rx-autocomplete-item-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 12px;
}
.rx-autocomplete-item:hover .rx-autocomplete-item-count,
.rx-autocomplete-item.active .rx-autocomplete-item-count {
  background: var(--bg-surface);
}
