/* ============================================
   TOVARIUM — КОМПОНЕНТИ
   Кнопки, тости, модалки, підказки, форми
   Використовуються на всіх сторінках
   ============================================ */

/* ===== КНОПКИ ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--gradient-btn);
  color: #fff;
  border: none;
}

.btn-primary:hover {
  background: var(--gradient-btn-hover);
  box-shadow: var(--shadow-glow-blue);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-input);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  background: var(--bg-hover);
}

.btn-danger {
  background: rgba(255, 80, 80, 0.1);
  color: #ff5050;
  border: 1px solid rgba(255, 80, 80, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 80, 80, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 12px;
}

.btn-ghost:hover {
  color: var(--neon-blue);
  background: var(--bg-hover);
}

.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 12px; }
.btn-lg { padding: 16px 32px; font-size: 16px; }

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== ТОСТИ (спливаючі повідомлення) ===== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.3s var(--ease-out);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--neon-cyan); }
.toast.error { border-left: 4px solid #ff5050; }
.toast.info { border-left: 4px solid var(--neon-blue); }
.toast.warning { border-left: 4px solid #fbbf24; }

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

/* ===== МОДАЛЬНІ ВІКНА ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--surface-backdrop);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: modalAppear 0.3s var(--ease-out);
}

.modal-wide {
  max-width: 900px;
}

@keyframes modalAppear {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-input);
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ===== ПІДКАЗКИ (tips) ===== */
.tip-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-tooltip);
  background: var(--surface-card);
  border: 1px solid var(--neon-blue);
  border-radius: var(--radius);
  padding: 20px 24px;
  max-width: 380px;
  box-shadow: var(--shadow-glow-blue);
  animation: tipSlideUp 0.4s var(--ease-out);
  display: none;
}

.tip-popup.show {
  display: block;
}

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

.tip-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.tip-popup-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--neon-blue);
}

.tip-popup-close {
  color: var(--text-muted);
  font-size: 18px;
  padding: 0;
  line-height: 1;
}

.tip-popup-close:hover {
  color: var(--text-primary);
}

.tip-popup-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* ===== ФОРМИ ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.form-row .form-group {
  flex: 1;
}

.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-wrap .color-hex {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: monospace;
}

.range-with-value {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-with-value input[type="range"] {
  flex: 1;
}

.range-value {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
  font-family: monospace;
}

/* ===== TOGGLE SWITCH ===== */
.toggle-switch {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--border-primary);
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.toggle-switch.active {
  background: var(--neon-blue);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active::after {
  left: 22px;
}

/* ===== ТЕМА/ПІДКАЗКИ — фіксовані кнопки ===== */
.fixed-btn {
  position: fixed;
  z-index: var(--z-sticky);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-card);
  border: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.fixed-btn:hover {
  border-color: var(--neon-blue);
  box-shadow: var(--shadow-glow-blue);
  transform: scale(1.05);
}

.theme-toggle-btn {
  top: 20px;
  right: 20px;
}

.tips-toggle-btn {
  top: 20px;
  right: 80px;
}

/* ===== СЕКЦІЯ ТАБІВ ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.tab.active {
  background: var(--surface-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tab:hover:not(.active) {
  color: var(--text-secondary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== AI ПАНЕЛЬ ===== */
.ai-panel {
  background: var(--surface-card);
  border: 1px solid var(--neon-purple);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}

.ai-panel-title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--neon-purple);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-loading {
  display: none;
  text-align: center;
  padding: 16px;
  color: var(--neon-purple);
  font-size: 13px;
}

.ai-loading.show {
  display: block;
}

.ai-result {
  display: none;
  background: var(--surface-input);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 13px;
  line-height: 1.8;
  margin-top: 10px;
  white-space: pre-wrap;
  color: var(--text-primary);
}

.ai-result.show {
  display: block;
}

/* ===== SPINNER ===== */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-primary);
  border-top-color: var(--neon-blue);
  border-radius: 50%;
  animation: spinRotate 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spinRotate {
  to { transform: rotate(360deg); }
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-blue {
  background: rgba(0, 212, 255, 0.1);
  color: var(--neon-blue);
}

.badge-purple {
  background: rgba(123, 47, 255, 0.1);
  color: var(--neon-purple);
}

.badge-green {
  background: rgba(0, 255, 213, 0.1);
  color: var(--neon-cyan);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .modal {
    padding: 20px;
    margin: 10px;
    border-radius: var(--radius);
  }

  .btn-lg {
    padding: 12px 24px;
    font-size: 14px;
  }

  .tip-popup {
    left: 16px;
    right: 16px;
    max-width: none;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }
}
