/* Файл: /public/css/style.css */
/* Основные стили проекта (Версия 2.0 - Улучшенная адаптивность и консистентность) */

/* ------------------- */
/* Переменные     */
/* ------------------- */
:root {
  --primary-color: #007bff;
  --primary-hover: #0056b3;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --danger-hover: #c82333;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --border-color: #dee2e6;
  --background-color: #ffffff;
  --body-bg-color: #f0f2f5;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --border-radius: 0.5rem;
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
}

/* ------------------- */
/* Базовые стили     */
/* ------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  background-color: var(--body-bg-color);
  color: var(--dark-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

/* ------------------- */
/* Контейнеры     */
/* ------------------- */
.container {
  width: 100%;
  max-width: 960px;
  background-color: var(--background-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.main-header {
  padding: 1rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.main-header h1 {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
}

.main-header h1 a {
    color: white;
    text-decoration: none;
}

.main-content {
  padding: 1.5rem;
  flex-grow: 1;
}

.main-footer {
  text-align: center;
  padding: 1rem;
  background-color: var(--light-color);
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--secondary-color);
  flex-shrink: 0;
}

/* Секции контента в панелях управления */
.content-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #fff;
}
.content-section > h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}
details.content-section > summary {
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
}


/* ------------------- */
/* Формы        */
/* ------------------- */
.pincode-form,
.upload-form,
.login-form,
.styled-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 550px;
  margin: 0 auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

label {
  font-weight: 500;
  color: #495057;
}

/* Поля ввода */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="datetime-local"],
select,
textarea {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Кнопки */
button,
.file-label {
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  background-color: var(--primary-color);
  color: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  text-align: center;
  display: inline-block;
  line-height: 1.5;
  min-height: 44px; /* Для лучшей доступности */
}

button:hover {
  background-color: var(--primary-hover);
}

button:disabled {
  background-color: var(--secondary-color);
  cursor: not-allowed;
  opacity: 0.7;
}

button.danger {
    background-color: var(--danger-color);
}
button.danger:hover {
    background-color: var(--danger-hover);
}

/* ------------------- */
/* Компоненты UI     */
/* ------------------- */

/* Сообщения */
.message {
  padding: 1rem;
  border-radius: var(--border-radius);
  margin: 1rem 0;
  border: 1px solid transparent;
  animation: fadeIn 0.3s ease-out;
}

.message.success {
  background-color: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

.message.error {
  background-color: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}

/* Загрузка файлов */
.file-label {
  cursor: pointer;
}

#file-input,
#file-input-camera {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

/* Список файлов */
.file-list {
  margin: 1rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.file-list-items {
  list-style: none;
  padding: 0;
  max-height: 150px;
  overflow-y: auto;
}

.file-list-items li {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}
.file-list-items li:last-child {
  border-bottom: none;
}

/* Прогресс-бар */
.progress-container {
  width: 100%;
  background-color: #e9ecef;
  border-radius: var(--border-radius);
  overflow: hidden;
  margin: 1rem 0;
}

.progress-bar {
  height: 20px;
  width: 0;
  background-color: var(--success-color);
  transition: width 0.3s ease;
  border-radius: var(--border-radius);
}

/* Галерея */
.gallery-wrapper {
  margin-top: 2rem;
}
.gallery-wrapper h3 {
  margin-bottom: 1rem;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.gallery img {
  width: 100%;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s, box-shadow 0.3s;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.gallery img:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

/* Камера */
#camera-controls {
  width: 100%;
}
.camera-select-wrapper {
  margin-bottom: 1rem;
  width: 100%;
}

#camera-preview {
  width: 100%;
  height: auto;
  max-height: 60vh;
  background-color: #000;
  border-radius: var(--border-radius);
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

#snap-photo {
  margin-top: 1rem;
  width: 100%;
}

/* Скрытая ссылка на вход */
#hidden-login-container {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
}

#hidden-login-container a {
  color: var(--primary-color);
  background-color: white;
  padding: 5px 10px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}

/* Панели управления */
.owner-nav, .admin-nav, .user-nav {
  margin-bottom: 2rem;
}
.owner-nav ul, .admin-nav ul, .user-nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 1rem;
    background-color: #e9ecef;
    border-radius: var(--border-radius);
}
.owner-nav a, .admin-nav a, .user-nav a {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
    padding: 0.5rem;
    border-radius: calc(var(--border-radius) / 2);
    transition: background-color 0.2s, color 0.2s;
}
.owner-nav a:hover, .admin-nav a:hover, .user-nav a:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Таблицы данных */
.data-table-wrapper {
  overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}
.data-table th, .data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.data-table th {
    background-color: var(--light-color);
    font-weight: 600;
}
.data-table .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.data-table .actions form {
    margin: 0;
}
.data-table .actions button {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Модальное окно */
#block-modal {
    display: none; /* по умолчанию скрыто */
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex; /* будет изменено JS */
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow);
}
.modal-content .styled-form {
    margin: 0;
    max-width: none;
}
.modal-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Анимации */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------- */
/* Адаптивность    */
/* ------------------- */

/* Планшеты (до 768px) */
@media (max-width: 768px) {
  .main-header {
    flex-direction: column;
    text-align: center;
  }
  .main-content {
    padding: 1.5rem 1rem;
  }
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
  }
  .upload-options {
    flex-direction: column;
  }
}

/* Мобильные устройства (до 480px) */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }
  .container {
    border-radius: 0;
    box-shadow: none;
  }
  .main-content {
    padding: 1rem;
  }
  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  button, .file-label {
    width: 100%;
  }
  .form-group-inline {
    flex-direction: column;
    align-items: flex-start;
  }
  .data-table {
    font-size: 0.8rem;
  }
  .data-table th, .data-table td {
    padding: 0.5rem;
  }
  .modal-buttons {
    flex-direction: column;
  }
}
