/* ============================================
   Bulk DR Checker — Dark Theme (Ahrefs-style)
   ============================================ */

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #161625;
  --bg-card: rgba(25, 25, 45, 0.7);
  --bg-card-border: rgba(255, 141, 0, 0.08);
  --bg-hover: rgba(255, 141, 0, 0.04);
  --bg-input: rgba(15, 15, 30, 0.6);

  --text-primary: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #55556e;

  --accent: #FF8D00;
  --accent-light: #FFa940;
  --accent-glow: rgba(255, 141, 0, 0.15);
  --accent-glow-strong: rgba(255, 141, 0, 0.3);

  --dr-high: #22c55e;
  --dr-high-bg: rgba(34, 197, 94, 0.1);
  --dr-mid: #f59e0b;
  --dr-mid-bg: rgba(245, 158, 11, 0.1);
  --dr-low: #ef4444;
  --dr-low-bg: rgba(239, 68, 68, 0.1);

  --border: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(255, 141, 0, 0.4);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 40px rgba(255, 141, 0, 0.06);

  --transition: 0.2s ease;
  /* Системный стек вместо Google Fonts: без внешних запросов и быстрее из РФ */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* Background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 500px;
  background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255, 141, 0, 0.07), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ==================
   Header
   ================== */

#app-header {
  position: relative;
  z-index: 1;
  padding: 48px 24px 24px;
  text-align: center;
}

.header-content h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.header-icon {
  font-size: 1.8rem;
}

.header-subtitle {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 1rem;
  font-weight: 400;
}

/* ==================
   Main
   ================== */

#app-main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 48px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==================
   Cards
   ================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  animation: fadeSlideIn 0.4s ease both;
}

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

/* ==================
   Input Card
   ================== */

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

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.card-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.input-area {
  margin-bottom: 20px;
}

textarea {
  width: 100%;
  height: 180px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  padding: 16px;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder {
  color: var(--text-muted);
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
}

.file-upload-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.domain-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.domain-count.over-limit {
  color: var(--dr-mid);
}

/* Buttons */

.btn-primary {
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.15));
  opacity: 0;
  transition: opacity var(--transition);
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(255, 141, 0, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary:disabled::before {
  display: none;
}

.btn-secondary {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(255, 141, 0, 0.2);
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--accent-glow-strong);
  border-color: var(--accent);
}

/* ==================
   Progress
   ================== */

.progress-card {
  padding: 20px 28px;
}

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

.progress-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.progress-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.btn-stop {
  padding: 6px 12px;
  color: var(--dr-low);
  background: var(--dr-low-bg);
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-stop:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--dr-low);
}

.btn-stop:disabled {
  opacity: 0.5;
  cursor: wait;
}

.progress-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
  border-radius: 3px;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

/* ==================
   Results
   ================== */

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.results-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.results-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.filter-group label {
  font-weight: 500;
}

.filter-group input {
  width: 60px;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  text-align: center;
  transition: border-color var(--transition);
}

.filter-group input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Table */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

thead th {
  background: rgba(15, 15, 30, 0.9);
  backdrop-filter: blur(10px);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
  white-space: nowrap;
}

thead th:hover {
  color: var(--accent);
}

thead th.sorted-asc,
thead th.sorted-desc {
  color: var(--accent);
}

.sort-icon::after {
  content: '';
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
}

th.sorted-asc .sort-icon::after {
  content: '▲';
  opacity: 1;
}

th.sorted-desc .sort-icon::after {
  content: '▼';
  opacity: 1;
}

.col-num {
  width: 50px;
  text-align: center;
}

.col-dr {
  width: 80px;
}

.col-rank {
  width: 130px;
}

.col-status {
  width: 100px;
}

tbody tr {
  transition: background var(--transition);
  animation: rowFadeIn 0.3s ease both;
}

@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

.col-num {
  text-align: center;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* DR Badge */

.dr-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.dr-high {
  color: var(--dr-high);
  background: var(--dr-high-bg);
}

.dr-mid {
  color: var(--dr-mid);
  background: var(--dr-mid-bg);
}

.dr-low {
  color: var(--dr-low);
  background: var(--dr-low-bg);
}

/* Status */

.status-ok {
  color: var(--dr-high);
  font-weight: 500;
}

.status-error {
  color: var(--dr-low);
  font-weight: 500;
  font-size: 0.8rem;
}

.status-pending {
  color: var(--text-muted);
}

.status-skipped {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Domain name styling */
.domain-name {
  font-weight: 500;
  word-break: break-all;
}

/* Rank styling */
.rank-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* Results summary */

.results-summary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.results-summary .stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.results-summary .stat-value {
  font-weight: 700;
  color: var(--text-secondary);
}

/* ==================
   Footer
   ================== */

#app-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 900px;
  margin: 0 auto;
  line-height: 1.6;
}

#app-footer p {
  max-width: 720px;
  margin: 0 auto;
}

#app-footer p + p {
  margin-top: 6px;
}

/* Другие инструменты экосистемы */

.other-tools {
  text-align: left;
  margin-bottom: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.other-tools-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.other-tools-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

#app-footer .other-tools-all {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.other-tools-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

#app-footer .other-tools-list a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 400;
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

#app-footer .other-tools-list a:hover {
  text-decoration: none;
  background: var(--bg-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.other-tools-list .tool-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

#app-footer .other-tools-list a:hover .tool-name {
  color: var(--accent);
}

.other-tools-list .tool-desc {
  font-size: 0.78rem;
  line-height: 1.45;
}

#app-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

#app-footer a:hover {
  text-decoration: underline;
}

/* ==================
   Utility
   ================== */

.hidden {
  display: none !important;
}

/* Spinner for pending */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

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

/* ==================
   Responsive
   ================== */

@media (max-width: 640px) {
  #app-header {
    padding: 32px 16px 16px;
  }

  .header-content h1 {
    font-size: 1.6rem;
  }

  #app-main {
    padding: 0 12px 32px;
  }

  .card {
    padding: 20px 16px;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .results-actions {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-group {
    width: 100%;
  }

  .other-tools-list {
    grid-template-columns: 1fr;
  }

  thead th,
  tbody td {
    padding: 8px 10px;
    font-size: 0.8rem;
  }
}
