/* ============================================================
   components.css – ОБЩИЕ КОМПОНЕНТЫ (кнопки, таблицы, бейджи, формы, тосты, пагинация)
   ============================================================ */

/* ---- 1. КНОПКИ ---- */
.action-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.action-button:hover {
  background: var(--accent-hover);
}
.action-button.secondary {
  background: var(--border-color);
  color: var(--text-primary);
}
.action-button.secondary:hover {
  background: #cbd5e1;
}
body.dark-theme .action-button.secondary:hover {
  background: #475569;
}
.action-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---- 2. ТАБЛИЦЫ (стиль Bootstrap) ---- */
.bootstrap-table {
  width: 100%;
  border-collapse: collapse;
}
.bootstrap-table th,
.bootstrap-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.bootstrap-table th {
  font-weight: 600;
  background: var(--border-color);
}
.clickable-row {
  cursor: pointer;
  transition: background 0.15s;
}
.clickable-row:hover {
  background: rgba(0,0,0,0.03);
}
body.dark-theme .clickable-row:hover {
  background: rgba(255,255,255,0.05);
}

/* ---- 3. БЕЙДЖИ СТАТУСОВ (общие цвета) ---- */
.badge-status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
/* Базовые цвета (будут переопределены в зависимости от статуса) */
.badge-status.created,
.badge-status.draft,
.badge-status.archived {
  background: #e2e8f0;
  color: #475569;
}
.badge-status.awaiting_offer,
.badge-status.awaiting_agreement,
.badge-status.waiting,
.badge-status.pending {
  background: #fef3c7;
  color: #92400e;
}
.badge-status.awaiting_invoice,
.badge-status.awaiting_prepayment,
.badge-status.awaiting_receipt,
.badge-status.sent,
.badge-status.new {
  background: #dbeafe;
  color: #1e40af;
}
.badge-status.in_queue {
  background: #e0e7ff;
  color: #3730a3;
}
.badge-status.in_progress,
.badge-status.available,
.badge-status.completed,
.badge-status.accepted,
.badge-status.signed,
.badge-status.approved,
.badge-status.paid,
.badge-status.issued {
  background: #d1fae5;
  color: #065f46;
}
.badge-status.awaiting_review,
.badge-status.awaiting_act {
  background: #fef3c7;
  color: #92400e;
}
.badge-status.cancelled,
.badge-status.expired,
.badge-status.rejected {
  background: #fee2e2;
  color: #991b1b;
}

/* Тёмная тема для бейджей */
body.dark-theme .badge-status.created,
body.dark-theme .badge-status.draft,
body.dark-theme .badge-status.archived {
  background: #334155;
  color: #94a3b8;
}
body.dark-theme .badge-status.awaiting_offer,
body.dark-theme .badge-status.awaiting_agreement,
body.dark-theme .badge-status.waiting,
body.dark-theme .badge-status.pending {
  background: #78350f;
  color: #fcd34d;
}
body.dark-theme .badge-status.awaiting_invoice,
body.dark-theme .badge-status.awaiting_prepayment,
body.dark-theme .badge-status.awaiting_receipt,
body.dark-theme .badge-status.sent,
body.dark-theme .badge-status.new {
  background: #1e3a5f;
  color: #93c5fd;
}
body.dark-theme .badge-status.in_queue {
  background: #2e2a5e;
  color: #a5b4fc;
}
body.dark-theme .badge-status.in_progress,
body.dark-theme .badge-status.available,
body.dark-theme .badge-status.completed,
body.dark-theme .badge-status.accepted,
body.dark-theme .badge-status.signed,
body.dark-theme .badge-status.approved,
body.dark-theme .badge-status.paid,
body.dark-theme .badge-status.issued {
  background: #064e3b;
  color: #6ee7b7;
}
body.dark-theme .badge-status.awaiting_review,
body.dark-theme .badge-status.awaiting_act {
  background: #78350f;
  color: #fcd34d;
}
body.dark-theme .badge-status.cancelled,
body.dark-theme .badge-status.expired,
body.dark-theme .badge-status.rejected {
  background: #7f1d1d;
  color: #fca5a5;
}

