/**
 * Customer CSS - StoreGram
 * Стили для клиентской части приложения
 */

/* ==========================================================================
   CSS Variables - Переменные цветов
   ========================================================================== */
:root {
  --bg-primary:       #222b36;
  --bg-surface:       #232e3c;
  --bg-input:         #1a222b;
  --text-primary:     #e6eaf0;
  --text-secondary:   #b0b8c1;
  --text-placeholder: #8a9aad;
  --border-color:     #384656;
  --accent-primary:      #37aee2;
  --accent-primary-dark: #1e96c8;
  --accent-price:     #f8a917;
  --accent-success:   #27ae60;
  --accent-danger:    #e74c3c;
  --accent-warning:   #f39c12;
}

/* ==========================================================================
   Base Styles - Базовые стили
   ========================================================================== */
html {scroll-behavior: smooth;}
body {
  font-family: Arial, sans-serif;
  margin: 20px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

h1, h2 {
  color: var(--text-secondary);
}

form {
  margin-top: 20px;
}

input {
  padding: 8px;
  margin-right: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

button {
  display: inline-block;
  font-weight: 500;
  font-size: 13px;
  line-height: 18px;
  padding: 6px 16px;
  height: 30px;
  border-radius: 7px;
  box-sizing: border-box;
  color: #fff;
  outline: none;
  border: none;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
  box-shadow: 0 2px 8px rgba(55,174,226,0.15);
  cursor: pointer;
  transition: background 0.2s;
}

button:hover, .tg-details-btn:hover {
  background: linear-gradient(90deg, var(--accent-primary-dark) 0%, var(--accent-primary) 100%);
}

/* ==========================================================================
   Layout - Общие классы разметки
   ========================================================================== */

.overlay-base {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(34, 43, 54, 0.85);
  justify-content: center;
  align-items: center;
}

#cart-overlay {
  z-index: 2100;
}

#product-detail-overlay {
  z-index: 2000;
}

.fixed-top-right {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
}

.user-info-centered {
  text-align: center;
  margin-bottom: 20px;
}

.user-info-text {
  font-size: 13px;
  color: var(--text-primary);
}

/* ==========================================================================
   Shop Info - Информация о магазине
   ========================================================================== */

.shop-info {
  display: flex;
  align-items: center;
  flex-direction: column;
}

.shop-info img {
  max-width: 60px;
}

.shop-info h1 {
  font-size: 13px;
  margin: 20px 0px;
  padding: 0px;
  color: #fff;
}

/* ==========================================================================
   Card Component - Компонент карточки
   ========================================================================== */

.card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  background-color: var(--bg-surface);
}

.card h5 {
  color: var(--text-primary);
  margin-bottom: 10px;
  font-size: 14px;
}

.card input[name="search"] {
  width: 100%;
  padding: 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}

.card input[name="search"]:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* ==========================================================================
   Product Form - Форма продукта
   ========================================================================== */

.product-form {
  background-color: var(--bg-surface);
  padding: 20px;
  border-radius: 5px;
  color: var(--text-primary);
}

.form-group input {
  width: 300px;
  padding: 8px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

/* ==========================================================================
   Search - Поиск
   ========================================================================== */

.search-info {
  background: var(--bg-input);
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border: 1px solid var(--border-color);
}

.search-info p {
  margin: 0 0 10px 0;
  color: var(--text-primary);
  font-size: 13px;
}

.search-info button {
  font-size: 12px;
  padding: 4px 12px;
  height: 26px;
}

/* ==========================================================================
   Product List - Список продуктов
   ========================================================================== */

.product-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-content: flex-end;
  margin-bottom: 30px;
  transition: max-height var(--page-animation), opacity var(--page-animation);
}

.product-feed-item {
  position: relative;
  box-sizing: border-box;
  text-align: center;
  align-items: center;
  flex-direction: column;
  justify-content: space-around;
  display: flex;
  padding: 10px;
  margin: 10px 0px;
}

