/* -------------------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------------------- */

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

:root {
  --color-bg:           #f5f5f4;
  --color-surface:      #ffffff;
  --color-border:       #e5e5e4;
  --color-border-light: #f0f0ef;
  --color-text:         #1c1917;
  --color-text-muted:   #78716c;
  --color-text-faint:   #a8a29e;
  --color-accent:       #2563eb;
  --color-accent-hover: #1d4ed8;

  /* Status colours */
  --color-2xx-bg:   #f0fdf4;
  --color-2xx-text: #166534;
  --color-2xx-border: #bbf7d0;
  --color-3xx-bg:   #fffbeb;
  --color-3xx-text: #92400e;
  --color-3xx-border: #fde68a;
  --color-4xx-bg:   #fef2f2;
  --color-4xx-text: #991b1b;
  --color-4xx-border: #fecaca;
  --color-5xx-bg:   #fdf4ff;
  --color-5xx-text: #6b21a8;
  --color-5xx-border: #e9d5ff;
  --color-err-bg:   #f5f5f4;
  --color-err-text: #57534e;
  --color-err-border: #d6d3d1;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}


/* -------------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------------- */

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  color: var(--color-text);
}

.logo svg { color: var(--color-accent); flex-shrink: 0; }

main { padding: 32px 0 64px; flex: 1; }

/* -------------------------------------------------------------------------
   Input section
   ------------------------------------------------------------------------- */

.input-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.input-row {
  display: flex;
  gap: 8px;
}

input[type="text"],
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="text"]::placeholder,
textarea::placeholder { color: var(--color-text-faint); }

#url-input { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  padding: 9px 18px;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Primary button */
#check-btn,
.bulk-actions button {
  background: var(--color-accent);
  color: #fff;
}

#check-btn:hover:not(:disabled),
.bulk-actions button:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

/* Bulk toggle */
.bulk-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  padding: 5px 10px;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  font-size: 13px;
}

.bulk-toggle:hover { background: var(--color-bg); }

/* Bulk panel */
.bulk-panel {
  display: none;
  margin-top: 12px;
}

.bulk-panel.open { display: block; }

textarea {
  height: 100px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

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

.bulk-hint { font-size: 12px; color: var(--color-text-faint); }
.bulk-hint-error { color: var(--color-4xx-text); font-weight: 500; }

.bulk-progress {
  font-size: 13px;
  color: var(--color-text-faint);
  padding: 0 0 12px;
}

/* -------------------------------------------------------------------------
   Results
   ------------------------------------------------------------------------- */

.results { display: flex; flex-direction: column; gap: 12px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
}

.empty-state svg { opacity: 0.25; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }
.empty-state small { font-size: 13px; color: var(--color-text-faint); }

/* Result card */
.result-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Card header */
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
}

.card-header:hover { background: var(--color-bg); }

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  flex-shrink: 0;
  min-width: 46px;
  text-align: center;
  letter-spacing: 0.02em;
}

.badge-2xx { background: var(--color-2xx-bg); color: var(--color-2xx-text); border-color: var(--color-2xx-border); }
.badge-3xx { background: var(--color-3xx-bg); color: var(--color-3xx-text); border-color: var(--color-3xx-border); }
.badge-4xx { background: var(--color-4xx-bg); color: var(--color-4xx-text); border-color: var(--color-4xx-border); }
.badge-5xx { background: var(--color-5xx-bg); color: var(--color-5xx-text); border-color: var(--color-5xx-border); }
.badge-err { background: var(--color-err-bg); color: var(--color-err-text); border-color: var(--color-err-border); }

.card-url {
  flex: 1;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.card-duration {
  font-size: 12px;
  color: var(--color-text-faint);
}

.card-chevron {
  color: var(--color-text-faint);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.card-header.open .card-chevron { transform: rotate(180deg); }

/* Loading state */
.card-loading .card-header { cursor: default; }
.card-loading .card-header:hover { background: transparent; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

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

.card-loading-url {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Card body */
.card-body {
  display: none;
  border-top: 1px solid var(--color-border-light);
}

.card-body.open { display: block; }

/* Redirect chain */
.chain-section { padding: 14px 16px; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-faint);
  margin-bottom: 10px;
}

.chain-hops { display: flex; flex-direction: column; gap: 0; }

.chain-hop {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hop-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  padding-top: 2px;
}

.hop-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  min-width: 40px;
  text-align: center;
}

.hop-line {
  width: 1px;
  flex: 1;
  min-height: 14px;
  background: var(--color-border);
  margin: 3px 0;
}

.hop-right { flex: 1; padding-bottom: 12px; overflow: hidden; }
.chain-hop:last-child .hop-right { padding-bottom: 0; }
.chain-hop:last-child .hop-line { display: none; }

.hop-url {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: var(--color-text);
  word-break: break-all;
}

.hop-detail {
  font-size: 11px;
  color: var(--color-text-faint);
  margin-top: 2px;
}

/* Headers table */
.headers-section {
  border-top: 1px solid var(--color-border-light);
  padding: 14px 16px;
}

.headers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.headers-table tr:not(:last-child) td { border-bottom: 1px solid var(--color-border-light); }

.headers-table td {
  padding: 5px 0;
  vertical-align: top;
}

.headers-table td:first-child {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: var(--color-text-muted);
  width: 180px;
  padding-right: 12px;
  white-space: nowrap;
}

.headers-table td:last-child {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: var(--color-text);
  word-break: break-all;
}

/* Card actions */
.card-actions {
  border-top: 1px solid var(--color-border-light);
  padding: 10px 16px;
  display: flex;
  justify-content: flex-end;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-copy:hover { background: var(--color-bg); color: var(--color-text); }
.btn-copy.copied { color: var(--color-2xx-text); border-color: var(--color-2xx-border); background: var(--color-2xx-bg); }

/* Error card */
.card-error {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--color-4xx-text);
  background: var(--color-4xx-bg);
  border-top: 1px solid var(--color-4xx-border);
}

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */

footer {
  margin-top: 48px;
  padding: 16px 0;
  text-align: center;
}

.version-label {
  font-size: 11px;
  color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   Utilities
   ------------------------------------------------------------------------- */

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
