/* CSS Reset and Variables */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
}

/* Body styling */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--background);
  color: var(--text);
  margin: 0;
  padding: 2rem;
  line-height: 1.5;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header and Logo */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

img {
  width: 120px;
  height: auto;
  transition: transform 0.2s ease;
}

img:hover {
  transform: scale(1.05);
}

/* Heading styling */
h1 {
  background-color: var(--surface);
  color: var(--text);
  padding: 1rem 1.5rem;
  text-align: center;
  margin: 2rem 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 1.875rem;
  font-weight: 700;
  border-left: 4px solid var(--primary);
}

/* Last run timestamp styling */
.last-run {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid var(--border);
}

.last-run strong {
  color: var(--text-light);
}

.last-run span {
  color: var(--text);
}

/* Table container */
.table-wrapper {
  background-color: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 2rem;
}

/* Table styling */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
  font-size: 0.875rem;
}

th {
  background-color: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  padding: 1rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 1rem;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

tr:hover td {
  background-color: #f8fafc;
}

/* Status indicators */
.status-akamai {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: #dbeafe;
  color: #1e40af;
}

.status-akamai::before {
  content: "●";
  margin-right: 0.375rem;
}

/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }
  
  h1 {
    font-size: 1.5rem;
    padding: 0.75rem 1rem;
  }
  
  .table-wrapper {
    margin: 0 -1rem;
    border-radius: 0;
  }
  
  td, th {
    padding: 0.75rem;
  }

  .header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .last-run {
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }
  
  h1 {
    font-size: 1.25rem;
    padding: 0.5rem 0.75rem;
  }
  
  .last-run {
    font-size: 0.875rem;
    padding: 0.75rem;
  }
  
  td, th {
    padding: 0.5rem;
    font-size: 0.75rem;
  }
}

/* Additional styles for aligning last run timestamp and TTL table */
.ttl-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.ttl-container h2 {
  margin: 0;
}

.last-run-ttl {
  margin-left: 20px;
  font-size: 14px;
  color: #333;
}

/* Dashboard Grid */
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.dashboard-card {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.dashboard-card h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text-light);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dashboard-card .value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

