/**
 * ClearLabel PWA Styles
 * Dark theme, mobile-first, accessible
 */

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

:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a1a;
  --bg-card: #252525;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --accent: #00d4aa;
  --accent-hover: #00f5c4;
  --danger: #ff4757;
  --warning: #ffa502;
  --success: #2ed573;
  --border: #333333;
  --radius: 12px;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: env(safe-area-inset-bottom, 1rem);
}

/* Header */
header {
  text-align: center;
  padding: 1.5rem 0;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.card.error {
  border-color: var(--danger);
  background: rgba(255, 71, 87, 0.1);
}

/* Scanner */
#scanner-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#scanner-overlay {
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

#scanner-container.active #scanner-overlay {
  opacity: 1;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { border-color: var(--accent); }
  50% { border-color: rgba(0, 212, 170, 0.5); }
}

.scanner-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.hint {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: center;
  margin: 1rem 0 0.5rem;
}

/* Forms */
#manual-form {
  display: flex;
  gap: 0.5rem;
}

input[type="text"] {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

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

/* Buttons */
.btn-primary, .btn-secondary {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
}

.btn-primary:hover, .btn-primary:active {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover, .btn-secondary:active {
  background: var(--border);
}

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

/* Loading */
#loading {
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}

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

/* Results */
#results-content {
  margin-bottom: 1rem;
}

.product-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.product-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.product-brand {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.product-barcode {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Risk Level */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.risk-high {
  background: rgba(255, 71, 87, 0.2);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.risk-medium {
  background: rgba(255, 165, 2, 0.2);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.risk-low {
  background: rgba(46, 213, 115, 0.2);
  color: var(--success);
  border: 1px solid var(--success);
}

.risk-factors {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.risk-factors li {
  margin-left: 1.25rem;
}

/* Alerts */
.alert-section {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.alert-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-section.recalls h3 { color: var(--warning); }
.alert-section.lawsuits h3 { color: var(--accent); }
.alert-section.chemicals h3 { color: var(--danger); }

.alert-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.alert-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.alert-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.alert-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.claim-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.claim-link:hover {
  text-decoration: underline;
}

/* Settlements */
#settlements-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

#settlements-list {
  margin-top: 1rem;
}

.settlement-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.settlement-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.settlement-payout {
  color: var(--accent);
  font-weight: 600;
  font-size: 1.1rem;
}

.settlement-deadline {
  color: var(--warning);
  font-size: 0.85rem;
  margin: 0.25rem 0;
}

/* Health Flags */
.alert-section.health-flags h3 {
  color: #ff6b9d;
}

.hf-name-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
  align-items: center;
}

.hf-severity {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.hf-avoid {
  background: rgba(255, 71, 87, 0.25);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.hf-caution {
  background: rgba(255, 165, 2, 0.25);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.hf-watch {
  background: rgba(255, 235, 59, 0.2);
  color: #fdd835;
  border: 1px solid #fdd835;
}

.hf-category {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.hf-child {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(156, 39, 176, 0.25);
  color: #ce93d8;
  border: 1px solid #ce93d8;
}

.hf-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.hf-why {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 0.375rem;
}

.hf-banned-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.hf-banned-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.hf-banned-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  background: rgba(255, 71, 87, 0.15);
  color: #ff8a80;
  border: 1px solid rgba(255, 71, 87, 0.3);
}

.hf-prop65 {
  font-size: 0.75rem;
  color: var(--warning);
  font-weight: 500;
  margin: 0.25rem 0;
}

.hf-detail-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem 0;
  font-weight: 500;
}

.hf-detail-btn:hover {
  text-decoration: underline;
}

.hf-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 0.375rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.health-flag-item {
  padding: 0.75rem 0;
}

/* Health Flags Browser */
#health-flags-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.hf-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.hf-filter-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.hf-filter-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
  font-weight: 600;
}

.hf-filter-btn:hover:not(.active) {
  border-color: var(--accent);
  color: var(--text-primary);
}

.hf-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.hf-browse-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.hf-empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 1rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.legal {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Mobile optimizations */
@media (max-width: 380px) {
  html {
    font-size: 14px;
  }

  #manual-form {
    flex-direction: column;
  }
}

/* Safe area for notch phones */
@supports (padding: max(0px)) {
  #app {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}
