/* ============================================================
   DNS Record Visualizer — Premium Dark Theme
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Colors */
  --bg-primary: #0B0E14;
  --bg-secondary: #111620;
  --bg-tertiary: #171D2A;
  --bg-card: rgba(23, 29, 42, 0.7);
  --bg-glass: rgba(23, 29, 42, 0.5);
  --border: rgba(108, 99, 255, 0.15);
  --border-hover: rgba(108, 99, 255, 0.35);
  --text-primary: #E8ECF4;
  --text-secondary: #8892A8;
  --text-muted: #5A6478;
  --accent-1: #6C63FF;
  --accent-2: #00D4AA;
  --accent-3: #FF6B9D;
  --accent-4: #FFBA49;
  --accent-5: #45B7FF;
  --accent-6: #B06CFF;
  --gradient-primary: linear-gradient(135deg, #6C63FF 0%, #00D4AA 100%);
  --gradient-secondary: linear-gradient(135deg, #FF6B9D 0%, #FFBA49 100%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(108, 99, 255, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #F4F6FA;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #EDF0F6;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.6);
  --border: rgba(108, 99, 255, 0.12);
  --border-hover: rgba(108, 99, 255, 0.25);
  --text-primary: #1A1D26;
  --text-secondary: #5A6478;
  --text-muted: #8892A8;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 30px rgba(108, 99, 255, 0.08);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* --- Layout --- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* --- Header --- */
.header {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  display: flex;
  align-items: center;
  animation: spin-slow 20s linear infinite;
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover {
  border-color: var(--border-hover);
  color: var(--accent-1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-icon:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
}

/* --- Search Section --- */
.search-section {
  padding: 64px 0 40px;
  text-align: center;
}

.search-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.search-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 32px;
}

.search-form {
  max-width: 600px;
  margin: 0 auto;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 16px;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-input-wrapper:focus-within {
  border-color: var(--accent-1);
  box-shadow: var(--shadow-glow);
}

.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 12px;
  outline: none;
  min-width: 0;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  padding: 10px 24px;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.search-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
}

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

.search-btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.search-btn.loading .search-btn-text { display: none; }
.search-btn.loading .search-btn-loading { display: inline-block; animation: spin 1s linear infinite; }

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

.quick-domains {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.quick-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quick-btn {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.quick-btn:hover {
  border-color: var(--accent-1);
  color: var(--accent-1);
  background: rgba(108, 99, 255, 0.08);
}

/* --- Error Banner --- */
.error-banner {
  max-width: 600px;
  margin: 0 auto 24px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 107, 157, 0.1);
  border: 1px solid rgba(255, 107, 157, 0.3);
  border-radius: var(--radius-md);
  color: var(--accent-3);
  font-size: 0.9rem;
  animation: slideDown 0.3s ease;
}

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

.error-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--accent-3);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.error-close:hover {
  opacity: 1;
}

/* --- Results Section --- */
.results-section {
  animation: fadeInUp 0.5s ease;
}

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

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
  padding: 16px;
  text-align: center;
  transition: all var(--transition);
  animation: fadeInUp 0.4s ease backwards;
}

.summary-card:nth-child(1) { animation-delay: 0.05s; }
.summary-card:nth-child(2) { animation-delay: 0.1s; }
.summary-card:nth-child(3) { animation-delay: 0.15s; }
.summary-card:nth-child(4) { animation-delay: 0.2s; }
.summary-card:nth-child(5) { animation-delay: 0.25s; }
.summary-card:nth-child(6) { animation-delay: 0.3s; }

.summary-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.summary-card .count {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.summary-card .label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* --- Section Heading --- */
.section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.section-heading svg {
  color: var(--accent-1);
}

/* --- Chain Visualization --- */
.chain-section {
  margin-bottom: 32px;
}

.chain-visual {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 20px 0;
  -webkit-overflow-scrolling: touch;
}

.chain-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  animation: fadeInUp 0.4s ease backwards;
}

.chain-node-box {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
  text-align: center;
  transition: all var(--transition);
  cursor: default;
  min-width: 120px;
}

.chain-node-box:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.chain-node-type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.chain-node-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-primary);
  word-break: break-all;
}

.chain-arrow {
  flex-shrink: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.chain-arrow svg {
  animation: pulse-arrow 2s ease-in-out infinite;
}

@keyframes pulse-arrow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* --- Record Tabs --- */
.records-section {
  margin-bottom: 40px;
}

.record-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.record-tab {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.record-tab:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.record-tab[aria-selected="true"] {
  background: rgba(108, 99, 255, 0.15);
  border-color: var(--accent-1);
  color: var(--accent-1);
}

.record-tab:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
}

.record-tab .tab-count {
  display: inline-block;
  background: rgba(108, 99, 255, 0.15);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.72rem;
  margin-left: 6px;
}

.record-tab[aria-selected="true"] .tab-count {
  background: rgba(108, 99, 255, 0.3);
}

/* --- Record Panel / Table --- */
.record-panel {
  animation: fadeInUp 0.3s ease;
}

.record-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.record-table thead {
  background: var(--bg-tertiary);
}

.record-table th {
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.record-table td {
  padding: 10px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.record-table tr:last-child td {
  border-bottom: none;
}

.record-table tr:hover td {
  background: rgba(108, 99, 255, 0.04);
}

.record-table .mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.record-table .type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.type-a { background: rgba(108, 99, 255, 0.15); color: var(--accent-1); }
.type-aaaa { background: rgba(0, 212, 170, 0.15); color: var(--accent-2); }
.type-cname { background: rgba(255, 107, 157, 0.15); color: var(--accent-3); }
.type-mx { background: rgba(255, 186, 73, 0.15); color: var(--accent-4); }
.type-txt { background: rgba(69, 183, 255, 0.15); color: var(--accent-5); }
.type-ns { background: rgba(176, 108, 255, 0.15); color: var(--accent-6); }

.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --- Keyboard Shortcuts Hint --- */
.shortcuts-hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 8px 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
  z-index: 90;
  transition: all var(--transition);
  white-space: nowrap;
}

.shortcuts-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .main {
    padding: 0 16px 40px;
  }

  .search-section {
    padding: 40px 0 24px;
  }

  .search-title {
    font-size: 1.5rem;
  }

  .search-subtitle {
    font-size: 0.92rem;
  }

  .summary-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .summary-card {
    padding: 12px;
  }

  .summary-card .count {
    font-size: 1.4rem;
  }

  .chain-visual {
    justify-content: flex-start;
    padding: 16px 0;
  }

  .chain-node-box {
    min-width: 100px;
    padding: 10px 14px;
  }

  .shortcuts-hint {
    display: none;
  }

  .record-table th,
  .record-table td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
}

@media (max-width: 480px) {
  .header-content {
    padding: 10px 16px;
  }

  .logo-text {
    font-size: 1rem;
  }

  .search-input-wrapper {
    flex-direction: column;
    padding: 8px;
    gap: 0;
  }

  .search-icon {
    display: none;
  }

  .search-input {
    width: 100%;
    text-align: center;
  }

  .search-btn {
    width: 100%;
  }

  .quick-domains {
    gap: 6px;
  }

  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