/* ---- 4. КНОПКИ-ССЫЛКИ В ТАБЛИЦАХ ---- */
.btn-link-table {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 13px;
  text-decoration: underline;
  transition: 0.2s;
}
.btn-link-table:hover {
  color: var(--accent-hover);
}

/* ---- 5. ПУСТОЕ СОСТОЯНИЕ ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  text-align: center;
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state .empty-text {
  font-size: 16px;
  font-weight: 500;
}

/* ---- 6. ВКЛАДКИ В РАЗДЕЛАХ ---- */
.section-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}
.section-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: 0.2s;
}
.section-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.section-header-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

/* ---- 7. ИКОНКИ ДЕЙСТВИЙ В ТАБЛИЦАХ (КП) ---- */
.actions-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  cursor: pointer;
  transition: opacity 0.2s;
}
.action-icon:hover {
  opacity: 0.7;
}
.action-icon img {
  max-width: 20px;
  max-height: 20px;
  display: block;
}
body.dark-theme .action-icon img {
  filter: brightness(0) invert(1);
}

/* ---- 8. ФИЛЬТРЫ (общие поля ввода) ---- */
.filter-input,
.filter-select {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: 0.2s;
  box-sizing: border-box;
}
.filter-input:focus,
.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139,92,246,0.2);
}
.reset-filters-btn {
  background: none;
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
  color: var(--text-primary);
  white-space: nowrap;
}
.reset-filters-btn:hover {
  background: rgba(0,0,0,0.05);
}
body.dark-theme .reset-filters-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* ---- 9. ЗАГРУЗЧИК (волна) ---- */
.loading-wave-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}
.loading-wave {
  display: flex;
  gap: 4px;
}
.loading-bar {
  width: 8px;
  height: 30px;
  background: var(--accent);
  animation: wave 0.8s ease-in-out infinite;
}
.loading-bar:nth-child(2) {
  animation-delay: 0.1s;
}
.loading-bar:nth-child(3) {
  animation-delay: 0.2s;
}
.loading-bar:nth-child(4) {
  animation-delay: 0.3s;
}
@keyframes wave {
  0%, 100% { height: 10px; }
  50% { height: 30px; }
}

/* ---- 10. КНОПКА "ЗАГРУЗИТЬ ЕЩЁ" ---- */
.load-more-btn {
  display: inline-block;
  width: auto;
  padding: 6px 20px;
  margin: 10px auto 0;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 40px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  color: var(--text-primary);
  text-align: center;
}
.load-more-btn:hover {
  background: rgba(0,0,0,0.05);
}
body.dark-theme .load-more-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* ---- 11. СИСТЕМНАЯ ПОДСКАЗКА (персонаж-ассистент) ---- */
.system-tip-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px 20px 20px 120px;
  position: relative;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 120px;
}
.tip-avatar {
  position: absolute;
  left: 0px;
  top: -15px;
  width: 130px;
  height: 130px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: transparent;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}
.tip-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tip-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}
.tip-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.tip-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  flex: 1;
}
.tip-button {
  padding: 6px 16px;
  font-size: 13px;
  flex-shrink: 0;
}
.tip-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  transition: 0.2s;
  line-height: 1;
}
.tip-close:hover {
  color: var(--text-primary);
}
.system-tips-container {
  margin: 0;
  padding: 0;
  display: block;
}
.system-tips-container[style*="display: none"] {
  display: none !important;
}