.product-feed-item img {
  position: relative;
  height: 78px;
  border-radius: 10px;
  max-width: 150px;
  max-height: 150px;
  object-fit: cover;
}

.product-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-price);
  margin-top: 5px;
}

/* ==========================================================================
   Product Buttons - Кнопки продукта
   ========================================================================== */

.tg-details-btn {
  display: inline-block;
  font-weight: 600;
  font-size: 14px;
  font-family: Segoe UI;
  line-height: 18px;
  padding: 6px 16px;
  height: 30px;
  border-radius: 7px;
  box-sizing: border-box;
  color: #fff;
  outline: none;
  border: none;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
  box-shadow: 0 2px 8px rgba(55,174,226,0.15);
  cursor: pointer;
  transition: background 0.2s;
  width: 80px;
  margin: 10px 0px;
}

.tg-buy-btn {
  display: inline-block;
  font-weight: 600;
  font-size: 14px;
  font-family: Segoe UI;
  line-height: 18px;
  padding: 6px 16px;
  height: 30px;
  border-radius: 7px;
  box-sizing: border-box;
  color: #fff;
  outline: none;
  border: none;
  background: var(--accent-price);
  box-shadow: 0 2px 8px rgba(40,167,69,0.15);
  cursor: pointer;
  transition: background 0.2s;
  width: 80px;
}

.tg-buy-btn:hover {
  filter: brightness(0.85);
}

/* ==========================================================================
   Quantity Controls - Управление количеством
   ========================================================================== */

.quantity-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 5px;
}

.quantity-display {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent-price);
  height: 22px;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-align: center;
}

.tg-minus-btn, .tg-plus-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-sizing: border-box;
  color: #fff;
  outline: none;
  border: none;
  background: var(--accent-success);
  box-shadow: 0 2px 8px rgba(40,167,69,0.15);
  cursor: pointer;
  transition: background 0.2s;
}

.tg-minus-btn {
  background: var(--accent-danger);
  box-shadow: 0 2px 8px rgba(220,53,69,0.15);
}

.tg-minus-btn:hover {
  filter: brightness(0.85);
}

.tg-plus-btn:hover {
  filter: brightness(0.85);
}

/* ==========================================================================
   Cart Button - Кнопка корзины
   ========================================================================== */

.cart-button {
  display: flex;
  align-items: center;
  font-weight: 500;
  font-size: 13px;
  line-height: 18px;
  width: 40px;
  height: 40px;
  justify-content: center;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
  box-shadow: 0 2px 8px rgba(55,174,226,0.15);
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}

.cart-count-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent-danger);
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  border: 2px solid var(--bg-primary);
  padding: 0 2px;
  box-sizing: border-box;
  pointer-events: none;
  user-select: none;
  cursor: default;
  line-height: 1;
}

.cart-count-badge:empty,
.cart-count-badge[data-count="0"] {
  display: none !important;
}

#cart-count {
  pointer-events: none;
  user-select: none;
  cursor: default;
}

/* ==========================================================================
   Manager Button - Кнопка менеджера
   ========================================================================== */

.manager-button {
  display: flex;
  align-items: center;
  font-weight: 500;
  font-size: 13px;
  line-height: 18px;
  width: 40px;
  height: 40px;
  justify-content: center;
  border-radius: 20px;
  color: #fff;
  background: var(--accent-danger);
  box-shadow: 0 2px 8px rgba(231,76,60,0.15);
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
  border: none;
  text-decoration: none;
}

.manager-button:hover {
  filter: brightness(0.85);
}

/* ==========================================================================
   Modal - Модальные окна
   ========================================================================== */

.product-details-modal, .cart-details-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  padding: 32px;
  min-width: 320px;
  max-width: 90vw;
  min-height: 120px;
  max-height: 90vh;
  overflow: auto;
  position: relative;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
}

#product-detail-overlay:has(.product-details-modal) {
  display: flex !important;
}

#cart-overlay:has(.cart-details-modal) {
  display: flex !important;
}

