/* ===========================================
   ОБЩИЕ ПЕРЕМЕННЫЕ И СБРОС СТИЛЕЙ
   =========================================== */
:root{
  --sr-line:#e9ecef;
  --sr-line-focus:#a8a8a8;
  --sr-text:#212529;
  --sr-muted:#8e9499;
  --sr-fill:#f6f7f9;
  --sr-radius:.6rem;
  --sr-success:#28a745;
  --sr-warning:#ffc107;
  --sr-info:#17a2b8;
  --sr-error:#dc3545;
}

/* Защита от горизонтального скролла и единая модель размеров */
*, *::before, *::after { 
  box-sizing: border-box; 
}


/* ===========================================
   МОДАЛЬНЫЕ ОКНА В СТИЛЕ SMART RECOVERY
   =========================================== */

/* Повышаем z-index для модалок */
.modal { 
  z-index: 2000 !important; 
}

.modal-backdrop { 
  z-index: 1990 !important; 
  background-color: rgba(0, 0, 0, 0.5);
}

/* Контейнер модального окна */
.modal-dialog {
  max-width: 840px;
  margin: 1.75rem auto;
}

.modal-content {
  border: none;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

/* Анимация появления */
.modal.fade .modal-dialog {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
}

.modal.show .modal-dialog {
  opacity: 1;
  transform: translateY(0);
}

/* ===========================================
   HEADER МОДАЛЬНОГО ОКНА
   =========================================== */
.modal-header {
  border: 0;
  padding: 28px 32px 20px;
  background: transparent;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--sr-text);
  margin: 0;
  line-height: 1.3;
}

.modal-header .btn-close {
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  opacity: 0.5;
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23212529'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
}

.modal-header .btn-close:hover {
  opacity: 1;
  transform: rotate(90deg);
}

.modal-header .btn-close:focus {
  box-shadow: none;
  outline: none;
}

/* ===========================================
   BODY МОДАЛЬНОГО ОКНА
   =========================================== */
.modal-body {
  padding: 0 32px 32px;
  color: var(--sr-text);
}

/* ===========================================
   ФОРМЫ В МОДАЛКАХ
   =========================================== */

/* Form floating для модалок */
.modal-body .form-floating {
  margin-bottom: 3px;
}

.modal-body .form-control,
.modal-body .form-select {
  border: 0 !important;
  border-bottom: 1.5px solid var(--sr-line) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  color: var(--sr-text);
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
  font-size: 16px; /* Для iOS без зума */
}

.modal-body .form-floating > .form-control,
.modal-body .form-floating > .form-select {
  height: calc(3.25rem + 2px);
  line-height: 1.25;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
  border-bottom-color: var(--sr-line-focus) !important;
  background-color: transparent !important;
  outline: none !important;
  transform: translateY(-1px);
}

.modal-body .form-control:not(:placeholder-shown):not(:focus),
.modal-body .form-select:not([value=""]):not(:focus) {
  background-color: var(--sr-fill) !important;
  border-bottom-color: transparent !important;
  border-radius: var(--sr-radius) !important;
  padding-left: 1rem;
  padding-right: 1rem;
}

.modal-body .form-floating > label {
  pointer-events: none;
  transform-origin: left top;
  transform: translateY(0.6rem) scale(1);
  color: var(--sr-muted);
  padding-left: 0.5rem;
  font-weight: 400;
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
}

.modal-body .form-floating > .form-control:focus ~ label,
.modal-body .form-floating > .form-control:not(:placeholder-shown) ~ label,
.modal-body .form-floating > .form-select:not([value=""]) ~ label,
.modal-body .form-floating > .form-select:valid ~ label {
  transform: translateY(-0.6rem) scale(0.85);
  color: var(--sr-muted);
  font-weight: 400;
}

.modal-body .form-floating > .form-control::placeholder {
  color: transparent;
}

/* Textarea */
.modal-body textarea.form-control {
  resize: vertical;
  min-height: 120px;
  padding-top: 1rem;
}

.modal-body textarea.form-control:not(:placeholder-shown):not(:focus),
.modal-body textarea.form-control:valid:not(:focus) {
  padding-top: 1.625rem;
  padding-bottom: 0.625rem;
}

