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

:root {
  --bg-base: #09090B;
  --bg-surface: #18181A;
  --bg-elevated: #27272A;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --text-primary: #F0F0F0;
  --text-secondary: #888888;
  --text-muted: #555555;
  
  --accent-good: #22C55E;
  --accent-mid: #F59E0B;
  --accent-bad: #EF4444;
}

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

body {
  font-family: 'Helvetica Now', 'Helvetica', 'Arial', sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* Stop whole page scroll, rely on main scroll */
}

a { text-decoration: none; color: inherit; }
button { background: none; border: none; cursor: pointer; font-family: 'Helvetica Now', 'Helvetica', 'Arial', sans-serif; }
input { font-family: 'Helvetica Now', 'Helvetica', 'Arial', sans-serif; }

/* Dashboard Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 8px;
  margin-bottom: 32px;
}
.logo-icon { width: 24px; height: 24px; color: var(--text-primary); }
.logo-text { font-size: 16px; font-weight: 700; color: var(--text-primary); }

.nav-group { margin-bottom: 24px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  transition: all 150ms ease-out;
}
.nav-item.active {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
}
.nav-item:hover:not(.active) { color: var(--text-primary); }

.nav-icon { width: 20px; height: 20px; opacity: 0.8; }

.user-profile {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
}
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-elevated); }
.user-name { font-size: 14px; color: var(--text-primary); font-weight: 500; }
.user-settings { margin-left: auto; color: var(--text-muted); }
.user-settings:hover { color: var(--text-primary); }

/* Main Content */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

/* Top Bar */
.top-bar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background-color: var(--bg-surface);
  flex-shrink: 0;
}

.search-bar {
  display: flex;
  align-items: center;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 36px;
  width: 280px;
  padding: 0 12px;
  transition: border-color 150ms ease-out;
}
.search-bar:focus-within { border-color: var(--border-hover); }
.search-icon { color: var(--text-muted); margin-right: 8px; width: 16px; }
.search-input {
  background: none; border: none; outline: none; color: var(--text-primary);
  font-size: 14px; width: 100%;
}
.search-input::placeholder { color: var(--text-muted); }

.top-actions { display: flex; align-items: center; gap: 16px; }
.bell-icon { color: var(--text-secondary); width: 20px; height: 20px; cursor: pointer; }
.bell-icon:hover { color: var(--text-primary); }
.top-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-elevated); }

/* Dashboard Grid */
.dashboard-grid {
  padding: 24px;
  display: grid;
  grid-template-columns: 4fr 6fr; /* ~40/60 split */
  grid-template-rows: auto 1fr;
  gap: 24px;
  height: max-content;
}

/* Photo Container (Left) */
.photo-panel {
  grid-column: 1;
  grid-row: 1 / 3;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.image-canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background-color: var(--bg-base);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#result-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Upload state */
.upload-placeholder {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 10;
  background-image: linear-gradient(rgba(9, 9, 11, 0.6), rgba(9, 9, 11, 0.8)), url('iconperson.png');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  transition: opacity 150ms ease-out;
}
.upload-placeholder:hover { opacity: 0.85; }
.upload-placeholder.drag-over { border: 2px dashed var(--accent-mid); background-color: rgba(0,0,0,0.8); background-blend-mode: overlay; }
.upload-placeholder.hidden { display: none; }

.upload-icon { width: 48px; height: 48px; color: rgba(255, 255, 255, 0.9); margin-bottom: 16px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.upload-text { font-size: 14px; color: rgba(255, 255, 255, 0.9); font-weight: 500; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }

.photo-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: auto;
}
.photo-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* Analytics Panel (Right - Top) */
.kpi-row {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-top: 1px solid rgba(255,255,255,0.12); /* Gloss edge */
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: border-color 150ms ease-out;
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.4),
    inset 0 1px 1px rgba(255,255,255,0.05); /* Inner gloss */
}
.kpi-card:hover { border-color: var(--border-hover); }

