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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

/* Контейнеры */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Хедер */
.header {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 15px;
  margin-bottom: 30px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-info {
  font-size: 16px;
  color: #555;
  font-weight: 500;
}

.user-info .username {
  color: #667eea;
  font-weight: 600;
}

/* Кнопки */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
}

.btn-secondary:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-2px);
}

.btn-logout {
  background: #f3f4f6;
  color: #6b7280;
}

.btn-logout:hover {
  background: #e5e7eb;
  color: #4b5563;
}

.btn-admin {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.btn-admin:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(240, 147, 251, 0.4);
}

/* Страница входа */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.logo-container {
  margin-bottom: 30px;
}

.logo {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 20px;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: #333;
  margin-bottom: 10px;
}

.login-subtitle {
  font-size: 14px;
  color: #888;
  margin-bottom: 30px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #555;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 15px;
  transition: all 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.error-message {
  background: #fef2f2;
  color: #dc2626;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  border: 1px solid #fecaca;
}

.btn-login {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  margin-top: 10px;
}

/* Список дашбордов */
.dashboard-page {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: #333;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.city-section {
  margin-bottom: 35px;
  background: #f9fafb;
  padding: 20px;
  border-radius: 15px;
  border: 1px solid #e5e7eb;
}

.city-title {
  font-size: 18px;
  font-weight: 600;
  color: #667eea;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 15px;
}

.dashboard-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.dashboard-card:hover {
  border-color: #667eea;
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.15);
}