/* ---- 12. СТАТУС-БАР (таймлайн) ---- */
.status-bar {
  position: relative;
  padding: 16px 0 10px 0;
  margin-bottom: 12px;
  background: var(--card-bg);
  border-radius: 10px;
  display: block;
}
.status-bar-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 10px;
  position: relative;
  z-index: 1;
}
.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  position: relative;
  padding: 0 4px;
}
.status-item.current {
  flex: 0 0 auto;
}
.status-item.empty {
  flex: 0 0 0 !important;
  visibility: hidden !important;
  padding: 0 !important;
  margin: 0 !important;
  min-width: 0 !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}
.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border-color);
  border: 2px solid var(--border-color);
  transition: 0.3s;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.status-dot.active {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(139,92,246,0.2);
}
.status-dot.empty-dot {
  display: none !important;
}
.status-label {
  font-size: 11px;
  text-align: center;
  color: var(--text-secondary);
  transition: 0.3s;
  line-height: 1.2;
  max-width: 80px;
  word-wrap: break-word;
}
.status-label.active {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}
.status-label.empty-label {
  display: none !important;
}
.status-bar-line {
  flex: 1 1 30px;
  height: 2px;
  background: var(--border-color);
  min-width: 20px;
  position: relative;
  top: -9px;
}
.status-bar-line.empty-line {
  flex: 0 0 0 !important;
  min-width: 0 !important;
  width: 0 !important;
  visibility: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
}
body.dark-theme .status-bar-line {
  background: var(--border-color);
}
body.dark-theme .status-dot {
  background: var(--border-color);
  border-color: var(--border-color);
}
body.dark-theme .status-dot.active {
  background: var(--accent);
  border-color: var(--accent);
}
body.dark-theme .status-label {
  color: var(--text-secondary);
}
body.dark-theme .status-label.active {
  color: var(--accent);
}

/* ---- 13. ВСПОМОГАТЕЛЬНЫЙ КЛАСС ДЛЯ СВОРАЧИВАНИЯ ФИЛЬТРОВ ---- */
.filter-roll-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  transition: background 0.2s;
}
.filter-roll-btn:hover {
  background: rgba(0,0,0,0.05);
}
body.dark-theme .filter-roll-btn:hover {
  background: rgba(255,255,255,0.1);
}
.filter-roll-btn .roll-icon {
  display: block;
  width: 24px;
  height: 24px;
  background: url('/images/icons/roll.png') no-repeat center;
  background-size: contain;
  transition: transform 0.3s;
}
.filter-roll-btn .roll-icon.collapsed {
  transform: rotate(180deg);
}
body.dark-theme .filter-roll-btn .roll-icon {
  filter: brightness(0) invert(1);
}

/* ---- СЛАЙДЕР ПОДСКАЗОК (ассистент) ---- */
.system-tips-container {
  display: block;
  margin-bottom: 12px;
}

.system-tip-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px 20px 20px 120px;
  position: relative;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 120px;
}

.tip-avatar {
  position: absolute;
  left: 0px;
  top: -15px;
  width: 130px;
  height: 130px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: transparent;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

.tip-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tip-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.tip-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tip-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  flex: 1;
}

.tip-button {
  padding: 6px 16px;
  font-size: 13px;
  flex-shrink: 0;
}

.tip-navigation {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tip-nav-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.tip-nav-btn:hover {
  background: rgba(0,0,0,0.05);
}
body.dark-theme .tip-nav-btn:hover {
  background: rgba(255,255,255,0.1);
}

.tip-counter {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: center;
}

.tip-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  transition: 0.2s;
  line-height: 1;
}
.tip-close:hover {
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .system-tip-card {
    padding: 16px 16px 16px 90px;
    flex-wrap: wrap;
    min-height: 100px;
  }
  .tip-avatar {
    width: 70px;
    height: 70px;
    left: 12px;
    top: -10px;
  }
  .tip-content {
    flex: 1 1 100%;
  }
  .tip-row {
    flex-direction: column;
    align-items: stretch;
  }
  .tip-button {
    width: 100%;
    text-align: center;
  }
  .tip-navigation {
    margin-top: 8px;
    justify-content: flex-end;
    width: 100%;
  }
}