.kpi-content-row { display: flex; justify-content: space-between; align-items: flex-end; }
.speedometer-container { width: 50px; flex-shrink: 0; margin-bottom: 4px; }
.speedometer-svg { display: block; width: 100%; overflow: visible; }

.kpi-label { font-size: 12px; color: var(--text-secondary); letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 8px; font-weight: 600; }
.kpi-value { 
  font-family: 'Helvetica Now Display Bold', 'Helvetica Now Display', 'Helvetica', sans-serif;
  font-size: 32px; font-weight: 700; color: var(--text-primary); line-height: 1.0; margin-bottom: 12px; 
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  width: fit-content;
}
.badge.good { background: rgba(34,197,94,0.15); color: var(--accent-good); }
.badge.mid { background: rgba(245,158,11,0.15); color: var(--accent-mid); }
.badge.bad { background: rgba(239,68,68,0.15); color: var(--accent-bad); }

/* Analytics Panel (Right - Details) */
.details-grid {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-content: start;
}

.detail-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-top: 1px solid rgba(255,255,255,0.12); /* Gloss edge */
  border-radius: 12px;
  padding: 20px;
  transition: border-color 150ms ease-out;
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.4),
    inset 0 1px 1px rgba(255,255,255,0.05); /* Inner gloss */
}
.detail-card:hover { border-color: var(--border-hover); }

.detail-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.detail-ideal { font-size: 12px; color: var(--text-muted); }
.detail-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.detail-value { 
  font-family: 'Helvetica Now Display Bold', 'Helvetica Now Display', 'Helvetica', sans-serif;
  font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1.0; margin-bottom: 16px; 
}

/* Range Bar */
.range-container { width: 100%; position: relative; height: 24px; margin-bottom: 8px; }
.range-track {
  width: 100%; height: 4px; background: var(--bg-elevated); border-radius: 2px;
  position: absolute; top: 10px;
}
.range-ideal-zone {
  position: absolute; height: 4px; top: 10px;
  background: rgba(34,197,94,0.3); border-radius: 2px;
}
.range-marker {
  position: absolute; top: 6px; width: 12px; height: 12px;
  background: #FFF; border-radius: 50%;
  box-shadow: 0 0 8px rgba(255,255,255,0.2);
  margin-left: -6px;
  transition: left 0.8s ease-out, border-color 0.8s ease-out;
  border: 2px solid var(--text-muted); /* overridden by JS based on score */
  box-sizing: content-box;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* Bottom Summary Panel */
.summary-panel {
  grid-column: 1 / -1; /* stretch across both */
  background: var(--bg-surface);
  border-top: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  border-left: 1px solid rgba(255,255,255,0.06);
  border-right: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.4),
    inset 0 1px 1px rgba(255,255,255,0.05); /* Inner gloss */
}
.summary-score { 
  font-family: 'Helvetica Now Display Bold', 'Helvetica Now Display', 'Helvetica', sans-serif;
  font-size: 20px; font-weight: 700; color: var(--text-primary); white-space: nowrap;
}
.summary-text { font-size: 14px; color: var(--text-secondary); }

/* Buttons */
.btn-primary {
  background: #FFFFFF; color: #000000; border-radius: 8px;
  padding: 10px 20px; font-size: 14px; font-weight: 500;
  transition: background 150ms ease-out;
}
.btn-primary:hover { background: #E0E0E0; }

.btn-secondary {
  background: transparent; color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 20px; font-size: 14px; font-weight: 500;
  transition: all 150ms ease-out;
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-elevated); }

/* Loading State */
.skeleton {
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  color: transparent !important;
}
.skeleton * { visibility: hidden; }
.skeleton::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background-image: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,0.02) 20%, rgba(255,255,255,0.05) 60%, rgba(255,255,255,0) 100%);
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.hidden { display: none !important; }

