* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 300;
}

.auth-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Login Form Styles */
.login-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-form .token-input {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  width: 200px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.login-form .token-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.login-form .token-input:focus {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
}

.admin-panel {
  display: flex;
  align-items: center;
  gap: 10px;
}

.token-input {
  padding: 8px 12px;
  border: none;
  border-radius: 5px;
  width: 200px;
}

/* Auth states */
body.unauthorized .tabs,
body.unauthorized .tab-content,
body.unauthorized .section {
  display: none;
}

body.unauthorized #auth-message {
  display: block !important;
}

.status-message {
  padding: 12px 20px;
  margin: 0;
  border-radius: 0;
  display: none;
}

.status-message.success {
  background: #d4edda;
  color: #155724;
  border-bottom: 2px solid #c3e6cb;
}

.status-message.error {
  background: #f8d7da;
  color: #721c24;
  border-bottom: 2px solid #f1b0b7;
}

.status-message.info {
  background: #cce7ff;
  color: #004085;
  border-bottom: 2px solid #b3d7ff;
}

.tabs {
  display: flex;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.tab-btn {
  padding: 15px 30px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
}

.tab-btn:hover {
  background: #e9ecef;
}

.tab-btn.active {
  background: white;
  border-bottom-color: #667eea;
  color: #667eea;
  font-weight: 600;
}

.tab-content {
  display: none;
  padding: 30px;
}

.tab-content.active {
  display: block;
}

.section {
  margin-bottom: 40px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.section-header h2 {
  color: #495057;
  font-weight: 600;
}

.items-list {
  margin-bottom: 30px;
}

.item {
  padding: 20px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  margin-bottom: 15px;
  transition: all 0.3s ease;
  background: white;
}

.item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-color: #667eea;
}

.item-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.item-info {
  flex: 1;
}

.item-info strong {
  font-size: 1.1rem;
  color: #495057;
  display: block;
  margin-bottom: 5px;
}

.item-price {
  color: #28a745;
  font-weight: 600;
  font-size: 1.2rem;
}

.item-description {
  color: #6c757d;
  margin: 8px 0;
  line-height: 1.5;
}

.item-preview {
  color: #6c757d;
  margin: 8px 0;
  line-height: 1.5;
}

.item-date {
  color: #999;
  font-size: 0.9rem;
}

.item-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.form-section {
  background: #f8f9fa;
  padding: 25px;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.form-section h3 {
  margin-bottom: 20px;
  color: #495057;
  font-weight: 600;
}

.ajax-form {
  max-width: 600px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #495057;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ced4da;
  border-radius: 5px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
  color: #333 !important;
  background-color: #fff !important;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Products search and scroll-top */
.search-wrapper input[type="search"] {
  padding: 8px 12px;
  border: 1px solid #dfe4ee;
  border-radius: 8px;
  width: 360px;
  max-width: 40vw;
}

#scroll-top-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 20000;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  border-radius: 8px;
  background: #ff8a00; /* orange */
  color: white;
}

@media (max-width: 640px) {
  #scroll-top-btn { right: 12px; bottom: 16px; width: 40px; height: 40px; }
}

#scroll-top-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(255,138,0,0.18);
}

.actions-row { display:flex; gap:12px; align-items:center; }

/* Buttons */
button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5a6fd8;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-warning {
  background: #ffc107;
  color: #212529;
  padding: 8px 15px;
  font-size: 0.85rem;
}

.btn-warning:hover {
  background: #e0a800;
}

.btn-danger {
  background: #dc3545;
  color: white;
  padding: 8px 15px;
  font-size: 0.85rem;
}

.btn-danger:hover {
  background: #c82333;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.stat-card {
  background: white;
  padding: 25px;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  text-align: center;
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card h3 {
  color: #6c757d;
  font-size: 1rem;
  margin-bottom: 10px;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: #667eea;
}

/* Empty and error states */
.empty-state,
.error {
  text-align: center;
  padding: 40px;
  color: #6c757d;
  font-style: italic;
}

.error {
  color: #dc3545;
  background: #f8d7da;
  border-radius: 5px;
}

/* Responsive design */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    text-align: center;
  }
  
  .auth-section {
    justify-content: center;
  }
  
  .login-form {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  
  .login-form .token-input {
    width: 100%;
  }
  
  .admin-panel {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  
  .token-input {
    width: 100%;
  }
  
  .tabs {
    flex-wrap: wrap;
  }
  
  .tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
  }
  
  .item-content {
    flex-direction: column;
  }
  
  .item-actions {
    align-self: stretch;
    justify-content: space-between;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .form-actions button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }
  
  .tab-content {
    padding: 20px;
  }
  
  .section-header {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Additional styles for admin filter controls (selects, multi-selects) */
.form-group select,
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dfe4ee;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  color: #222;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 6px 18px rgba(102,126,234,0.08);
}

/* Add custom arrow for single selects */
.form-group select:not([multiple]) {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><path fill='%23667eea' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
  padding-right: 38px; /* space for arrow */
}

/* Style for multi-select boxes used for characteristics */
select[multiple],
.form-group select[multiple] {
  min-height: 140px;
  max-height: 320px;
  overflow: auto;
  padding: 8px 10px;
  /* For multi-selects keep native list, but remove inner borders */
  background: transparent;
  border: none;
}

/* Make long lists inside multi-select clearer */
select[multiple] option {
  padding: 6px 8px;
}

/* Ensure multi-select wrapper looks like other controls and contains the select */
.multi-select-wrapper {
  border: 1px solid #dfe4ee;
  padding: 6px;
  border-radius: 8px;
  background: #fff;
}

.multi-select-wrapper select {
  width: 100%;
  border: none;
  background: transparent;
  padding: 4px 6px;
  font-size: 14px;
}

/* Two-column layout for filters area in admin */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 24px;
  align-items: start;
}

/* Responsive fallback */
@media (max-width: 900px) {
  .filters-grid { grid-template-columns: 1fr; }
}

/* Label improvements */
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #000000;
}