/* Form-text подсказки */
.modal-body .form-text {
  font-size: 0.875rem;
  color: var(--sr-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* ===========================================
   ЧЕКБОКСЫ В МОДАЛКАХ
   =========================================== */
.modal-body .form-check {
  padding-left: 1.75rem;
  margin-bottom: 1rem;
}

.modal-body .form-check-input {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  margin-left: -1.75rem;
  border: 1.5px solid var(--sr-line);
  background-color: transparent;
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
}

.modal-body .form-check-input:checked {
  background-color: var(--sr-text);
  border-color: var(--sr-text);
}

.modal-body .form-check-input:focus {
  border-color: var(--sr-line-focus);
  box-shadow: none;
}

.modal-body .form-check-label {
  color: var(--sr-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.modal-body .form-check-label a {
  color: var(--sr-muted);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
}

.modal-body .form-check-label a:hover {
  color: var(--sr-text);
  border-bottom-style: solid;
}

/* ===========================================
   КНОПКИ В МОДАЛКАХ
   =========================================== */
.modal-body .btn {
  box-shadow: none !important;
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
  font-weight: 400;
  letter-spacing: 0.3px;
  font-size: 16px; /* Для iOS */
}

.modal-body .btn-outline-dark {
  border: 1px solid var(--sr-line);
  background: transparent;
  color: var(--sr-text);
  padding: 0.75rem 2rem;
}

.modal-body .btn-outline-dark:hover {
  background: var(--sr-text);
  border-color: var(--sr-text);
  color: #fff;
  transform: translateY(-1px);
}

.modal-body .btn-outline-dark:active {
  transform: translateY(0);
}

.modal-body .btn-outline-dark:disabled {
  opacity: 0.6;
  transform: none;
}

/* Спиннер в кнопке */
.modal-body .btn .spinner-border {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* ===========================================
   СООБЩЕНИЯ В МОДАЛКАХ
   =========================================== */
.modal-body .form-messages,
.modal-body .sr-alert {
  border-radius: var(--sr-radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-body .form-messages.alert-danger,
.modal-body .sr-alert.error {
  background: #fee;
  color: var(--sr-error);
  border: 1px solid rgba(220, 53, 69, 0.2);
}

.modal-body .form-messages.alert-success,
.modal-body .sr-alert.success {
  background: #e8f5e9;
  color: var(--sr-success);
  border: 1px solid rgba(40, 167, 69, 0.2);
}

.modal-body .form-messages.alert-info {
  background: #e7f3ff;
  color: var(--sr-info);
  border: 1px solid rgba(23, 162, 184, 0.2);
}

/* Скрытие сообщений */
.modal-body .form-messages.d-none,
.modal-body .sr-alert.d-none {
  display: none !important;
}

/* ===========================================
   ЗАГРУЗКА В МОДАЛКЕ
   =========================================== */
.modal-body .spinner-border.text-success {
  width: 3rem;
  height: 3rem;
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--sr-success);
}

/* ===========================================
   СЕТКИ ДЛЯ ПОЛЕЙ
   =========================================== */
.modal-body .row {
  margin-left: -0.75rem;
  margin-right: -0.75rem;
}

.modal-body .row > * {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* ===========================================
   КРАСИВАЯ ЗАГРУЗКА ФАЙЛА
   =========================================== */
.modal-body .file-upload-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.modal-body .file-upload-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.modal-body .file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  border: 2px dashed var(--sr-line);
  border-radius: var(--sr-radius);
  background: var(--sr-fill);
  color: var(--sr-muted);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
  text-align: center;
  margin-bottom: 0;
}

.modal-body .file-upload-label:hover {
  border-color: var(--sr-line-focus);
  background: #fff;
  transform: translateY(-1px);
}

.modal-body .file-upload-label svg {
  width: 40px;
  height: 40px;
  margin-bottom: 0.75rem;
  color: var(--sr-muted);
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
}


.modal-body .file-upload-text {
  font-size: 1rem;
  font-weight: 400;
  color: var(--sr-text);
  margin-bottom: 0.25rem;
}

.modal-body .file-upload-name {
  font-size: 0.875rem;
  color: var(--sr-success);
  font-weight: 400;
  margin-top: 0.5rem;
  display: none;
}

.modal-body .file-upload-input:focus + .file-upload-label {
  border-color: var(--sr-line-focus);
  box-shadow: 0 0 0 3px rgba(33, 37, 41, 0.05);
  outline: none;
}

.modal-body .file-upload-wrapper.has-file .file-upload-label {
  border-color: var(--sr-success);
  background: rgba(40, 167, 69, 0.05);
}

.modal-body .file-upload-wrapper.has-file .file-upload-name {
  display: block;
}

.modal-body .file-upload-wrapper.has-file svg {
  color: var(--sr-success);
}

.modal-body .file-upload-error {
  color: var(--sr-error);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: none;
}

.modal-body .file-upload-wrapper.invalid .file-upload-label {
  border-color: var(--sr-error);
  background: rgba(220, 53, 69, 0.05);
}

.modal-body .file-upload-wrapper.invalid .file-upload-error {
  display: block;
}

/* Адаптив для файла */
@media (max-width: 576px) {
  .modal-body .file-upload-label {
    padding: 1.5rem 1rem;
  }
  
  .modal-body .file-upload-label svg {
    width: 32px;
    height: 32px;
  }
  
  .modal-body .file-upload-text {
    font-size: 0.9rem;
  }
}

/* ===========================================
   КАСТОМНЫЙ СЕЛЕКТ ДЛЯ МОДАЛОК
   =========================================== */
.modal-body .custom-select-wrapper{ 
  position: relative; 
  margin-bottom: 3px;
}

.modal-body .custom-select{ 
  position: relative; 
}

.modal-body .custom-select-trigger{
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.375rem 0.5rem;
  padding-bottom: 8px;
  padding-top: 26px;
  border: 0;
  border-bottom: 1.5px solid var(--sr-line);
  background: transparent;
  color: var(--sr-muted);
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
  text-align: left;
  cursor: pointer;
  font-size: 16px; /* Для iOS */
}

.modal-body .custom-select-trigger:focus {
  border-bottom-color: var(--sr-line-focus);
  outline: none;
  transform: translateY(-1px);
}

.modal-body .custom-select-trigger.selected{
  color: var(--sr-text);
  background: var(--sr-fill);
  border-bottom-color: var(--sr-line);
  border-radius: var(--sr-radius);
  padding: 0.375rem 1rem;
  height: 58px;
}


.modal-body .custom-select-trigger span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-height: 2.6em; /* 2 строки * 1.3 line-height */
}

.modal-body .custom-select-trigger.selected span {
  -webkit-line-clamp: 1;
  line-clamp: 1; /* Для выбранного состояния - только 1 строка */
  max-height: 1.3em;
}

.modal-body .custom-select-options{
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  font-size: 0.875rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.2s cubic-bezier(.4, 0, .2, 1);
  z-index: 1050;
  max-height: 300px;
  overflow: auto;
}

.modal-body .custom-select.open .custom-select-options{ 
  opacity: 1; 
  visibility: visible; 
  transform: translateY(0); 
}

.modal-body .custom-select-option{ 
  padding: 12px 16px; 
  cursor: pointer;
  transition: background 0.15s ease;
}

.modal-body .custom-select-option:hover{ 
  background: var(--sr-fill); 
}

.modal-body .custom-select-option.selected{ 
  background: var(--sr-text); 
  color: #fff; 
}

.modal-body .custom-select-option:first-child {
  border-radius: 12px 12px 0 0;
}

.modal-body .custom-select-option:last-child {
  border-radius: 0 0 12px 12px;
}

/* ===========================================
   АДАПТИВНОСТЬ
   =========================================== */
@media (max-width: 768px) {
  .modal-dialog {
    max-width: 95%;
    margin: 1rem auto;
  }

  .modal-header {
    padding: 20px 24px 16px;
  }

  .modal-title {
    font-size: 1.2rem;
  }

  .modal-body {
    padding: 0 24px 24px;
  }

  .modal-body .form-control,
  .modal-body .form-select {
    font-size: 16px !important; /* Предотвращает зум на iOS */
  }

  .modal-body .btn {
    font-size: 16px !important;
  }
}

/* ===========================================
   ФИКСЫ ДЛЯ iOS
   =========================================== */
@supports (-webkit-touch-callout: none) {
  .modal.fade .modal-dialog,
  .modal.show .modal-dialog {
    transform: none !important;
  }

  .modal {
    position: fixed !important;
    -webkit-overflow-scrolling: touch;
  }

  body.modal-open {
    position: fixed;
    width: 100%;
    overflow: hidden;
  }
}

/* ===========================================
   ДОПОЛНИТЕЛЬНЫЕ ЭЛЕМЕНТЫ
   =========================================== */

/* Input file для резюме */
.modal-body .input-file {
  margin-bottom: 1.5rem;
}

.modal-body .input-file label {
  display: block;
  font-weight: 500;
  color: var(--sr-text);
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.modal-body .input-file input[type="file"] {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--sr-line);
  border-radius: var(--sr-radius);
  background: var(--sr-fill);
  color: var(--sr-text);
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
  cursor: pointer;
}

.modal-body .input-file input[type="file"]:hover {
  border-color: var(--sr-line-focus);
}

.modal-body .input-file input[type="file"]:focus {
  outline: none;
  border-color: var(--sr-line-focus);
  box-shadow: 0 0 0 3px rgba(33, 37, 41, 0.05);
}

.modal-body .input-file .help-text {
  font-size: 0.875rem;
  color: var(--sr-muted);
  margin-top: 0.5rem;
  line-height: 1.4;
}

.modal-body .input-file .error-text {
  color: var(--sr-error);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: none;
}

.modal-body .input-file.invalid .error-text {
  display: block;
}

/* SR-grid для старых форм */
.modal-body .sr-grid {
  display: grid;
  gap: 1rem;
}

.modal-body .sr-grid.cols-2 {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 576px) {
  .modal-body .sr-grid.cols-2 {
    grid-template-columns: 1fr;
  }
}