/* Auth Overlay */
.auth-overlay {
  position: fixed; top:0; left:0; width:100%; height:100%;
  background: rgba(9, 9, 11, 0.95);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(10px);
}
.auth-box {
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-top: 1px solid rgba(255,255,255,0.12);
  padding: 40px; border-radius: 16px;
  width: 400px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.05);
}
.auth-logo { width: 48px; height: 48px; margin-bottom: 16px; color: var(--accent-good); }
.auth-box h2 { font-size: 24px; margin-bottom: 8px; color: var(--text-primary); }
.auth-box p { color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }
.g-btn { display: flex; justify-content: center; }

/* View Routing */
.view-section { display: none; padding: 24px; }
.view-section.active { display: block; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* History Grid */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.history-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}
.history-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.history-img { width: 100%; height: 280px; object-fit: contain; background: #000; border-bottom: 1px solid rgba(255,255,255,0.06); }
.history-info { padding: 16px; display: flex; justify-content: space-between; align-items: center; }
.history-date { font-size: 12px; color: var(--text-secondary); }
.history-score { font-family: 'Helvetica Now Display Bold', sans-serif; font-size: 24px; font-weight: 700; color: var(--text-primary); }

/* Welcome Overlay: Glossy Glassmorphism */
.welcome-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(5, 5, 7, 0.3);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: opacity 0.5s ease;
}
.welcome-overlay.hidden {
  opacity: 0; pointer-events: none;
}
.welcome-orb {
  position: absolute; border-radius: 50%; opacity: 0.8;
  animation: orbFloat 10s infinite alternate ease-in-out;
  will-change: transform;
}
.orb-1 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(34,197,94,0.15) 0%, rgba(34,197,94,0) 70%); top: 10%; left: 20%; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(0,212,255,0.1) 0%, rgba(0,212,255,0) 70%); bottom: 10%; right: 10%; animation-delay: -3s; }
.orb-3 { width: 350px; height: 350px; background: radial-gradient(circle, rgba(168,85,247,0.12) 0%, rgba(168,85,247,0) 70%); top: 40%; left: 50%; animation-delay: -5s; }

@keyframes orbFloat { 0% { transform: translateY(0) scale(1); } 100% { transform: translateY(-30px) scale(1.1); } }

/* The Glossy Tile */
.welcome-box {
  position: relative; z-index: 2;
  /* Diagonal glass reflection gradient */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  will-change: backdrop-filter;
  transform: translateZ(0);
  
  /* Enhanced light refraction edges */
  border-top: 1px solid rgba(255,255,255,0.5);
  border-left: 1px solid rgba(255,255,255,0.3);
  border-right: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  border-radius: 24px;
  
  padding: 48px; width: 600px; max-width: 90vw;
  
  /* Stronger inner glare, huge outer depth */
  box-shadow: 
    0 30px 60px rgba(0,0,0,0.6), 
    inset 0 2px 4px rgba(255,255,255,0.4), 
    inset 0 0 20px rgba(255,255,255,0.15);
  
  animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes slideUpFade { 0% { opacity:0; transform: translateY(40px); } 100% { opacity:1; transform: translateY(0); } }

.welcome-title {
  font-family: 'Helvetica Now Display Bold', sans-serif;
  font-size: 36px; margin-bottom: 8px; color: #FFF;
  text-shadow: 0 0 20px rgba(255,255,255,0.3);
}
.welcome-p { font-size: 16px; color: var(--text-secondary); margin-bottom: 32px; }

.welcome-features { display: flex; flex-direction: column; gap: 24px; margin-bottom: 40px; }
.welcome-feat { display: flex; gap: 16px; align-items: flex-start; }
.welcome-feat strong { color: var(--text-primary); font-size: 15px; display: block; margin-bottom: 4px; }
.welcome-feat span { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }

.welcome-btn {
  width: 100%; background: #FFF; color: #000; font-size: 16px; font-weight: 600;
  padding: 16px; border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.welcome-btn:hover {
  background: #E0E0E0; transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(255,255,255,0.1);
}
