/* UAM Matrix — кольори з ТЗ */
:root {
  --primary: #2196f3;
  --primary-dark: #1976d2;
  --success: #2e7d32;
  --error: #c62828;
  --badge: #ff9800;
  --bg: #f5f5f5;
  --card: #ffffff;
  --copy-bg: #e3f2fd;
  --copy-hover: #bbdefb;
  --copy-done: #c8e6c9;
  --copy-done-color: #2e7d32;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: #333;
  margin: 0;
  padding: 1.5rem;
  line-height: 1.5;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}

h1 {
  color: var(--primary);
  margin-top: 0;
}

.subtitle {
  color: #666;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--card);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.upload-section h2,
.summary-section h2,
.results-section h2 {
  margin-top: 0;
  font-size: 1.1rem;
  color: #444;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--copy-bg);
}

.drop-zone__prompt {
  display: block;
  margin-bottom: 0.75rem;
  color: #666;
}

.file-name {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--primary-dark);
}

.file-name:empty {
  display: none;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-analyze {
  margin-top: 1rem;
  padding: 0.6rem 1.25rem;
  font-weight: 600;
}

/* Режим пошуку — горизонтальні радіо */
.mode-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.mode-switch__label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #555;
}

.mode-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.mode-radio input {
  margin: 0;
}

/* Filters */
.filters {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.filters h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: #555;
}

.filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.filter-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.filter-row span {
  min-width: 90px;
  font-size: 0.9rem;
}

.filter-row input {
  width: 80px;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
}

/* Error block */
.error-block {
  background: #ffebee;
  border-left: 4px solid var(--error);
  color: #b71c1c;
}

/* Summary */
.summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.summary-list li {
  padding: 0.25rem 0;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table th,
.results-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.results-table th {
  background: #fafafa;
  font-weight: 600;
  color: #444;
}

.results-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.results-table th.sortable:hover {
  background: #f0f0f0;
}

.results-table th.sortable .sort-indicator {
  margin-left: 0.25rem;
  font-size: 0.75rem;
  color: var(--primary);
}

.results-table th.sortable[aria-sort="ascending"] .sort-indicator::after {
  content: ' ▲';
}

.results-table th.sortable[aria-sort="descending"] .sort-indicator::after {
  content: ' ▼';
}

.results-table td {
  vertical-align: top;
}

.cell-with-copy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 320px;
}

.cell-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.copy-btn {
  flex-shrink: 0;
  background: var(--copy-bg);
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--primary-dark);
  transition: background 0.2s, color 0.2s;
}

.copy-btn:hover {
  background: var(--copy-hover);
}

.copy-btn.copied {
  background: var(--copy-done);
  color: var(--copy-done-color);
}

.creatives-cell .cell-text {
  max-width: 280px;
}

.badge-count {
  display: inline-block;
  background: var(--badge);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  margin-left: 0.25rem;
  flex-shrink: 0;
}

.roi-positive {
  color: var(--success);
  font-weight: 500;
}

.roi-negative {
  color: var(--error);
  font-weight: 500;
}

@media (max-width: 600px) {
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .results-table th,
  .results-table td {
    padding: 0.5rem;
    font-size: 0.85rem;
  }

  .cell-with-copy {
    max-width: 200px;
  }
}
