/* ============================================
   Modal Styles - Regresolog Content AI
   ============================================ */

/* Основний оверлей модалки */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Контейнер модалки */
.modal-container {
  background: var(--panel, #ffffff);
  border-radius: 28px;
  width: 90%;
  max-width: 1400px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

/* Хедер модалки */
.modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--soft, #f9fafb);
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text, #1f2933);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--muted, #6b7280);
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text, #1f2933);
}

/* Тіло модалки */
.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
  background: #ffffff;
}

/* Футер модалки */
.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border, #e5e7eb);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--soft, #f9fafb);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ============================================
   Таблиці в модалках
   ============================================ */
.modal-table-wrapper {
  overflow-x: auto;
  border-radius: 16px;
  margin-top: 8px;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.modal-table th,
.modal-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #eef0f2;
  vertical-align: top;
}

.modal-table th {
  background: #f8fafc;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  color: #475569;
  letter-spacing: 0.4px;
  border-bottom: 2px solid #e2e8f0;
}

.modal-table tr:hover {
  background: #fafcff;
}

/* Колонка з аналізом */
.analysis-preview {
  max-width: 280px;
  font-size: 12px;
  line-height: 1.45;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================
   Бейджі для Score
   ============================================ */
.score-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

.score-high {
  background: #d1fae5;
  color: #065f46;
}

.score-mid {
  background: #fef3c7;
  color: #92400e;
}

.score-low {
  background: #fee2e2;
  color: #991b1b;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f3f4f6;
  padding: 5px 12px;
  border-radius: 40px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.success {
  background: #d1fae5;
  color: #065f46;
}

.status-badge.error {
  background: #fee2e2;
  color: #991b1b;
}

.status-badge.warning {
  background: #ffedd5;
  color: #92400e;
}

/* ============================================
   Лоадер
   ============================================ */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px;
  color: var(--muted, #6b7280);
  font-size: 14px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: #111;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted, #6b7280);
  font-size: 14px;
}

.empty-state .btn {
  margin-top: 16px;
}

/* ============================================
   Кнопки в модалках
   ============================================ */
.modal-footer .btn {
  padding: 8px 18px;
  font-size: 13px;
}

.modal-table .btn {
  padding: 5px 12px;
  font-size: 11px;
  white-space: nowrap;
}

/* ============================================
   Адаптивність
   ============================================ */
@media (max-width: 768px) {
  .modal-container {
    width: 95%;
    max-height: 92vh;
  }
  
  .modal-header {
    padding: 14px 18px;
  }
  
  .modal-header h3 {
    font-size: 1.2rem;
  }
  
  .modal-body {
    padding: 16px 18px;
  }
  
  .modal-footer {
    padding: 12px 18px;
  }
  
  .modal-table th,
  .modal-table td {
    padding: 8px 10px;
    font-size: 11px;
  }
  
  .analysis-preview {
    max-width: 180px;
  }
  
  .score-badge {
    padding: 2px 8px;
    font-size: 10px;
  }
}

/* ============================================
   Form styles всередині модалок
   ============================================ */
.modal-body .select-input,
.modal-body select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.2s;
}

.modal-body .select-input:focus,
.modal-body select:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 2px rgba(17, 17, 17, 0.1);
}

.modal-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}

.modal-body textarea:focus {
  outline: none;
  border-color: #111;
}

.modal-body label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
  color: #374151;
}