.dashboard-name {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.dashboard-type {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Админ панель */
.admin-page {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.admin-section {
  margin-bottom: 40px;
  padding-bottom: 30px;
  border-bottom: 2px solid #f3f4f6;
}

.admin-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Форма создания пользователя */
.create-user-form {
  background: #f9fafb;
  padding: 25px;
  border-radius: 15px;
  display: flex;
  gap: 15px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group-inline {
  flex: 1;
  min-width: 200px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.checkbox-group label {
  cursor: pointer;
  font-size: 14px;
  color: #555;
}

/* Таблица пользователей */
.users-table {
  width: 100%;
  background: white;
  border-radius: 15px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.users-table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.users-table th {
  padding: 15px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.users-table td {
  padding: 15px;
  border-top: 1px solid #f3f4f6;
  font-size: 14px;
}

.users-table tbody tr:hover {
  background: #f9fafb;
}

.role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.role-admin {
  background: #ddd6fe;
  color: #7c3aed;
}

.role-user {
  background: #e0e7ff;
  color: #4f46e5;
}

/* Доступ к дашбордам */
.access-list {
  max-height: 300px;
  overflow-y: auto;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 15px;
  background: #f9fafb;
}

.access-city {
  font-weight: 600;
  color: #667eea;
  margin-top: 15px;
  margin-bottom: 10px;
}

.access-city:first-child {
  margin-top: 0;
}

.access-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  margin: 5px 0;
  background: white;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.access-item:hover {
  background: #f3f4f6;
}

.access-item input[type="checkbox"] {
  margin-right: 10px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.access-item label {
  cursor: pointer;
  font-size: 14px;
  color: #555;
  flex: 1;
}

.access-item input[type="checkbox"]:disabled + label {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

/* Детальная страница дашборда */
.dashboard-detail-header {
  background: #1f2937;
  color: white;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.dashboard-detail-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.dashboard-detail-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

.dashboard-detail-name {
  font-size: 18px;
  font-weight: 600;
}

.dashboard-detail-nav {
  display: flex;
  gap: 20px;
}

.dashboard-detail-nav a {
  color: white;
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background 0.3s ease;
}

.dashboard-detail-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dashboard-frame {
  position: fixed;
  top: 70px;
  left: 0;
  width: 100%;
  height: calc(100vh - 70px);
  border: none;
  background: #f9fafb;
}

/* Адаптация для мобильных устройств Safari */
@media only screen and (max-width: 768px) {
  .dashboard-frame {
    /* Добавляем отступ снизу для Safari на iOS */
    height: calc(100vh - 70px - 80px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Анимации загрузки */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease;
}

/* Выпадающее меню пользователя */
.user-dropdown {
  position: relative;
  display: inline-block;
}

.user-menu-btn {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.user-menu-btn:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background: white;
  min-width: 200px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  z-index: 1000;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.dropdown-content.show {
  display: block;
  animation: slideDown 0.3s ease;
}

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

.dropdown-item {
  color: #333;
  padding: 12px 20px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s ease;
  font-size: 14px;
  border: none;
  width: 100%;
  text-align: left;
  background: white;
  cursor: pointer;
}

.dropdown-item:hover {
  background: #f3f4f6;
}

.dropdown-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0;
}

.dropdown-header {
  padding: 12px 20px;
  background: #f9fafb;
  font-size: 12px;
  color: #888;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Страница смены пароля */
.password-change-container {
  max-width: 500px;
  margin: 50px auto;
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.password-title {
  font-size: 24px;
  font-weight: 700;
  color: #333;
  margin-bottom: 30px;
  text-align: center;
}

.success-message {
  background: #d1fae5;
  color: #065f46;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  border: 1px solid #a7f3d0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-requirements {
  background: #f3f4f6;
  padding: 15px;
  border-radius: 8px;
  margin-top: 20px;
  font-size: 13px;
  color: #6b7280;
}

.password-requirements ul {
  margin: 10px 0 0 20px;
  padding: 0;
}

.password-requirements li {
  margin: 5px 0;
}

/* Чекбокс "Запомнить меня" */
.remember-me {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0;
  font-size: 14px;
  color: #555;
}

.remember-me input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.remember-me label {
  cursor: pointer;
}

/* Иконки */
.icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  vertical-align: middle;
}

/* Адаптивность */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .create-user-form {
    flex-direction: column;
    align-items: stretch;
  }
  
  .users-table {
    overflow-x: auto;
    display: block;
  }
  
  .dashboard-detail-header {
    padding: 10px 15px;
  }
  
  .dashboard-detail-name {
    font-size: 14px;
  }
}

/* Публичные дашборды */
.dashboard-card.public {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: 2px solid #059669;
  color: white;
}

.dashboard-card.public:hover {
  border-color: #047857;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
  transform: translateY(-3px);
}

.dashboard-card.public .dashboard-name {
  color: white;
  font-weight: 600;
}

.dashboard-card.public .dashboard-type {
  color: #d1fae5;
  font-weight: 500;
}

/* Скрытые дашборды */
.dashboard-card.hidden {
  background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
  border: 2px solid #6b7280;
  color: white;
}

.dashboard-card.hidden:hover {
  border-color: #ef4444;
  box-shadow: 0 10px 25px rgba(239, 68, 68, 0.2);
}

.dashboard-card.hidden .dashboard-name {
  color: white;
}

.dashboard-card.hidden .dashboard-type {
  color: #fbbf24;
}

.hidden-indicator {
  display: inline-block;
  background: #dc2626;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  margin-left: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip-text {
  visibility: hidden;
  background-color: #333;
  color: white;
  text-align: center;
  border-radius: 6px;
  padding: 5px 10px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 12px;
  white-space: nowrap;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Скроллбар */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.banners-container {
    margin-bottom: 20px;
}

.banner {
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
}

.banner-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.banner-content {
    flex: 1;
}

.banner-title {
    display: block;
    font-size: 16px;
    margin-bottom: 5px;
    font-weight: 600;
}

.banner-message {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Типы баннеров */
.banner-info {
    background: #e0f2fe;
    border-left: 4px solid #0284c7;
    color: #075985;
}

.banner-warning {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

.banner-error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.banner-success {
    background: #d1fae5;
    border-left: 4px solid #10b981;
    color: #065f46;
}

/* Стили для новых ролей */
.role-tech-admin {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.role-superadmin {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.role-hidden {
    background: #1f2937;
    color: white;
}

/* Кнопка для управления баннерами */
.btn-warning {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(251, 191, 36, 0.4);
}

/* Опции входа */
.login-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.saved-logins-hint {
    text-align: center;
    margin-top: 15px;
    color: #888;
}

/* Страница управления баннерами */
.banner-form {
    background: #f9fafb;
    padding: 25px;
    border-radius: 15px;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    resize: vertical;
}

.form-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.checkbox-row {
    display: flex;
    gap: 20px;
    margin: 15px 0;
}

/* Список баннеров */
.banners-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.banner-item {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 15px;
    padding: 20px;
    transition: all 0.3s ease;
}

.banner-item.inactive {
    opacity: 0.6;
}

.banner-item:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.1);
}

.banner-preview {
    margin-bottom: 15px;
}

.banner-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    padding: 10px 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.banner-locations {
    display: flex;
    gap: 8px;
}

.location-badge {
    background: #e0e7ff;
    color: #4f46e5;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.inactive {
    background: #f3f4f6;
    color: #6b7280;
}

.banner-date {
    color: #888;
    font-size: 12px;
    margin-left: auto;
}

.banner-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    line-height: 20px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover,
.close:focus {
    color: #667eea;
}

/* Datalist для сохраненных логинов */
#login::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

/* Улучшения для чекбокса суперадмина */
.checkbox-group.superadmin-checkbox {
    background: #fef3c7;
    padding: 10px 15px;
    border-radius: 8px;
    border: 2px solid #f59e0b;
}

.checkbox-group.superadmin-checkbox label {
    color: #92400e;
    font-weight: 600;
}

/* Адаптивность для баннеров */
@media (max-width: 768px) {
    .banner {
        flex-direction: column;
        gap: 10px;
    }
    
    .banner-icon {
        font-size: 20px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .checkbox-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .banner-meta {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .banner-date {
        margin-left: 0;
    }
    
    .banner-actions {
        width: 100%;
    }
    
    .banner-actions button,
    .banner-actions form {
        flex: 1;
    }
    
}

/* Стили для формы выхода */
.logout-form {
    margin: 0;
    padding: 0;
    display: block;
}

.logout-form .dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.5;
}

.logout-form .dropdown-item:hover {
    background-color: #f8f9fa;
}