/* Domain Groups */
.domain-group {
  background-color: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

.domain-header {
  padding: 1rem;
  background-color: var(--background);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.domain-header:hover {
  background-color: #f1f5f9;
}

.domain-header > span:first-child {
  flex: 1;
  min-width: 0;
}

.domain-content {
  display: none;
  padding: 1rem;
}

.domain-content.active {
  display: block;
}

/* Status Indicators */
.status {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-success {
  background-color: #dcfce7;
  color: #166534;
}

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

.status-akamai {
  background-color: #dbeafe;
  color: #1e40af;
}

.status::before {
  content: "●";
  margin-right: 0.375rem;
}

/* TTL Display */
.ttl-bars {
  background-color: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 2rem;
}

.ttl-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.ttl-entry:last-child {
  border-bottom: none;
}

.ttl-hostname {
  font-weight: 500;
  color: var(--text);
}

.ttl-value {
  color: var(--primary);
  font-weight: 700;
  font-family: monospace;
  font-size: 1.125rem;
  text-align: right;
  min-width: 80px;
}

/* TTL Controls */
.ttl-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.ttl-control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ttl-control-group label {
  font-size: 0.875rem;
  color: var(--text-light);
  font-weight: 500;
}

.ttl-control-group select {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--text);
  font-size: 0.875rem;
}

.ttl-stats {
  margin-left: auto;
  font-size: 0.875rem;
  color: var(--text-light);
  font-weight: 500;
}

/* Enhanced TTL entries */
.ttl-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

.ttl-entry:hover {
  background-color: var(--surface);
}

.ttl-entry:last-child {
  border-bottom: none;
}

.ttl-entry-content {
  flex: 1;
  min-width: 0;
}

.ttl-hostname {
  font-weight: 500;
  color: var(--text);
  display: block;
  margin-bottom: 0.25rem;
}

.ttl-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ttl-timestamp {
  font-size: 0.75rem;
  color: var(--text-light);
}

.ttl-value-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.ttl-category-badge {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ttl-badge-very-short {
  background: #fee2e2;
  color: #dc2626;
}

.ttl-badge-short {
  background: #fef3c7;
  color: #d97706;
}

.ttl-badge-medium {
  background: #dcfce7;
  color: #16a34a;
}

.ttl-badge-long {
  background: #dbeafe;
  color: #2563eb;
}

.ttl-no-results {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
  font-style: italic;
}

/* TTL category styling */
.ttl-category-very-short {
  border-left: 3px solid #dc2626;
}

.ttl-category-short {
  border-left: 3px solid #d97706;
}

.ttl-category-medium {
  border-left: 3px solid #16a34a;
}

.ttl-category-long {
  border-left: 3px solid #2563eb;
}

@media (max-width: 768px) {
  .ttl-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .ttl-control-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
  }
  
  .ttl-stats {
    margin-left: 0;
    text-align: center;
  }
  
  .ttl-entry {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .ttl-value-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 2rem;
}

.timeline-item {
  position: relative;
  padding-bottom: 1.5rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.5rem;
  top: 0.25rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background-color: var(--primary);
}

.timeline-item.error-period::before {
  background-color: var(--danger);
}

.timeline-item::after {
  content: "";
  position: absolute;
  left: -1.15rem;
  top: 1rem;
  width: 0.125rem;
  height: calc(100% - 1rem);
  background-color: var(--border);
}

.timeline-item:last-child::after {
  display: none;
}

.timeline-date {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.timeline-content {
  background-color: var(--surface);
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Error Period Styling */
.error-period .timeline-content {
  border-color: var(--danger);
  background-color: #fef2f2;
}

.error-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.error-message {
  color: var(--danger);
  font-weight: 500;
}

.error-duration {
  font-size: 0.875rem;
  color: var(--text-light);
  padding-left: 1rem;
  border-left: 2px solid var(--danger);
}

.refresh-controls {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    align-items: center;
    padding: 0 20px;
}

.refresh-button {
    padding: 8px 15px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.refresh-button:hover {
    background: var(--primary-dark);
}

.refresh-controls select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--surface);
    cursor: pointer;
}

.refresh-status {
    background: var(--surface);
    padding: 5px 10px;
    border-radius: var(--radius);
    font-size: 0.9em;
    color: var(--success);
    margin-left: auto;
    border: 1px solid var(--border);
}

@media (max-width: 768px) {
    .refresh-controls {
        flex-direction: column;
        align-items: stretch;
        padding: 0 10px;
    }
    
    .refresh-status {
        margin-left: 0;
        margin-top: 10px;
        text-align: center;
    }
}

/* Loading States */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 0.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text);
  backdrop-filter: blur(2px);
  z-index: 1000;
  border-bottom: 1px solid var(--border);
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.loading-overlay.active {
  transform: translateY(0);
}

.loading-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  border: 2px solid var(--primary);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

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

.section-loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.section-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--primary);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
  margin: -0.75rem 0 0 -0.75rem;
}

/* Search and Filter Controls */
.search-filter-container {
  background-color: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Enhanced Search Styles */
.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  outline: none;
  transition: all 0.2s;
  background-color: var(--surface);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 0.75rem;
  color: var(--text-light);
  font-size: 0.875rem;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.search-clear:hover {
  background-color: var(--border);
  color: var(--text);
}

.search-count {
  position: absolute;
  right: 2.75rem;
  font-size: 0.75rem;
  color: var(--text-light);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  background-color: var(--background);
  pointer-events: none;
}

.search-hint {
  position: absolute;
  right: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-light);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  background-color: var(--background);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.search-box:focus-within .search-hint {
  opacity: 1;
}

/* Search Result Highlighting */
.highlight-match {
  white-space: nowrap;
  display: inline;
  background-color: var(--highlight);
  border-radius: 2px;
  padding: 0 2px;
}

/* Improved No Results State */
.no-results {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-light);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.no-results::before {
  content: "🔍";
  font-size: 2rem;
  opacity: 0.5;
}

.no-results .suggestion {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

.filter-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-button {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

@media (max-width: 768px) {
  .search-filter-container {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .filter-controls {
    width: 100%;
    justify-content: center;
  }
}

/* Prevent domain name wrapping */
.domain-header span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nameserver Section Styles */
.dns-nameservers {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}

.ns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.ns-card {
  background: var(--background);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s ease;
}

.ns-card:hover {
  box-shadow: var(--shadow);
}

.ns-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.ns-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

.ns-provider-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.akamai-logo {
  height: 24px;
  width: auto;
  filter: brightness(0);
}

.ns-provider {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.provider-akamai { background: #ee7203; color: white; }
.provider-cloudflare { background: #f97316; color: white; }
.provider-aws { background: #ff9900; color: white; }
.provider-google { background: #4285f4; color: white; }
.provider-azure { background: #0078d4; color: white; }
.provider-ns1 { background: #7c3aed; color: white; }
.provider-dnsimple { background: #10b981; color: white; }
.provider-linode { background: #00b04f; color: white; }
.provider-do { background: #0080ff; color: white; }
.provider-custom { background: var(--text-light); color: white; }

.ns-content {
  color: var(--text);
}

.ns-list {
  margin-bottom: 1rem;
}

.ns-record {
  background: var(--surface);
  padding: 0.5rem;
  margin: 0.25rem 0;
  border-radius: var(--radius);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  color: var(--text);
  border: 1px solid var(--border);
}

.ns-timestamp {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: right;
}

.ns-history {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.ns-history h3 {
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 1rem;
}

.ns-change-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ns-change-item {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.change-hostname {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.change-details {
  display: grid;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.change-from, .change-to {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  color: var(--text-light);
}

.change-from::before {
  content: "→ ";
  color: var(--danger);
}

.change-to::before {
  content: "→ ";
  color: var(--success);
}

.change-time {
  color: var(--text-light);
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

@media (max-width: 768px) {
  .ns-grid {
    grid-template-columns: 1fr;
  }
  
  .ns-header {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  
  .ns-provider-container {
    align-self: flex-end;
  }
  
  .akamai-logo {
    height: 20px;
  }
}
