/* SIFT Verifier PWA Styles */

:root {
  --gold: #d2aa28;
  --gold-bright: #e1be50;
  --gold-dark: #a88820;
  --dark: #0a0a0a;
  --dark-secondary: #1a1a1f;
  --dark-tertiary: #2d2d32;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
  --blue: #697d9b;
  
  --radius: 12px;
  --radius-sm: 8px;
  --spacing: 16px;
  --header-height: 56px;
  --nav-height: 64px;
  
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

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

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-height);
  padding: 0 var(--spacing);
  background: var(--dark-secondary);
  border-bottom: 1px solid var(--dark-tertiary);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--gold);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
}

.status-dot.online {
  background: var(--success);
}

/* Main content */
.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.section {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.section.active {
  opacity: 1;
  pointer-events: auto;
}

.section.hidden {
  display: none;
}

/* Camera section */
#camera-section {
  background: #000;
}

.camera-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.targeting-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 70vmin;
  height: 70vmin;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.targeting-reticle svg {
  width: 100%;
  height: 100%;
}

.scanning-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--gold);
  font-size: 14px;
}

.scanning-indicator.hidden {
  display: none;
}

.scanning-ring {
  width: 80px;
  height: 80px;
  border: 3px solid transparent;
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.camera-controls {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.btn-capture {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gold);
  border: 4px solid var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.1s ease;
}

.btn-capture:active {
  transform: scale(0.95);
  background: var(--gold-dark);
}

.btn-capture svg {
  width: 32px;
  height: 32px;
  color: var(--dark);
}

.instructions {
  padding: 16px;
  text-align: center;
  background: var(--dark-secondary);
}

.instructions p {
  font-size: 14px;
}

.instructions .hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Result section */
#result-section {
  padding: var(--spacing);
  background: var(--dark);
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.result-card {
  width: 100%;
  max-width: 400px;
  background: var(--dark-secondary);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-header {
  padding: 24px;
  text-align: center;
}

.result-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-icon.success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.result-icon.warning {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning);
}

.result-icon.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.result-icon svg {
  width: 48px;
  height: 48px;
}

.result-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.result-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.result-details {
  padding: 16px 24px;
  border-top: 1px solid var(--dark-tertiary);
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}

.result-row .label {
  color: var(--text-secondary);
}

.result-row .value {
  font-family: 'SF Mono', Consolas, monospace;
  color: var(--text-primary);
}

.result-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex: 1;
}

.btn-primary {
  background: var(--gold);
  color: var(--dark);
}

.btn-primary:hover {
  background: var(--gold-bright);
}

.btn-secondary {
  background: var(--dark-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: #3d3d42;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--dark-tertiary);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
}

.btn-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.btn-close:hover {
  background: var(--dark-tertiary);
  color: var(--text-primary);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing);
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  background: var(--dark-secondary);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--dark-tertiary);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--dark-tertiary);
  font-size: 14px;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-item .label {
  color: var(--text-secondary);
}

.detail-item .value {
  font-family: 'SF Mono', Consolas, monospace;
  word-break: break-all;
  text-align: right;
  max-width: 60%;
}

.detail-item .value.match {
  color: var(--success);
}

.detail-item .value.mismatch {
  color: var(--error);
}

/* Settings section */
#settings-section {
  padding: var(--spacing);
  overflow-y: auto;
}

#settings-section h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
}

.settings-group {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--dark-secondary);
  border-radius: var(--radius);
}

.settings-group h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--dark-tertiary);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item label {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-item input[type="text"],
.setting-item input[type="password"],
.setting-item input[type="number"] {
  width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--dark-tertiary);
  border-radius: var(--radius-sm);
  background: var(--dark);
  color: var(--text-primary);
  font-size: 14px;
}

.setting-item input[type="text"]:focus,
.setting-item input[type="password"]:focus,
.setting-item input[type="number"]:focus {
  border-color: var(--gold);
  outline: none;
}

.setting-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
}

/* Bottom navigation */
.app-nav {
  display: flex;
  height: var(--nav-height);
  background: var(--dark-secondary);
  border-top: 1px solid var(--dark-tertiary);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item.active {
  color: var(--gold);
}

.nav-item:not(.active):hover {
  color: var(--text-primary);
}

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

/* Responsive */
@media (max-height: 600px) {
  .camera-controls {
    padding: 12px;
  }
  
  .btn-capture {
    width: 56px;
    height: 56px;
  }
  
  .btn-capture svg {
    width: 24px;
    height: 24px;
  }
  
  .instructions {
    padding: 8px;
  }
}

/* Decode feedback styles */
.decode-badge {
  display: inline-block;
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  margin-top: 8px;
}

.result-issues {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  padding: 12px;
  margin: 16px 0;
}

.issue-item {
  color: #f59e0b;
  font-size: 0.9rem;
  padding: 4px 0;
}

.mono {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.85em;
  word-break: break-all;
}

.result-row .value.mono {
  font-size: 0.75rem;
}

.detail-item .value.mono {
  font-size: 0.8rem;
  word-break: break-all;
}

/* Debug log styles */
.debug-log {
  margin-top: 16px;
  padding: 16px;
  background: #1a1a1a;
  border-radius: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.debug-log h3 {
  margin: 0 0 12px 0;
  color: #888;
  font-size: 0.9rem;
}

.debug-log pre {
  margin: 0;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #aaa;
  white-space: pre-wrap;
  word-break: break-all;
}

.debug-log .log-decoder { color: #22c55e; }
.debug-log .log-perspective { color: #3b82f6; }
.debug-log .log-debug { color: #f59e0b; }
.debug-log .log-error { color: #ef4444; }

.modal-footer {
  padding: 12px 0;
  border-top: 1px solid #333;
  margin-top: 16px;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

/* Brightness control */
.brightness-control {
  margin-top: 12px;
  padding: 0 20px;
}

.brightness-control label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #888;
  font-size: 0.9rem;
}

.brightness-control input[type="range"] {
  flex: 1;
  height: 4px;
  background: #333;
  border-radius: 2px;
  -webkit-appearance: none;
  appearance: none;
}

.brightness-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #d2aa28;
  border-radius: 50%;
  cursor: pointer;
}

.brightness-control #brightness-value {
  min-width: 35px;
  text-align: right;
  font-family: monospace;
}

.brightness-control .hint {
  margin-top: 4px;
  font-size: 0.75rem;
  text-align: center;
}

/* Photo select button */
.btn-photo {
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.debug-log .log-server { color: #a855f7; }