/* ==========================================================================
   Loading Indicator - Индикатор загрузки
   ========================================================================== */

.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  color: var(--text-primary);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top: 2px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.indicator {
  display: none;
  margin-left: 10px;
}

.htmx-request .indicator {
  display: inline;
}

/* ==========================================================================
   Animations - Анимации (цвета в @keyframes оставлены hardcoded)
   ========================================================================== */

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Анимация при добавлении товара */
.cart-count-badge.animate-add {
  animation: cartBounce 1.2s ease-out, cartGlow 2.5s ease-out;
}

/* Основная анимация подпрыгивания */
@keyframes cartBounce {
  0% {
    transform: scale(1) rotate(0deg);
    background: #e74c3c;
  }
  15% {
    transform: scale(2.5) rotate(-5deg);
    background: #f39c12;
  }
  30% {
    transform: scale(1.8) rotate(3deg);
    background: #27ae60;
  }
  45% {
    transform: scale(2.2) rotate(-2deg);
    background: #3498db;
  }
  60% {
    transform: scale(1.5) rotate(1deg);
    background: #9b59b6;
  }
  75% {
    transform: scale(2.0) rotate(-1deg);
    background: #e67e22;
  }
  90% {
    transform: scale(1.3) rotate(0deg);
    background: #2ecc71;
  }
  100% {
    transform: scale(1) rotate(0deg);
    background: #e74c3c;
  }
}

/* Эффект свечения */
@keyframes cartGlow {
  0% {
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.5);
  }
  20% {
    box-shadow: 0 0 25px rgba(243, 156, 18, 1), 0 0 35px rgba(243, 156, 18, 0.6), 0 0 45px rgba(243, 156, 18, 0.3);
  }
  40% {
    box-shadow: 0 0 30px rgba(39, 174, 96, 1), 0 0 40px rgba(39, 174, 96, 0.6), 0 0 50px rgba(39, 174, 96, 0.3);
  }
  60% {
    box-shadow: 0 0 25px rgba(52, 152, 219, 1), 0 0 35px rgba(52, 152, 219, 0.6), 0 0 45px rgba(52, 152, 219, 0.3);
  }
  80% {
    box-shadow: 0 0 20px rgba(155, 89, 182, 1), 0 0 30px rgba(155, 89, 182, 0.6), 0 0 40px rgba(155, 89, 182, 0.3);
  }
  100% {
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.8), 0 0 20px rgba(231, 76, 60, 0.4);
  }
}

/* Дополнительная анимация пульсации для счетчика */
.cart-count-badge.pulse {
  animation: cartCounterPulse 0.8s ease-out;
}

@keyframes cartCounterPulse {
  0% { transform: scale(1); }
  25% { transform: scale(1.3); }
  50% { transform: scale(1.1); }
  75% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Убираем старую анимацию для кнопки корзины */
.cart-button.pulse {
  /* Убрано - теперь пульсирует только счетчик */
}

@keyframes cartButtonPulse {
  /* Оставляем для совместимости, но не используем */
  0% { transform: scale(1); }
  100% { transform: scale(1); }
}

/* Дополнительный эффект "взрыва" для привлечения внимания */
.cart-button.burst::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: burstEffect 0.6s ease-out;
  pointer-events: none;
}

@keyframes burstEffect {
  0% {
    width: 0;
    height: 0;
    opacity: 1;
  }
  50% {
    width: 80px;
    height: 80px;
    opacity: 0.8;
  }
  100% {
    width: 120px;
    height: 120px;
    opacity: 0;
  }
}

/* ==========================================================================
   Product Details Modal - Модальное окно деталей продукта
   ========================================================================== */

.modal-title {
  color: var(--text-primary);
}

.modal-title-centered {
  color: var(--text-primary);
  text-align: center;
}

.product-details {
  background: none;
  color: var(--text-primary);
}

.product-property {
  margin-bottom: 10px;
}

.product-property .label {
  font-weight: bold;
  color: var(--text-secondary);
}

.product-property .value {
  color: var(--text-primary);
}

