.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px var(--color-primary-50);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-gray-400);
}

.form-input--error {
  border-color: var(--color-danger-500);
}

.form-input--error:focus {
  border-color: var(--color-danger-500);
  box-shadow: 0 0 0 3px var(--color-danger-50);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger-500);
  margin-top: var(--space-1);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-checkbox,
.form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.form-checkbox input[type="checkbox"],
.form-radio input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary-600);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.field_with_errors .form-input,
.field_with_errors .form-select,
.field_with_errors .form-textarea {
  border-color: var(--color-danger-500);
}

.field_with_errors .form-input:focus,
.field_with_errors .form-select:focus,
.field_with_errors .form-textarea:focus {
  border-color: var(--color-danger-500);
  box-shadow: 0 0 0 3px var(--color-danger-50);
}

.field_with_errors .form-label {
  color: var(--color-danger-600);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .form-input:focus,
  :root:not([data-theme="light"]) .form-select:focus,
  :root:not([data-theme="light"]) .form-textarea:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  }
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Pre-Anesthetic Wizard Styling */
.wizard-container {
  margin-top: var(--space-4);
}

.wizard-header {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.wizard-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: var(--space-3);
}

.wizard-save-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: all 250ms ease;
  background: var(--color-gray-50);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

:root[data-theme="dark"] .wizard-save-status {
  background: var(--color-gray-800);
}

.wizard-save-status--saving {
  color: var(--color-warning-600);
  border: 1px dashed var(--color-warning-200);
}

.wizard-save-status--saved {
  color: var(--color-success-600);
  border: 1px solid var(--color-success-200);
  background: var(--color-success-50);
}

:root[data-theme="dark"] .wizard-save-status--saved {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.2);
}

.wizard-save-status--error {
  color: var(--color-danger-600);
  border: 1px solid var(--color-danger-200);
  background: var(--color-danger-50);
}

:root[data-theme="dark"] .wizard-save-status--error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}

.wizard-save-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--color-warning-200);
  border-top-color: var(--color-warning-600);
  border-radius: 50%;
  animation: wizardSpin 1s linear infinite;
}

@keyframes wizardSpin {
  to { transform: rotate(360deg); }
}

.wizard-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  width: 100%;
}

.wizard-progress-line {
  position: absolute;
  top: 15px;
  left: 10%;
  height: 3px;
  background: var(--color-border-light);
  width: 80%;
  z-index: 1;
}

.wizard-progress-bar {
  height: 100%;
  background: var(--color-primary-500);
  width: 0%;
  transition: width 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

.wizard-step-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  flex: 1;
  cursor: pointer;
}

.wizard-step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all 250ms ease;
}

.wizard-step-node--active .wizard-step-circle {
  border-color: var(--color-primary-500);
  background: var(--color-surface);
  color: var(--color-primary-700);
  box-shadow: 0 0 0 4px var(--color-primary-50);
}

:root[data-theme="dark"] .wizard-step-node--active .wizard-step-circle {
  background: var(--color-surface);
  color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.wizard-step-node--completed .wizard-step-circle {
  border-color: var(--color-success-500);
  background: var(--color-success-500);
  color: #fff;
}

.wizard-step-label {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: center;
  transition: color 250ms ease;
}

.wizard-step-node--active .wizard-step-label {
  color: var(--color-primary-600);
}

:root[data-theme="dark"] .wizard-step-node--active .wizard-step-label {
  color: #60a5fa;
}

.wizard-step-node--completed .wizard-step-label {
  color: var(--color-success-600);
}

/* Steps content */
.wizard-step-content {
  display: none;
  animation: wizardFadeIn 300ms ease-in-out forwards;
}

.wizard-step-content--active {
  display: block;
}

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

.wizard-step-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-6);
  border-top: 1px solid var(--color-border-light);
  padding-top: var(--space-4);
}

@media (max-width: 640px) {
  .wizard-header {
    padding: var(--space-4) var(--space-3);
    gap: var(--space-3);
  }

  .wizard-step-circle {
    width: 28px;
    height: 28px;
    font-size: var(--text-xs);
  }

  .wizard-progress-line {
    top: 13px;
  }

  .wizard-step-node:not(.wizard-step-node--active) .wizard-step-label {
    display: none;
  }

  .wizard-step-node--active .wizard-step-label {
    display: block;
    position: absolute;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-primary-600);
    background: var(--color-surface);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    z-index: 10;
  }

  :root[data-theme="dark"] .wizard-step-node--active .wizard-step-label {
    color: #60a5fa;
    background: var(--color-gray-900);
    border-color: var(--color-gray-800);
  }
}

@media (max-width: 480px) {
  .wizard-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  .wizard-save-status {
    align-self: flex-start;
  }
}

/* Custom Searchable Dropdown CSS */
.anesflow-select-custom-wrapper {
  position: relative;
  width: 100%;
}

.anesflow-select-custom-trigger {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.anesflow-select-custom-trigger:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px var(--color-primary-50);
}

[data-theme="dark"] .anesflow-select-custom-trigger:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.anesflow-select-custom-trigger::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--color-gray-500);
  border-bottom: 2px solid var(--color-gray-500);
  transform: rotate(45deg) translateY(-2px);
  margin-left: 8px;
  transition: transform var(--transition-fast);
}

.anesflow-select-custom-wrapper--open .anesflow-select-custom-trigger::after {
  transform: rotate(-135deg) translateY(2px) translateX(-2px);
}

.anesflow-select-custom-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin-top: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: dropdownFadeIn var(--transition-fast) forwards;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.anesflow-select-custom-wrapper--open .anesflow-select-custom-dropdown {
  display: flex;
}

.anesflow-select-custom-search-container {
  padding: 8px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-gray-50);
}

[data-theme="dark"] .anesflow-select-custom-search-container {
  background: var(--color-gray-800);
}

.anesflow-select-custom-search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-text);
  background: var(--color-surface);
}

.anesflow-select-custom-search:focus {
  outline: none;
  border-color: var(--color-primary-500);
}

.anesflow-select-custom-options {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.anesflow-select-custom-option {
  padding: 8px 12px;
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.anesflow-select-custom-option:hover {
  background: var(--color-gray-100);
}

[data-theme="dark"] .anesflow-select-custom-option:hover {
  background: var(--color-gray-800);
}

.anesflow-select-custom-option--selected {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
  font-weight: 600;
}

[data-theme="dark"] .anesflow-select-custom-option--selected {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.anesflow-select-custom-option--no-results {
  padding: 8px 12px;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-align: center;
  font-style: italic;
}

/* Dark mode date/datetime calendar picker icon color */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
:root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator,
:root:not([data-theme="light"]) input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}


