/* styles.css — полный код с сохранением текущего состояния и добавлением скрытия кнопки "Выйти" до авторизации */

/* Общие сбросы и базовые установки */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background-color: #121212;
  color: #eee;
  font-family: Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

/* Шапка */
header {
  background-color: #222;
  color: #ccc;
  display: flex;
  align-items: center;
  padding: 12px 30px;
  box-shadow: 0 2px 7px rgba(0,0,0,0.6);
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  flex-grow: 1;
}

.logo-section img {
  height: 50px;
  margin-right: 15px;
}

.title-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.title-section h1 {
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
  color: #eee;
}

.title-section p {
  margin: 0;
  font-size: 0.9rem;
  color: #ccc;
}

.header-center {
  flex-shrink: 0;
  text-align: center;
  position: relative;
}

/* Кнопка "Выйти" — скрыта по умолчанию всегда (только JS показывает, когда авторизован) */
#logout-btn {
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  user-select: none;
  transition: background-color 0.3s ease;
  white-space: nowrap;
  display: none !important; /* принудительно скрываем по умолчанию */
  height: 40px;
  line-height: 40px;
  padding: 0 16px;
  box-sizing: border-box;
  font-size: 1rem;
}

#logout-btn.show {
  display: block !important; /* класс .show отображает кнопку */
}

#logout-btn:hover {
  background-color: #43a047;
}

/* ПК позиционирование кнопки "Выйти" с классом .show */
@media (min-width: 1025px) {
  #logout-btn.show {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
  }
}

/* Мобильное отображение с классом .show */
@media (max-width: 1024px) {
  #logout-btn.show {
    position: static;
    width: 100%;
    margin: 10px auto;
    box-sizing: border-box;
    text-align: center;
    transform: none;
    padding: 12px 0;
    border-radius: 0;
    white-space: normal;
  }
}

/* Центрирование меню авторизации и просмотра полей на ПК */
@media (min-width: 1025px) {
  body > #auth-section,
  body > #menu-view-section {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 40px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(40,40,40,0.8);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.8);
    display: block;
  }

  #auth-section form {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
}

/* Вертикальное расположение label и полей в меню просмотра */
#menu-view-section label,
#menu-view-section input,
#menu-view-section textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 12px;
}

#menu-view-section input,
#menu-view-section textarea {
  margin-top: 4px;
  background-color: #222;
  border-radius: 6px;
  border: none;
  padding: 8px 10px;
  color: #ddd;
  font-size: 1rem;
  resize: vertical;
  cursor: default;
}

#menu-view-section input[readonly],
#menu-view-section textarea[readonly] {
  background-color: #1a1a1a;
  color: #bbb;
  cursor: default;
  resize: none;
}

/* Формы */
label {
  font-weight: 600;
  margin-top: 18px;
  font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea {
  background-color: #333;
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 6px;
  color: #eee;
  font-size: 1rem;
  resize: vertical;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus,
textarea:focus {
  background-color: #444;
  outline: none;
  box-shadow: 0 0 8px #4caf50;
}

input[readonly],
textarea[readonly] {
  cursor: default;
  background-color: #1a1a1a;
  color: #bbb;
  resize: none;
}

/* Кнопки */
button {
  margin-top: 28px;
  background-color: #4caf50;
  border: none;
  border-radius: 10px;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s ease;
}

button:hover,
button:focus {
  background-color: #43a047;
  outline: none;
}

/* После авторизации — главный контейнер */
main.container {
  max-width: 1600px;
  margin: 30px auto;
  padding: 0 20px;
  box-sizing: border-box;
  display: none;
  gap: 36px;
  align-items: flex-start;
  justify-content: center;
}

/* Меню управления полем */
#menu-edit-section {
  width: 460px;
  background-color: #222;
  padding: 32px 28px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.8);
  max-height: 80vh;
  overflow-y: auto;
  margin-top: 40px;
  box-sizing: border-box;
}

/* Исправление меню управления на мобильных — плавное занятие 100% ширины */
@media (max-width: 960px) {
  #menu-edit-section {
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 24px;
    padding-left: 20px !important;
    padding-right: 20px !important;
    overflow-x: hidden;
  }
}

.map-section {
  flex-grow: 1;
  background: rgba(0,0,0,0.6);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.9);
  min-height: 650px;
  max-height: 80vh;
  overflow: hidden;
  user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 300px;
}

#map-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 14px;
  cursor: grab;
  user-select: none;
}

#menu-edit-section h2 {
  margin-top: 0;
  font-weight: 600;
  font-size: 1.3rem;
}

#menu-edit-section label {
  margin-top: 15px;
  font-weight: 700;
  display: block;
}

#menu-edit-section input, #menu-edit-section textarea {
  width: 100%;
  padding: 8px 10px;
  margin-top: 6px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  background-color: #333;
  color: #eee;
  resize: vertical;
}

#menu-edit-section button {
  margin-top: 25px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background-color: #4caf50;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#menu-edit-section button:hover {
  background-color: #43a047;
}

/* Сообщение ошибки */
#login-message {
  height: 1.2em;
  color: #f44336;
  font-weight: 600;
  margin-top: 12px;
  text-align: center;
}

/* Кнопка изменить данные */
#edit-btn {
  margin-top: 20px;
  background-color: #2196f3;
}

#edit-btn:hover {
  background-color: #1976d2;
}

/* Мобильная адаптация */
@media (max-width: 960px) {
  main.container {
    flex-direction: column;
    align-items: center;
  }
  .menu-section {
    max-height: none;
    margin-top: 24px;
  }
  .map-section {
    min-height: 400px;
    max-height: 50vh;
  }
  .auth-section, .menu-section, #menu-view-section {
    max-width: 100%;
  }
}

/* Мобильное оформление логотипа и заголовка */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    text-align: center;
  }
  header img {
    height: 40px;
    margin: 0 0 8px 0;
  }
  .title-section h1 {
    font-size: 1.8rem;
    margin: 0;
    font-weight: 700;
    color: #e0e0e0;
    text-shadow: 0 0 5px #4caf50aa;
    white-space: normal;
    word-break: break-word;
  }
  .title-section p {
    font-size: 1rem;
    color: #a0a0a0;
    margin-top: 4px;
  }
}