.product-image {
  max-width: 200px;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-input);
  margin-top: 10px;
}

.add-to-cart-section {
  margin-top: 20px;
  text-align: center;
}

.quantity-input-group {
  margin-bottom: 16px;
}

.quantity-label {
  color: var(--text-secondary);
  font-weight: bold;
  margin-right: 10px;
}

.quantity-input {
  width: 60px;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  text-align: center;
}

.btn-add-to-cart {
  background: var(--accent-success);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(46,204,113,0.15);
  padding: 12px 24px;
  cursor: pointer;
  margin: 8px;
}

.btn-add-to-cart:hover {
  filter: brightness(1.15);
}

.btn-close-modal {
  margin-top: 24px;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(55,174,226,0.15);
  padding: 10px 24px;
  cursor: pointer;
}

.btn-close-modal:hover {
  background: linear-gradient(90deg, var(--accent-primary-dark) 0%, var(--accent-primary) 100%);
}

.cart-notification {
  margin-top: 16px;
  text-align: center;
}

/* ==========================================================================
   Cart - Корзина
   ========================================================================== */

.cart-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
}

.cart-item {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  padding: 12px;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.cart-item-name {
  flex: 1;
}

.cart-item-name span {
  font-weight: bold;
  color: var(--text-primary);
}

.cart-item-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-quantity-minus {
  background: var(--accent-warning);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.btn-quantity-minus:hover {
  filter: brightness(0.85);
}

.btn-quantity-plus {
  background: var(--accent-success);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
}

.btn-quantity-plus:hover {
  filter: brightness(1.15);
}

.cart-item-quantity {
  color: var(--text-primary);
  font-weight: bold;
  min-width: 25px;
  text-align: center;
  font-size: 14px;
}

.btn-remove-item {
  background: var(--accent-danger);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}

.btn-remove-item:hover {
  filter: brightness(0.85);
}

.cart-summary {
  text-align: center;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.cart-total {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 15px;
}

.cart-comment {
  margin-bottom: 15px;
}

.cart-comment-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}

.cart-comment-input::placeholder {
  color: var(--text-placeholder);
}

.cart-comment-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.btn-clear-cart {
  background: var(--accent-danger);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}

.btn-clear-cart:hover {
  filter: brightness(0.85);
}

.btn-checkout {
  background: linear-gradient(90deg, var(--accent-primary-dark) 0%, var(--accent-primary) 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-checkout:hover {
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
}

.btn-checkout.htmx-request {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-checkout.htmx-request .checkout-spinner {
  display: inline-flex !important;
}

.checkout-spinner {
  display: none;
}

.checkout-spinner svg {
  animation: spin 1s linear infinite;
}

.alert-success {
  margin-top: 15px;
  padding: 10px;
  background: var(--accent-success);
  color: #fff;
  border-radius: 6px;
  text-align: center;
}

.alert-error {
  margin-top: 15px;
  padding: 10px;
  background: var(--accent-danger);
  color: #fff;
  border-radius: 6px;
  text-align: center;
}

.btn-close-cart {
  margin-top: 20px;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(55,174,226,0.15);
  padding: 10px 24px;
  cursor: pointer;
}

.btn-close-cart:hover {
  background: linear-gradient(90deg, var(--accent-primary-dark) 0%, var(--accent-primary) 100%);
}

/* ==========================================================================
   Language Switcher - Переключатель языка
   ========================================================================== */

.language-switcher {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 3000;
}

.language-switcher select {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.language-switcher select:hover {
  border-color: var(--accent-primary);
  background-color: var(--border-color);
}

.language-switcher select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(55, 174, 226, 0.2);
}

/* ==========================================================================
   Product Category - Категории продуктов
   ========================================================================== */
.product-category-group-holder {
  width: 100%;
}
.product-category-group {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  background: none;
  padding: 0;
}

.product-category-group h2 {
  width: 100%;
  margin-bottom: 1rem;
}

.category-buttons {
  position: sticky;
  top: 0;
  z-index: 10;
}