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

:root {
  --bg: #030303;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.15);
  --text-primary: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --accent-cyan: #22d3ee;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --font-heading: "Outfit", sans-serif;
  --font-body: "Inter", sans-serif;
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(168, 85, 247, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(34, 211, 238, 0.05) 0%, transparent 40%);
  z-index: -1;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  opacity: 0.02;
  pointer-events: none;
  z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 24px;
}

.header {
  text-align: center;
  margin-bottom: 48px;
  animation: fadeInDown 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.header h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(to bottom, #fff 30%, rgba(255, 255, 255, 0.7));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.sub {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

.bento-grid {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1200px) {
  .bento-grid {
    grid-template-columns: 1fr 1.5fr;
  }
  .insights-panel {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .bento-grid {
    grid-template-columns: 1fr;
  }
  .insights-panel {
    grid-column: span 1;
  }
}

.card {
  background: var(--surface);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-premium);
  transition: border-color 0.3s ease, transform 0.3s ease;
}

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

.controls-panel .card {
  margin-bottom: 20px;
}

.hero-panel .card {
  height: 100%;
}

.controls {
  display: grid;
  gap: 16px;
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-left: 4px;
}

.file-input-wrapper {
  position: relative;
  cursor: pointer;
}

.file-input-wrapper input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.custom-file-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.file-input-wrapper:hover .custom-file-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-indigo);
}

select, input[type="number"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

select:focus, input[type="number"]:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.hidden {
  display: none !important;
}

.button-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 8px;
}

button {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
}

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

.primary {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  position: relative;
  overflow: hidden;
}

.primary::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: rotate(45deg);
  transition: 0.5s;
}

.primary:hover:not(:disabled)::after {
  left: 100%;
}

.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.hero-panel h2 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-panel h2::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-cyan);
}

.canvas-viewport {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent-cyan);
  box-shadow: 0 0 15px var(--accent-cyan);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

body.is-analyzing .scan-line {
  opacity: 1;
  animation: scan 2s linear infinite;
}

@keyframes scan {
  0% { top: 0; }
  100% { top: 100%; }
}

.status-bar {
  margin-top: 12px;
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

.insights-panel h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.result-hero {
  text-align: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.result-hero .label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.shape {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: var(--font-heading);
  background: linear-gradient(135deg, #fff, var(--accent-indigo));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.confidence {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.metrics-list {
  display: grid;
  gap: 8px;
}

.metric-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}

.metric-item:hover {
  transform: translateX(4px);
  background: rgba(255, 255, 255, 0.04);
}

.metric-item .k { color: var(--text-muted); }
.metric-item .v { font-weight: 600; color: var(--text-primary); }

.details-wrapper {
  margin-top: 24px;
}

details {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.table-container {
  margin-top: 12px;
  overflow-x: auto;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

th, td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 0.7rem;
}

.note {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 8px;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeIn 0.6s ease-out backwards;
}

.controls-panel { animation-delay: 0.1s; }
.hero-panel { animation-delay: 0.2s; }
.insights-panel { animation-delay: 0.3s; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