/* Small helper for select placeholders */
.select-empty {
  color: #9aa3b2;
}

/* Small spacing for multi-select containers */
.multi-select-wrapper {
  border: 1px solid #eef1f6;
  padding: 6px;
  border-radius: 6px;
  background: #fff;
}

/* Admin Popup Styles */
.admin-popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.admin-popup.active {
  display: flex;
}

.admin-popup__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.admin-popup__content {
  background: white;
  border-radius: 10px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: 10001;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.admin-popup__header {
  padding: 20px 30px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 10px 10px 0 0;
}

.admin-popup__header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.admin-popup__close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: white;
  transition: all 0.3s ease;
}

.admin-popup__close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg) scale(1.1);
}

.admin-popup__body {
  padding: 30px;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
}

.admin-popup__body .form-section-inner {
  margin-top: 20px;
}

/* Scrollbar styles for popup */
.admin-popup__body::-webkit-scrollbar {
  width: 8px;
}

.admin-popup__body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.admin-popup__body::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.admin-popup__body::-webkit-scrollbar-thumb:hover {
  background: #555;
}

@media (max-width: 768px) {
  .admin-popup__content {
    max-width: 95%;
    max-height: 95vh;
  }
  
  .admin-popup__header {
    padding: 15px 20px;
  }
  
  .admin-popup__header h3 {
    font-size: 1.2rem;
  }
  
  .admin-popup__body {
    padding: 20px;
  }
}

/* Добавить в существующий CSS */

.form-row {
  display: flex;
  gap: 15px;
}

.form-row .form-group {
  flex: 1;
}

.form-section-inner {
  background: white;
  padding: 20px;
  border-radius: 5px;
  border: 1px solid #e9ecef;
  margin-bottom: 20px;
}

.form-section-inner h4 {
  margin-bottom: 15px;
  color: #495057;
  font-size: 1.1rem;
}

.item-image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 5px;
  overflow: hidden;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Additional admin styles: improve form controls and image previews */
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea, .token-input {
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid #dfe4ee;
}

.item-image.preview {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #eef1f6;
}

.admin .actions-row {
  display:flex;gap:8px;align-items:center;
}

/* Responsive spacing for admin forms */
@media (min-width: 992px) {
  .ajax-form { max-width: 800px; }
}

.item-sku, .item-meta {
  display: block;
  font-size: 0.85rem;
  color: #6c757d;
  margin-bottom: 2px;
}

.item-meta {
  margin-top: 5px;
}

.item-excerpt {
  color: #6c757d;
  margin: 8px 0;
  line-height: 1.4;
  font-style: italic;
}

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}
/* Добавляем в конец файла admin.css */

/* Стили для формы смены пароля на странице */
#change-password-section {
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#change-password-section .section-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #dee2e6;
}

#change-password-section h2 {
  color: #495057;
  font-size: 1.3rem;
  margin: 0;
}

