/* WMS System - Общие стили */

:root {
  /* Тёмная тема (по умолчанию) */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-card: #333333;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --accent: #4a90e2;
  --accent-hover: #357abd;
  --border: #404040;
  --shadow: rgba(0, 0, 0, 0.3);
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --info: #2196f3;
}

[data-theme="light"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #212121;
  --text-secondary: #757575;
  --accent: #1976d2;
  --accent-hover: #1565c0;
  --border: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.1);
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --info: #2196f3;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* Сайдбар */
.sidebar {
  width: 250px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Свёрнутый сайдбар */
.sidebar.collapsed {
  width: 60px;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 0 10px 20px;
}

.sidebar.collapsed .sidebar-header h2 {
  display: none;
}

.sidebar.collapsed .sidebar-nav a {
  padding: 12px 18px;
  justify-content: center;
}

.sidebar.collapsed .sidebar-nav .nav-text {
  opacity: 0;
  width: 0;
  margin-left: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-nav .nav-icon {
  font-size: 1.3em;
}

.sidebar.collapsed .submenu {
  display: none !important;
}

.sidebar.collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

/* Tooltip для свёрнутого сайдбара */
.sidebar.collapsed .sidebar-nav a {
  position: relative;
}

.sidebar.collapsed .sidebar-nav a::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9em;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1001;
  margin-left: 10px;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
  pointer-events: none;
}

.sidebar.collapsed .sidebar-nav a:hover::after {
  opacity: 1;
  visibility: visible;
}

.sidebar-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-header h2 {
  font-size: 1.5em;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s, width 0.3s;
}

/* Кнопка сворачивания */
.sidebar-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.sidebar-nav {
  list-style: none;
  padding-bottom: 80px; /* Место для footer */
}

.sidebar-nav li {
  margin: 5px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.2s, padding 0.3s;
}

.sidebar-nav .nav-icon {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  transition: font-size 0.2s;
}

.sidebar-nav .nav-text {
  margin-left: 10px;
  transition: opacity 0.2s, width 0.3s, margin 0.3s;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background-color: var(--bg-card);
}

.sidebar-nav a.active {
  background-color: var(--accent);
  color: white;
}

.sidebar-nav .submenu {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s;
}

.sidebar-nav .submenu.open {
  max-height: 500px;
}

.sidebar-nav .submenu a {
  padding-left: 40px;
  font-size: 0.9em;
}

/* Нижняя часть сайдбара */
.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 5px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.sidebar-theme-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1em;
}

.sidebar-theme-toggle:hover {
  background: var(--bg-card);
}

.sidebar-theme-toggle .nav-icon {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  font-size: 1.2em;
}

.sidebar-theme-toggle .nav-text {
  margin-left: 10px;
  white-space: nowrap;
  transition: opacity 0.2s, width 0.3s, margin 0.3s;
}

/* Свёрнутое состояние для footer */
.sidebar.collapsed .sidebar-footer {
  padding: 5px 0;
}

.sidebar.collapsed .sidebar-theme-toggle {
  justify-content: center;
  padding: 12px 18px;
}

.sidebar.collapsed .sidebar-theme-toggle .nav-text {
  opacity: 0;
  width: 0;
  margin-left: 0;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-theme-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9em;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1001;
  margin-left: 10px;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
  pointer-events: none;
}

.sidebar.collapsed .sidebar-theme-toggle {
  position: relative;
}

.sidebar.collapsed .sidebar-theme-toggle:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Кнопка выхода */
.sidebar-logout-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1em;
}

.sidebar-logout-btn:hover {
  background: rgba(244, 67, 54, 0.15);
  color: var(--error);
}

.sidebar-logout-btn .nav-icon {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  font-size: 1.2em;
}

.sidebar-logout-btn .nav-text {
  margin-left: 10px;
  white-space: nowrap;
  transition: opacity 0.2s, width 0.3s, margin 0.3s;
}

.sidebar.collapsed .sidebar-logout-btn {
  justify-content: center;
  padding: 12px 18px;
  position: relative;
}

.sidebar.collapsed .sidebar-logout-btn .nav-text {
  opacity: 0;
  width: 0;
  margin-left: 0;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-logout-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9em;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1001;
  margin-left: 10px;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
  pointer-events: none;
}

.sidebar.collapsed .sidebar-logout-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Основной контент */
.content {
  flex: 1;
  margin-left: 250px;
  padding: 20px;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Контент при свёрнутом сайдбаре */
body.sidebar-collapsed .content {
  margin-left: 60px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 2em;
  color: var(--text-primary);
}

.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1.2em;
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background-color: var(--bg-secondary);
}

/* Карточки */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.3em;
  font-weight: 600;
  color: var(--text-primary);
}

/* Таблицы */
.table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background-color: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
}

.table tr:hover {
  background-color: var(--bg-secondary);
}

.table tr:last-child td {
  border-bottom: none;
}

/* Формы */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-primary);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 1em;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

/* Кнопки */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1em;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--bg-card);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background-color: var(--bg-secondary);
}

.btn-danger {
  background-color: var(--error);
  color: white;
}

.btn-danger:hover {
  background-color: #d32f2f;
}

.btn-success {
  background-color: var(--success);
  color: white;
}

.btn-success:hover {
  background-color: #388e3c;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 500;
}

.badge-success {
  background-color: var(--success);
  color: white;
}

.badge-warning {
  background-color: var(--warning);
  color: white;
}

.badge-error {
  background-color: var(--error);
  color: white;
}

.badge-info {
  background-color: var(--info);
  color: white;
}

.badge-default {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* Модальные окна */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-content {
  background-color: var(--bg-card);
  border-radius: 8px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.5em;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-footer {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Уведомления */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 20px;
  border-radius: 5px;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 3000;
  animation: slideIn 0.3s;
  max-width: 400px;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification-success {
  background-color: var(--success);
  color: white;
}

.notification-error {
  background-color: var(--error);
  color: white;
}

.notification-warning {
  background-color: var(--warning);
  color: white;
}

.notification-info {
  background-color: var(--info);
  color: white;
}

/* Адаптивность */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
  }

  .sidebar.collapsed {
    width: 50px;
  }

  .content {
    margin-left: 200px;
  }

  body.sidebar-collapsed .content {
    margin-left: 50px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 100%;
    position: relative;
    height: auto;
  }

  .sidebar.collapsed {
    width: 100%;
  }

  .content {
    margin-left: 0;
  }

  body.sidebar-collapsed .content {
    margin-left: 0;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .sidebar-toggle {
    display: none;
  }
}

/* Утилиты */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

/* Lightbox для просмотра изображений */
.lightbox {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.3s ease;
}

.lightbox.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  margin: auto;
  animation: zoomIn 0.3s ease;
}

.lightbox-img {
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10000;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  transition: background-color 0.3s, transform 0.2s;
  user-select: none;
}

.lightbox-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.lightbox-close:active {
  transform: scale(0.95);
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 30px;
  font-weight: bold;
  cursor: pointer;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s, transform 0.2s;
  user-select: none;
}

.lightbox-prev {
  left: 30px;
}

.lightbox-next {
  right: 30px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-prev:active,
.lightbox-next:active {
  transform: translateY(-50%) scale(0.95);
}

.lightbox-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9em;
  text-align: center;
}

/* Кликабельные изображения */
.product-photo,
.product-photo-preview,
.product-list-photo {
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

.product-photo:hover,
.product-photo-preview:hover,
.product-list-photo:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes zoomIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.hidden {
  display: none !important;
}
