/* ============================
   Global base styles
   ============================ */

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

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  background: #0f172a;
  color: #e5e7eb;
}

/* Simple container helper */
.container {
  padding: 1.5rem 2rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Links */
a {
  color: #38bdf8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Monospace helper */
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

/* Small text helpers */
.small {
  font-size: 0.75rem;
}

.muted {
  color: #6b7280;
}

.nowrap {
  white-space: nowrap;
}

/* Pills / tags */
.pill {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
}

.pill-utm {
  border-color: #4b5563;
  color: #fbbf24;
}

.pill-ref {
  border-color: #4b5563;
  color: #38bdf8;
}

.pill-direct {
  border-color: #4b5563;
  color: #22c55e;
}

.pill-tagged {
  border-color: #4b5563;
  color: #f97316;
}

.pill-login {
  border-color: #16a34a;
  color: #bbf7d0;
}

.pill-role {
  border-color: #3b82f6;
  color: #bfdbfe;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #16a34a;
  color: #bbf7d0;
  margin-bottom: 1rem;
}

/* Flash messages */
.flash {
  background: rgba(22, 163, 74, 0.15);
  border: 1px solid #16a34a;
  color: #bbf7d0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

/* ============================
   App header + nav
   (dashboard, visitors, identify)
   ============================ */

.app-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #1f2937;
  background: #020617;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header h1 {
  margin: 0;
  font-size: 1.7rem;
}

.app-header p {
  margin: 0.35rem 0 0;
  color: #9ca3af;
  font-size: 0.95rem;
}

.app-subtitle {
  margin: 0.35rem 0 0;
  color: #9ca3af;
  font-size: 0.95rem;
}

.nav-links {
  font-size: 0.9rem;
}

.nav-links a {
  color: #9ca3af;
  text-decoration: none;
  margin-left: 1rem;
}

.nav-links a:hover {
  color: #e5e7eb;
}

/* ============================
   Dashboard: stats + tables
   ============================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #020617;
  border-radius: 0.75rem;
  padding: 1rem 1.2rem;
  border: 1px solid #1f2937;
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
}

.section-title {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}

/* Tables shared by dashboard + visitors */
.table-wrapper {
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #020617;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid #1f2937;
}

thead {
  background: #0b1120;
}

th,
td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #111827;
}

th {
  font-weight: 500;
  color: #9ca3af;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody tr:nth-child(even),
tbody tr:nth-child(odd) {
  background: #020617;
}

/* ============================
   Auth / login card
   ============================ */

.auth-body {
  background: #020617;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.auth-card {
  background: #0f172a;
  padding: 2rem 2.5rem;
  border-radius: 0.75rem;
  border: 1px solid #1f2937;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.auth-card h1 {
  margin: 0 0 0.75rem;
  font-size: 1.4rem;
}

.auth-card p {
  margin: 0 0 1.5rem;
  color: #9ca3af;
  font-size: 0.9rem;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
}

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border-radius: 0.4rem;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
  box-sizing: border-box;
}

input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

/* Buttons */
.btn,
button {
  display: inline-block;
  padding: 0.65rem 0.8rem;
  border-radius: 0.4rem;
  border: none;
  background: #3b82f6;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn-full {
  width: 100%;
}

button:hover,
.btn:hover {
  background: #2563eb;
}

.error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid #f87171;
  padding: 0.5rem 0.7rem;
  border-radius: 0.45rem;
  font-size: 0.8rem;
  color: #fecaca;
  margin-bottom: 0.8rem;
}

.hint {
  margin-top: 0.9rem;
  font-size: 0.75rem;
  color: #6b7280;
}

/* ============================
   Identify form page
   ============================ */

.identify-body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  background: #0f172a;
  color: #e5e7eb;
}

.identify-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #1f2937;
  background: #020617;
}

.identify-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.identify-header p {
  margin: 0.4rem 0 0;
  color: #9ca3af;
  font-size: 0.95rem;
}

.identify-container {
  max-width: 480px;
  margin: 2.5rem auto;
  padding: 1.5rem 1.75rem 2.25rem;
  background: #020617;
  border-radius: 0.75rem;
  border: 1px solid #1f2937;
}

.identify-notice {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

/* ============================
   Visitors page
   ============================ */

.visitors-container {
  padding: 1.5rem 2rem 3rem;
}

/* ============================
   Landing page (light theme)
   ============================ */
/*
   To use these styles, add classes to your landing template:
   <body class="landing-body">
   <header class="landing-header">...</header>
*/

.landing-body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: #222;
  background: #ffffff;
}

.landing-header {
  background: #1e40af;
  color: white;
  padding: 4rem 2rem;
  text-align: center;
}

.landing-header h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.landing-header p {
  font-size: 1.2rem;
  opacity: 0.9;
  margin-bottom: 2rem;
}

.btn-primary {
  background: #facc15;
  color: #111;
  padding: 0.9rem 2rem;
  border-radius: 0.5rem;
  font-size: 1.1rem;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
}

.btn-primary:hover {
  background: #fde047;
}

.landing-nav {
  margin-top: 1.5rem;
}

.landing-nav a {
  color: rgba(255, 255, 255, 0.8);
  margin: 0 1rem;
  text-decoration: none;
}

.landing-nav a:hover {
  color: #ffffff;
}

.landing-section {
  padding: 4rem 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.landing-section-alt {
  background: #f3f4f6;
}

.landing-section-title {
  font-size: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.landing-footer {
  background: #111;
  color: #aaa;
  padding: 2rem;
  text-align: center;
  margin-top: 3rem;
}

/* ============================
   Utility code styling
   ============================ */

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  background: #020617;
  padding: 0.08rem 0.25rem;
  border-radius: 0.25rem;
  color: #e5e7eb;
}

/* Form Inputs - Improved Visibility */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9375rem;

  background: #20232a;       /* lighter than page bg */
  border: 1px solid #2d323d; /* subtle border */
  color: #ffffff;

  transition: border-color 0.15s ease, background 0.15s ease;
}

input::placeholder {
  color: #8c94a5; /* slightly brighter placeholder */
}

/* Focus state pops more clearly */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  background: #262b35;        /* one step brighter */
  border-color: #3a9ff0;      /* soft blue highlight */
  box-shadow: 0 0 0 1px #3a9ff0;
}

/* Generated links list */

.links-section {
  margin-top: 2.5rem;
}

.links-list {
  margin-top: 1rem;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
}

.link-row + .link-row {
  border-top: 1px solid var(--border-subtle);
}

.link-row-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-row-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.link-row-url {
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron {
  font-size: 0.8rem;
  opacity: 0.8;
}

.link-details {
  display: none;
  padding: 0.75rem 1rem 1rem;
  background: var(--surface-muted, #151822);
}

.link-details.open {
  display: block;
}

.link-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.link-details-table th,
.link-details-table td {
  padding: 0.25rem 0.5rem;
  text-align: left;
}

.link-details-table th {
  font-weight: 500;
  color: color: var(--text-muted, #b8c0d4);
}

.metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary, #1a4dbf); /* dark blue */
  text-decoration: underline;
  cursor: pointer;
}

.copy-url-btn {
  background: #8c94a5;      /* light, same family as card background */
  color: #1c2a4a;           /* your dark blue */
  border: 1px solid rgba(255,255,255,0.4);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
}

.copy-url-btn:hover {
  opacity: 0.85;
}

.metric-label {
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.metric-label:hover {
  opacity: 0.8;
}