/* ========================================
   PATIENT FORM - MODERNIZED STYLES
   ======================================== */

/* Main Container */
.patient-app {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
}

/* Header */
.patient-app__header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--color-border);
}

.patient-app__title {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 0.5rem 0;
  line-height: 1.2;
}

.patient-app__subtitle {
  font-size: 1.125rem;
  color: var(--color-text-light);
  margin: 0;
  font-weight: 400;
}

/* Progress Bar - Modern Design */
.patient-progress {
  position: relative;
  margin-bottom: 3rem;
  background: var(--color-bg-alt);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.patient-progress__bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: 12px 12px 0 0;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.patient-progress__steps {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  position: relative;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.patient-progress__steps::-webkit-scrollbar {
  display: none;
}

.patient-progress__step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.patient-progress__step:hover {
  transform: translateY(-2px);
}

.patient-progress__step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text-light);
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}

.patient-progress__step-label {
  font-size: 0.75rem;
  color: var(--color-text-light);
  text-align: center;
  line-height: 1.3;
  transition: all 0.2s ease;
}

.patient-progress__step.is-complete .patient-progress__step-number {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
  font-size: 1rem;
  font-weight: 700;
}

.patient-progress__step.is-active .patient-progress__step-number {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.15);
  transform: scale(1.1);
}

.patient-progress__step.is-active .patient-progress__step-label {
  color: var(--color-primary);
  font-weight: 600;
}

/* Form Container */
.patient-form {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.patient-form__stage {
  min-height: 400px;
  margin-bottom: 2rem;
}

.patient-form__stage--success {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-alt);
  border-radius: 12px;
  padding: 2rem;
}

.patient-success-card {
  background: white;
  border-radius: 12px;
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  max-width: 640px;
  width: 100%;
}

.patient-success-card h2 {
  font-size: 1.8rem;
  margin-bottom: 0;
  color: var(--color-primary);
}

/* Step Intro */
.patient-form__intro {
  text-align: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.patient-form__intro-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}

.patient-form__intro h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.5rem 0;
}

.patient-form__intro p {
  font-size: 1rem;
  color: var(--color-text-light);
  margin: 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Sections */
.patient-form__section {
  margin-bottom: 2.5rem;
  padding: 1.5rem;
  background: var(--color-bg-alt);
  border-radius: 8px;
  border: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

.patient-form__section:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.patient-form__section--important {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  position: relative;
}

.patient-form__section--important::before {
  content: '⚠️';
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  opacity: 0.7;
}

.patient-form__section-header {
  margin-bottom: 1.5rem;
}

.patient-form__section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.25rem 0;
}

.patient-form__section-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin: 0;
}

/* Field Layouts */
.patient-form__fields {
  display: grid;
  gap: 1.5rem;
}

.patient-form__fields--single {
  grid-template-columns: 1fr;
}

.patient-form__fields--two {
  grid-template-columns: repeat(2, 1fr);
}

.patient-form__fields--three {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
  .patient-form__fields--two,
  .patient-form__fields--three {
    grid-template-columns: 1fr;
  }
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field--full {
  grid-column: 1 / -1;
}

.field__label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field__label label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.field__required {
  color: var(--color-error);
  font-size: 1rem;
}

.field__control {
  position: relative;
}

.field__control input,
.field__control textarea,
.field__control select {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  background: white;
  border: 2px solid var(--color-border);
  border-radius: 6px;
  transition: all 0.2s ease;
  outline: none;
  box-sizing: border-box;
}

.field__control input:focus,
.field__control textarea:focus,
.field__control select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

.field__control input::placeholder,
.field__control textarea::placeholder {
  color: var(--color-text-lighter);
}

.field__control textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.field__control select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23666' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 12px;
  padding-right: 2.5rem;
  cursor: pointer;
}

.field--searchable .field__control {
  width: 100%;
}

.searchable-select {
  position: relative;
  width: 100%;
}