#change-password-form .form-group {
  margin-bottom: 15px;
}

#change-password-form .form-actions {
  margin-top: 25px;
  padding-top: 15px;
  border-top: 1px solid #dee2e6;
}

/* Адаптивность для формы смены пароля */
@media (max-width: 768px) {
  #change-password-section {
    margin: 15px 20px !important;
  }
  
  #change-password-section .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  
  #change-password-section h2 {
    font-size: 1.1rem;
  }
}

/* Photos preview inside admin product popup */
.photos-preview {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.photos-preview__item {
  width: 120px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #eef1f6;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.photos-preview__item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.15s ease;
}
.photos-preview__item a { display:block; width:100%; height:100%; }
.photos-preview__empty {
  color: #6c757d;
  font-size: 13px;
}

/* Upload input + hint styles */

.photos-upload input[type="file"] {
  /* keep input accessible but hide default control */
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #667eea;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-size: 0.95rem;
  margin-top: 6px;
}

.btn-upload:hover {
  background: #5a6fd8;
}

.upload-filenames {
  display: inline-block;
  margin-left: 12px;
  font-size: 0.95rem;
  color: #495057;
}

.photos-upload-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #6c757d;
}

/* Small visual indicator while uploading (applied by JS via class) */
.photos-uploading {
  opacity: 0.6;
  pointer-events: none;
}

@media (max-width: 480px) {
  .photos-preview__item { width: 90px; height: 70px; }
}

/* Compact custom multi-select styles */
.custom-multiselect {
  display: inline-block;
  position: relative;
  width: 100%;
  margin-top: 4px;
}
.custom-multiselect .multi-toggle {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #dfe4ee;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #222;
}
.custom-multiselect .multi-toggle.select-empty { color: #9aa3b2; }
.custom-multiselect .multi-toggle:after {
  content: '\25BE';
  float: right;
  color: #667eea;
  font-size: 12px;
}
.custom-multiselect .multi-panel {
  display: none;
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: #fff;
  border: 1px solid #e9eef8;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(102,126,234,0.12);
  max-height: 220px;
  overflow: auto;
  padding: 8px;
}
.custom-multiselect .multi-panel.open { display: block; }
.custom-multiselect .multi-option {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
}
.custom-multiselect .multi-option:hover { background: #f5f8ff; }
.custom-multiselect .multi-option input[type="checkbox"] { margin: 0; }
.custom-multiselect .multi-option span { font-size: 14px; color: #333; }

/* Make sure native multiple selects inside multi-select-wrapper remain hidden but accessible */
.multi-select-wrapper select[multiple] { display: none !important; }

/* Article Content Editor Styles */
.article-content-editor {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 15px;
}

.editor-toolbar {
  background: #f0f0f0;
  border-bottom: 1px solid #ddd;
  padding: 10px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.editor-toolbar button {
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #333 !important;
}

.editor-toolbar button:hover {
  background: #e8e8e8;
  border-color: #999;
}

.editor-content {
  padding: 15px;
  max-height: 600px;
  overflow-y: auto;
  background: white;
}

.content-block {
  margin-bottom: 15px;
  padding: 12px;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 5px;
  position: relative;
}

.content-block-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #ff4444;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

.content-block-remove:hover {
  background: #cc0000;
}

.content-block-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  color: #333 !important;
  background-color: #fff !important;
}

.content-block-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.content-block-input::placeholder {
  color: #999;
}

.content-block textarea {
  min-height: 80px;
  resize: vertical;
}

.content-block-image-preview {
  max-width: 100%;
  max-height: 150px;
  margin-top: 10px;
  border-radius: 4px;
}

.content-block-image-file {
  margin-top: 10px;
}

.content-block-image-file input[type="file"] {
  display: none;
}

.content-block-image-file label {
  display: inline-block;
  padding: 8px 12px;
  background: #667eea;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.content-block-image-file label:hover {
  background: #5568d3;
}

/* Video upload progress */
.video-upload-progress {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.video-progress-bar {
  flex: 1;
  height: 25px;
  border-radius: 4px;
  background: #f0f0f0;
  border: 1px solid #ddd;
}

.video-progress-bar::-webkit-progress-bar {
  background: #f0f0f0;
  border-radius: 4px;
  height: 25px;
}

.video-progress-bar::-webkit-progress-value {
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.video-progress-bar::-moz-progress-bar {
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 4px;
}

.progress-text {
  font-size: 12px;
  color: #666;
  min-width: 40px;
  text-align: right;
}

