/* ============== RESET & BASE ============== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --success: #10b981;
  --success-dark: #059669;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-dark: #d97706;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-dark: #2563eb;
  --info-light: #dbeafe;
  --dark: #1e293b;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl:
    0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family:
    "Inter",
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============== HEADER ============== */
.header {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  color: white;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 6px -1px rgb(99 102 241 / 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
}

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

.last-check {
  font-size: 13px;
  opacity: 0.95;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  padding: 7px 16px;
  border-radius: 9999px;
  font-weight: 500;
}

/* ============== STATS BAR ============== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 24px 32px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  opacity: 0;
  transition: var(--transition);
}

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

.stat-card:hover::before {
  opacity: 1;
}

.stat-card:nth-child(1):hover::before {
  background: linear-gradient(90deg, #6366f1, #818cf8);
}
.stat-card:nth-child(2):hover::before {
  background: linear-gradient(90deg, #10b981, #34d399);
}
.stat-card:nth-child(3):hover::before {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.stat-card:nth-child(4):hover::before {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.stat-number {
  font-size: 32px;
  font-weight: 800;
  color: var(--gray-800);
  letter-spacing: -0.025em;
}

.stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============== TOOLBAR ============== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  gap: 0;
}

.input-group input {
  padding: 10px 16px;
  border: 2px solid var(--gray-200);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 14px;
  width: 300px;
  outline: none;
  transition: var(--transition);
  background: white;
  color: var(--gray-800);
}

.input-group input::placeholder {
  color: var(--gray-400);
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.input-group .btn {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============== SEARCH ============== */
.search-bar {
  display: flex;
  gap: 10px;
  padding: 0 32px 16px;
}

.search-bar input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  background: white;
}

.search-bar input::placeholder {
  color: var(--gray-400);
}

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.search-bar select {
  padding: 10px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  background: white;
  cursor: pointer;
  min-width: 180px;
  color: var(--gray-700);
  transition: var(--transition);
}

.search-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

/* ============== BUTTONS ============== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #34d399);
  color: white;
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #10b981);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #f87171);
  color: white;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #ef4444);
}

.btn-info {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: white;
}

.btn-info:hover {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border: 2px solid var(--gray-200);
}

.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-800);
}

.btn-settings {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  color: white;
  font-size: 18px;
  padding: 8px 12px;
  border-radius: 50%;
}

.btn-settings:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: rotate(90deg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  padding: 7px 9px;
  font-size: 14px;
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--primary-50);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}

/* ============== TABLE ============== */
.table-container {
  padding: 0 32px 32px;
}

.domain-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.domain-table thead {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
}

.domain-table th {
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.domain-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.domain-table tbody tr {
  transition: var(--transition);
}

.domain-table tbody tr:hover {
  background: var(--primary-50);
}

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

.domain-table tbody tr.selected {
  background: var(--primary-100);
}

.col-check {
  width: 40px;
  text-align: center;
}

.col-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.col-no {
  width: 50px;
  text-align: center;
  color: var(--gray-400);
  font-weight: 600;
}

.col-domain {
  min-width: 200px;
}

.col-status {
  width: 140px;
  text-align: center;
}

.col-code {
  width: 80px;
  text-align: center;
}

.col-time {
  width: 180px;
  text-align: center;
}

.col-checked {
  width: 160px;
  text-align: center;
}

.col-actions {
  width: 160px;
  text-align: center;
}

.domain-name {
  font-weight: 600;
  color: var(--gray-800);
}

.domain-name a {
  color: var(--gray-800);
  text-decoration: none;
  transition: var(--transition);
}

.domain-name a:hover {
  color: var(--primary);
  text-decoration: none;
}

/* ============== STATUS BADGES ============== */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.status-fast {
  background: var(--success-light);
  color: var(--success-dark);
}

.status-normal {
  background: #ecfdf5;
  color: #047857;
}

.status-slow {
  background: var(--warning-light);
  color: var(--warning-dark);
}

.status-down {
  background: var(--danger-light);
  color: var(--danger-dark);
}

.status-timeout {
  background: #f3e8ff;
  color: #7c3aed;
}

.status-server_error {
  background: #fce7f3;
  color: #be185d;
}

.status-client_error {
  background: #fff7ed;
  color: #c2410c;
}

.status-unknown {
  background: var(--gray-100);
  color: var(--gray-500);
}

.status-invalid {
  background: var(--gray-100);
  color: var(--gray-500);
}

/* ============== RESPONSE TIME BAR ============== */
.response-time {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.time-bar {
  width: 70px;
  height: 6px;
  background: var(--gray-200);
  border-radius: 9999px;
  overflow: hidden;
}

.time-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.time-bar-fill.fast {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.time-bar-fill.normal {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.time-bar-fill.slow {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.time-bar-fill.very-slow {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.time-value {
  font-size: 13px;
  font-weight: 600;
  min-width: 65px;
  color: var(--gray-600);
}

/* ============== ACTION BUTTONS ============== */
.actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

/* ============== EMPTY STATE ============== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-icon {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 15px;
  color: var(--gray-500);
}

/* ============== LOADING ============== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  background: white;
  padding: 48px 56px;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.loading-content p {
  color: var(--gray-600);
  font-weight: 500;
  font-size: 15px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ============== MODAL ============== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-large {
  max-width: 720px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-close:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.modal-body {
  padding: 24px;
}

.modal-body label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-700);
  font-size: 14px;
}

.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="number"],
.modal-body input[type="password"],
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
  color: var(--gray-800);
  background: white;
}

.modal-body input::placeholder,
.modal-body textarea::placeholder {
  color: var(--gray-400);
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.modal-body textarea {
  resize: vertical;
}

.modal-body small {
  display: block;
  margin-top: 4px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Settings form */
.settings-section {
  margin-bottom: 28px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--gray-100);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 13px;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--gray-600);
}

/* ============== TOAST ============== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 500;
  min-width: 320px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(10px);
}

.toast.toast-exit {
  animation: toastOut 0.3s ease forwards;
}

.toast-success {
  background: linear-gradient(135deg, #10b981, #059669);
}

.toast-error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast-info {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.toast-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(80px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(80px) scale(0.95);
  }
}

/* ============== CHECKING ANIMATION ============== */
.checking {
  position: relative;
}

.checking::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.8;
  }
}

.checking .domain-name::after {
  content: " ⏳";
}

/* ============== SCROLLBAR ============== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ============== RESPONSIVE ============== */
@media (max-width: 1024px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    padding: 16px 20px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0 20px 12px;
  }

  .toolbar-left,
  .toolbar-right {
    justify-content: center;
  }

  .input-group input {
    width: 220px;
  }

  .table-container {
    padding: 0 12px 20px;
    overflow-x: auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .header {
    padding: 14px 20px;
  }

  .search-bar {
    padding: 0 20px 12px;
  }
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    text-align: center;
    gap: 10px;
    padding: 16px;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px 16px;
  }

  .stat-card {
    padding: 16px 12px;
  }

  .stat-number {
    font-size: 26px;
  }

  .search-bar {
    flex-direction: column;
    padding: 0 16px 12px;
  }

  .input-group {
    width: 100%;
  }

  .input-group input {
    width: 100%;
    flex: 1;
  }

  .col-code,
  .col-checked {
    display: none;
  }

  .domain-table th,
  .domain-table td {
    padding: 10px 8px;
    font-size: 13px;
  }

  .toast {
    min-width: auto;
    margin-left: 20px;
  }
}
