/* ==========================================================================
   ThreadCounty — Enterprise Textile Metrology Platform
   Design System & Core Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-base: #080c14;
  --bg-surface: #0d131f;
  --bg-surface-elevated: #131c2d;
  --bg-surface-hover: #182338;
  
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-active: rgba(59, 130, 246, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-muted: #475569;

  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-base);
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
}

/* ==========================================================================
   Background System (Refined Industrial Precision Grid)
   ========================================================================== */
.bg-precision-grid {
  background-color: #080c14;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(37, 99, 235, 0.08), transparent 70%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(6, 182, 212, 0.04), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  background-attachment: fixed;
}

/* Subtle dot overlay for dropzones & cards */
.bg-dot-matrix {
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 16px 16px;
}

/* ==========================================================================
   Card & Surface Components (Linear / Vercel Aesthetic)
   ========================================================================== */
.tc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.45), inset 0 1px 0 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tc-card:hover {
  border-color: var(--border-strong);
}

.tc-card-elevated {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.6), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

/* High-precision corner crosshairs (Replacing gaudy neon HUD corners) */
.tc-reticle-box {
  position: relative;
}

.tc-reticle-box::before,
.tc-reticle-box::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 2;
  transition: border-color 0.2s ease;
}

.tc-reticle-box::before {
  top: 10px;
  left: 10px;
  border-top: 1.5px solid rgba(255, 255, 255, 0.2);
  border-left: 1.5px solid rgba(255, 255, 255, 0.2);
}

.tc-reticle-box::after {
  bottom: 10px;
  right: 10px;
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.2);
  border-right: 1.5px solid rgba(255, 255, 255, 0.2);
}

.tc-reticle-box:hover::before,
.tc-reticle-box:hover::after {
  border-color: rgba(59, 130, 246, 0.6);
}

/* ==========================================================================
   Buttons & Controls (Stripe / Raycast Precision)
   ========================================================================== */
.tc-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 0.75rem 1.25rem;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  user-select: none;
}

.tc-btn-primary:hover {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-0.5px);
}

.tc-btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tc-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.625rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  user-select: none;
}

.tc-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
  color: #ffffff;
}

.tc-btn-secondary:active {
  background: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   Form Inputs & Selects (Specificity overrides @tailwindcss/forms white reset)
   ========================================================================== */
input.tc-input,
select.tc-input,
textarea.tc-input,
.tc-input {
  width: 100%;
  min-height: 2.5rem;
  background-color: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: #f1f5f9;
  color-scheme: dark;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.25rem;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input.tc-input:hover,
select.tc-input:hover,
.tc-input:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

input.tc-input:focus,
select.tc-input:focus,
textarea.tc-input:focus,
.tc-input:focus {
  border-color: rgba(59, 130, 246, 0.75);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18), inset 0 1px 2px rgba(0, 0, 0, 0.4);
  background-color: #0b111e;
}

input.tc-input::placeholder,
.tc-input::placeholder {
  color: #475569;
}

/* Strip Tailwind/browser input defaults inside composite dark control groups */
.tc-field-group {
  display: flex;
  align-items: center;
  min-height: 2.5rem;
  background-color: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  overflow: hidden;
}

.tc-field-group:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.tc-field-group:focus-within {
  border-color: rgba(59, 130, 246, 0.75);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  background-color: #0b111e;
}

.tc-field-bare {
  background-color: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  color: #f1f5f9 !important;
  color-scheme: dark;
}

.tc-field-bare:focus {
  box-shadow: none !important;
  outline: none !important;
}

.tc-field-bare::placeholder {
  color: #475569 !important;
}

/* ==========================================================================
   Badges & Indicators
   ========================================================================== */
.tc-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

.tc-badge-blue {
  background: rgba(37, 99, 235, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.tc-badge-emerald {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.tc-badge-amber {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.tc-badge-purple {
  background: rgba(168, 85, 247, 0.12);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.25);
}

.tc-badge-neutral {
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Status indicator dot */
.tc-pulse-dot {
  position: relative;
  display: inline-flex;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
}

.tc-pulse-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  opacity: 0.35;
  animation: pulse-ring 2.4s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(2); opacity: 0; }
  100% { transform: scale(0.8); opacity: 0; }
}

/* ==========================================================================
   Optical Scanline Animation (Calm, Subtle Metrology Line)
   ========================================================================== */
.tc-scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.8), rgba(6, 182, 212, 0.9), transparent);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
  pointer-events: none;
  z-index: 10;
  animation: metrology-scan 4.5s ease-in-out infinite;
}

@keyframes metrology-scan {
  0% { top: 0%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* ==========================================================================
   Telemetry Stream Auto-ticker
   ========================================================================== */
.telemetry-ticker {
  animation: ticker-vertical 24s linear infinite;
}

.telemetry-ticker:hover {
  animation-play-state: paused;
}

@keyframes ticker-vertical {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* ==========================================================================
   Table Styling
   ========================================================================== */
.tc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.tc-table th {
  padding: 0.875rem 1.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.tc-table td {
  padding: 1rem 1.25rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-secondary);
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.tc-table tbody tr:hover td {
  background-color: rgba(255, 255, 255, 0.025);
  color: var(--text-primary);
}

/* ==========================================================================
   Scrollbar & Utilities
   ========================================================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #080c14;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Respect Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .tc-scanline,
  .telemetry-ticker {
    animation: none !important;
  }
}
