/* ======= Базовые стили приложения (mobile-first) ======= */

/* 1) Базовая коробочная модель и предсказуемые размеры */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  /* Вместо height: 100vh — безопаснее для мобильных браузеров */
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;

  background: linear-gradient(135deg, #0f3d3e, #1c5e5f);
  font-family: Arial, sans-serif;

  /* На мобильных лучше не центрировать body флексом —
     иначе часто ломаются прокрутка и фиксированные элементы */
  display: block;
  color: #ffffff;
}

/* Toast уведомление приложения */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  
  background: #124a4b;
  border: 1px solid #2c786c;
  color: #eaf7f5;

  padding: 14px 18px;
  border-radius: 12px;

  font-size: 14px;
  text-align: center;

  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
  z-index: 2000;

  max-width: 90vw;
}

.app-toast.success {
  border-color: #3fbf8f;
}

.app-toast.error {
  border-color: #e05a5a;
}

.app-toast.hidden {
  display: none;
}

/* 2) Контейнер приложения: на мобильных — колонка */
.app-container {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* 3) Переключатель языка: компактнее и безопаснее для "notch" */
.language-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  background-color: #2c786c;
  color: white;
  border: none;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  z-index: 1100;

  /* На мобильных — лёгкая тень, чтобы читалось на фоне */
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.language-toggle:hover {
  background-color: #1e5c52;
}

/* 4) "Sidebar" на мобильных превращаем в верхний блок меню (без изменений HTML) */
.sidebar {
  width: 100%;
  background-color: rgba(0, 0, 0, 0.35);
  padding: 14px 12px;
  color: white;
  font-size: 15px;

  display: flex;
  flex-direction: column;
  gap: 10px;

  /* чтобы контент не прятался под фиксированной кнопкой языка */
  padding-top: 48px;
}

/* Текст в сайдбаре (у вас там <p>) */
.sidebar p {
  margin: 0 0 6px;
  opacity: 0.95;
}

/* 5) Кнопки меню: touch-friendly */
.menu-button {
  background-color: #2c786c;
  color: white;
  border: none;

  /* 44px+ — комфортная высота для пальца */
  padding: 14px 14px;
  min-height: 44px;

  font-size: 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.menu-button:hover {
  background-color: #1e5c52;
}

/* 6) Контент: на мобильных — прокрутка, фон остаётся */
.main-content {
  flex: 1 1 auto;
  padding: 12px;
  
  -webkit-overflow-scrolling: touch;
}

/* ======= Модалки (универсальные) ======= */
.modal {
  position: fixed;
  inset: 0; /* top/right/bottom/left:0 */
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);

  display: flex;
  justify-content: center;
  align-items: flex-end; /* на мобильных удобнее снизу как sheet */
  z-index: 1200;

  /* чтобы клики/скролл ощущались корректно */
  overscroll-behavior: contain;
}

.modal.hidden {
  display: none;
}

/* На мобильных делаем модалку полноэкранной/почти полноэкранной */
.modal-content {
  background-color: #0f3d3e;
  width: 100%;
  max-width: 100%;
  max-height: 92dvh;

  padding: 18px 14px 16px;
  border-radius: 16px 16px 0 0;

  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  position: relative;
  color: white;
  border: 1px solid #2c786c;

  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-content h2 {
  margin: 0 0 12px;
  color: #ffffff;
  font-size: 18px;
}

.modal-content label {
  font-weight: bold;
  display: block;
  margin-bottom: 6px;
  color: #d6f1ee;
  font-size: 14px;
}

.modal-content input,
.modal-content textarea,
.book-form-container input,
.book-form-container textarea,
.book-form-container select {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  margin-top: 6px;

  background: rgba(255, 255, 255, 0.92);
  color: #163b38;

  border: 1px solid rgba(44, 120, 108, 0.28);
  border-radius: 14px;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease,
    transform 0.15s ease;

  -webkit-appearance: none;
  appearance: none;
}

.modal-content input::placeholder,
.modal-content textarea::placeholder,
.book-form-container input::placeholder,
.book-form-container textarea::placeholder {
  color: #6e8f8a;
}

.modal-content input:focus,
.modal-content textarea:focus,
.book-form-container input:focus,
.book-form-container textarea:focus,
.book-form-container select:focus {
  outline: none;
  border-color: #2c786c;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(44, 120, 108, 0.14);
  transform: translateY(-1px);
}

.modal-content input:hover,
.modal-content textarea:hover,
.book-form-container input:hover,
.book-form-container textarea:hover,
.book-form-container select:hover {
  border-color: rgba(44, 120, 108, 0.45);
  background: #ffffff;
}

.book-form-container textarea {
  min-height: 120px;
  resize: vertical;
}

.modal-content button {
  background-color: #2c786c;
  color: white;
  border: none;

  padding: 14px 16px;
  min-height: 44px;

  border-radius: 12px;
  cursor: pointer;
  margin-top: 12px;
  width: 100%;
}

.modal-content button:hover {
  background-color: #1e5c52;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 26px;
  line-height: 1;
  color: #ffffff;
  cursor: pointer;

  /* увеличиваем зону клика */
  padding: 8px;
}

/* ======= Вспомогательные классы ======= */
.hidden-input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}


.file-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
  flex-wrap: nowrap;
  overflow: hidden;
  width: 100%;
}

.file-name {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  color: #d6f1ee;
  font-size: 14px;
  opacity: 0.9;
  max-width: 100%;
}

/* ======= Desktop enhancements ======= */
@media (min-width: 900px) {
  body {
    /* desktop можно вернуть "фрейм" по центру, если хотите */
    display: flex;
    justify-content: center;
    align-items: stretch;
  }

  .app-container {
    flex-direction: row;
    width: 100%;
    height: 100%;
    min-height: 100vh;
  }

  .sidebar {
    width: 220px;
    padding: 20px;
    gap: 15px;
    padding-top: 20px; /* на desktop не нужно место под язык */
  }

  .main-content {
    padding: 20px;
  }

  .modal {
    align-items: center; /* модалка по центру */
  }

  .modal-content {
    width: 420px;
    max-width: 90%;
    border-radius: 12px;
    max-height: 90vh;
    padding: 30px;
  }

  .modal-content button {
    width: auto;
    min-width: 160px;
  }

  .language-toggle {
    position: absolute; /* как у вас было */
    top: 20px;
    right: 20px;
    box-shadow: none;
  }
}

/* ======= Mobile bottom navigation ======= */
.bottom-nav {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  gap: 10px;

  background-color: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  z-index: 1300;
}

.bottom-nav__btn {
  flex: 1 1 0;
  background-color: #2c786c;
  color: #fff;
  border: none;
  border-radius: 14px;

  min-height: 52px;
  padding: 10px 8px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;

  cursor: pointer;
}

.bottom-nav__icon {
  font-size: 18px;
  line-height: 1;
}

.bottom-nav__label {
  font-size: 12px;
  line-height: 1.1;
  opacity: 0.95;
}

/* Чтобы контент не прятался под нижней панелью */
@media (max-width: 899px) {
  .main-content {
    padding-bottom: calc(12px + 90px + env(safe-area-inset-bottom));
  }

  .sidebar {
    display: none;
  }
}

/* На desktop bottom-nav не нужен */
@media (min-width: 900px) {
  .bottom-nav {
    display: none;
  }
}