.searchable-select__control {
  display: flex;
  align-items: center;
  border: 2px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.searchable-select--open .searchable-select__control {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

.field--error .searchable-select__control {
  border-color: var(--color-error);
}

.searchable-select--disabled .searchable-select__control {
  background: var(--color-bg-alt);
  color: var(--color-text-lighter);
}

.searchable-select--loading .searchable-select__control {
  cursor: progress;
  opacity: 0.85;
}

.searchable-select__input {
  flex: 1;
  border: none;
  padding: 0.75rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  background: transparent;
  outline: none;
  min-width: 0;
}

.searchable-select__input:disabled {
  cursor: not-allowed;
}

.searchable-select__toggle,
.searchable-select__clear {
  border: none;
  background: none;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
  cursor: pointer;
  font-size: 1rem;
}

.searchable-select__toggle:disabled,
.searchable-select__clear:disabled {
  cursor: not-allowed;
  color: var(--color-text-lighter);
}

.searchable-select__toggle span {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.searchable-select__clear {
  font-size: 1.25rem;
  line-height: 1;
}

.searchable-select__clear:focus-visible,
.searchable-select__toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.searchable-select__dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  z-index: 20;
}

.searchable-select__list {
  max-height: 260px;
  overflow-y: auto;
}

.searchable-select__option {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.searchable-select__option--active,
.searchable-select__option:hover {
  background: var(--color-bg-alt);
}

.searchable-select__status,
.searchable-select__empty,
.searchable-select__status-note {
  padding: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-text-light);
}

.field__date-picker {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.field__date-picker input[data-datepicker='true'] {
  padding-right: 2.75rem;
  cursor: text;
}

.field__date-button {
  position: absolute;
  right: 0.75rem;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-light);
}

.field__date-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.field__date-button-icon {
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3Cpath d='M8 14h.01M12 14h.01M16 14h.01M8 18h.01M12 18h.01M16 18h.01'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.field--error .field__control input,
.field--error .field__control textarea,
.field--error .field__control select {
  border-color: var(--color-error);
}

.field--error .field__control input:focus,
.field--error .field__control textarea:focus,
.field--error .field__control select:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Display Field */
.field--display .field__display-value {
  padding: 0.75rem 1rem;
  background: var(--color-bg-alt);
  border: 2px solid var(--color-border);
  border-radius: 6px;
  font-weight: 600;
  color: var(--color-primary);
  min-height: 46px;
  display: flex;
  align-items: center;
}

/* Checkbox Field */
.field--checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
}

.field--checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 0.125rem;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.field__checkbox-label {
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text);
  cursor: pointer;
}

.consent-link {
  background: none;
  border: none;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0;
  margin-left: 0.25rem;
  transition: color 0.2s ease;
}

.consent-link:hover {
  color: var(--color-primary-dark);
  text-decoration: none;
}

/* Field Hint & Error */
.field__hint {
  font-size: 0.75rem;
  color: var(--color-text-light);
  line-height: 1.4;
}

.field__error-message {
  font-size: 0.8125rem;
  color: var(--color-error);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.field__error-message::before {
  content: '⚠';
  font-size: 1rem;
}

/* Form Actions */
.patient-form__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.patient-form__actions-spacer {
  flex: 1;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary--large {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-secondary {
  background: white;
  color: var(--color-text);
  border: 2px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-bg-alt);
  border-color: var(--color-text-light);
}

/* Submit Status */
.submit-status {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.5;
  animation: slideDown 0.3s ease;
}

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

.submit-status--success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.submit-status--error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--color-text-light);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-body p {
  margin: 0 0 1rem 0;
  line-height: 1.6;
  color: var(--color-text);
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
}

/* Summary Card */
.summary-card {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.summary-card__section {
  background: var(--color-bg-alt);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.summary-card__label {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 1rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-primary);
}

.summary-card__value {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--color-text);
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.summary-card__value:last-child {
  border-bottom: none;
}

.summary-card__value strong {
  color: var(--color-text-light);
  font-weight: 600;
  display: inline-block;
  min-width: 180px;
}

/* Responsive */
@media (max-width: 768px) {
  .patient-app {
    padding: 1.5rem 1rem;
  }

  .patient-app__title {
    font-size: 1.75rem;
  }

  .patient-app__subtitle {
    font-size: 1rem;
  }

  .patient-form {
    padding: 1.5rem;
  }

  .patient-progress {
    padding: 1rem;
  }

  .patient-progress__steps {
    justify-content: flex-start;
    gap: 0.75rem;
  }

  .patient-progress__step {
    flex: 0 0 auto;
    min-width: 48px;
  }

  .patient-progress__step-number {
    margin: 0;
  }

  .patient-progress__step-label {
    display: none;
  }

  .patient-form__section {
    padding: 1.25rem;
  }

  .patient-form__actions {
    flex-direction: column-reverse;
    gap: 0.75rem;
  }

  .patient-form__actions button {
    width: 100%;
  }

  .patient-form__actions-spacer {
    display: none;
  }

  .summary-card__value strong {
    display: block;
    min-width: auto;
    margin-bottom: 0.25rem;
  }

  /* Виправлення полів для мобільних */
  .field__control input,
  .field__control textarea,
  .field__control select {
    font-size: 16px;
    padding: 0.625rem 0.875rem;
  }

  .field__control textarea {
    min-height: 100px;
  }

  /* Модалка на планшетах */
  .modal-content {
    max-width: 90%;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  .patient-app {
    padding: 1rem 0.5rem;
  }

  .patient-app__title {
    font-size: 1.5rem;
  }

  .patient-form {
    padding: 1rem;
  }

  .patient-form__intro h2 {
    font-size: 1.5rem;
  }

  .patient-form__section {
    padding: 1rem;
  }

  /* Додаткові виправлення для дуже малих екранів */
  .field__control input,
  .field__control textarea,
  .field__control select {
    font-size: 16px;
    padding: 0.5rem 0.75rem;
  }

  .field__checkbox-label {
    font-size: 0.8125rem;
    line-height: 1.4;
  }

  .btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
  }

  /* Модалка на малих екранах */
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-content {
    max-width: 100%;
    max-height: 95vh;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }

  .modal-title {
    font-size: 1.125rem;
  }

  .consent-link {
    display: block;
    margin-top: 0.25rem;
    margin-left: 0;
  }
}
