/* App Header */
.app-header {
  position: sticky;
  top: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: var(--glass-border);
  padding: var(--space-4) 0;
  text-align: center;
  z-index: var(--z-sticky);
}

.app-logo {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  background: linear-gradient(135deg, var(--color-primary), var(--color-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
  margin-bottom: var(--space-1);
}

.app-tagline {
  font-size: var(--text-xs);
  color: var(--color-warm-gray);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Screen System */
.screen {
  display: none;
  padding: var(--space-8) 0 var(--space-16);
  min-height: calc(100vh - 100px);
}

.screen.active {
  display: block;
  animation: fadeIn var(--transition-slow);
}

/* Upload Component */
.upload-intro {
  text-align: center;
  margin-bottom: var(--space-8);
}

.upload-intro h2 {
  font-size: var(--text-xl);
}

.upload-intro p {
  color: var(--color-warm-gray);
  font-size: var(--text-sm);
}

.upload-zone {
  border: 2px dashed var(--color-gold);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  background-color: var(--color-white);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-6);
}

.upload-zone:hover, .upload-zone.dragover {
  border: 2px solid var(--color-gold);
  box-shadow: var(--shadow-gold);
  background-color: var(--color-bg);
}

.upload-icon {
  font-size: var(--text-4xl);
  color: var(--color-warm-gray);
  margin-bottom: var(--space-4);
}

.upload-text {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

.upload-hint {
  font-size: var(--text-xs);
  color: var(--color-warm-gray);
}

.image-preview {
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 320px;
  margin: 0 auto var(--space-8);
  box-shadow: var(--shadow-md);
  background-color: var(--color-white);
  padding: var(--space-2);
}

.image-preview img {
  width: 100%;
  height: 320px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.upload-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: center;
}

@media (min-width: 480px) {
  .upload-actions {
    flex-direction: row;
    justify-content: center;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--text-base);
  transition: all var(--transition-fast);
  min-height: 48px; /* Large touch target */
  text-align: center;
  text-decoration: none;
  width: 100%;
}

@media (min-width: 480px) {
  .btn {
    width: auto;
  }
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
  color: var(--color-white);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #e3c04c, #cda01d);
  box-shadow: var(--shadow-gold);
  transform: scale(1.02);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: var(--color-warm-gray);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--color-gold);
  color: var(--color-gold-dark);
}

.btn-secondary:hover {
  background: var(--color-gold);
  color: var(--color-white);
}

.btn-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--color-accent);
}

.btn-icon:hover {
  background: rgba(212, 175, 55, 0.1);
}

/* Loader / Loading States */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-loader);
}

.loader-content {
  text-align: center;
  padding: var(--space-8);
}

.loader-spinner {
  width: 60px;
  height: 60px;
  border: 3px solid rgba(183, 110, 121, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-6);
}

.loader-text {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
  animation: pulse 2s infinite;
}

.loader-subtext {
  font-size: var(--text-sm);
  color: var(--color-warm-gray);
}

.shimmer {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Analysis Results */
.section-title {
  text-align: center;
  margin-bottom: var(--space-8);
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.analysis-card {
  background: var(--color-white);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.analysis-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid rgba(139, 126, 126, 0.2);
  padding-bottom: var(--space-3);
}

.analysis-card-icon {
  font-size: var(--text-2xl);
}

.analysis-card-title {
  font-family: var(--font-heading);
  color: var(--color-primary);
  font-size: var(--text-lg);
  margin-bottom: 0;
}

.analysis-card-body {
  font-size: var(--text-sm);
  color: var(--color-accent);
  margin-bottom: var(--space-4);
}

.analysis-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.analysis-tag {
  background-color: var(--color-secondary);
  color: var(--color-accent);
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-weight: 500;
}

.analysis-tag.positive {
  background-color: rgba(92, 184, 92, 0.15);
  color: #2b542c;
}

.analysis-tag.concern {
  background-color: rgba(217, 83, 79, 0.15);
  color: #843534;
}

.screen-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

/* Premium Report */
.report-container {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-4);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-8);
}

.report-section {
  margin-bottom: var(--space-8);
  border-bottom: 1px solid rgba(139, 126, 126, 0.2);
  padding-bottom: var(--space-6);
}

.report-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.report-section-title {
  font-family: var(--font-heading);
  color: var(--color-primary);
  font-size: var(--text-lg);
  margin-bottom: var(--space-4);
}

.report-content {
  font-size: var(--text-sm);
  color: var(--color-accent);
}

.report-content p {
  margin-bottom: var(--space-4);
}

.report-content ul {
  list-style-type: none;
  margin-bottom: var(--space-4);
}

.report-content ul li {
  position: relative;
  padding-left: var(--space-5);
  margin-bottom: var(--space-2);
}

.report-content ul li::before {
  content: "•";
  color: var(--color-gold);
  position: absolute;
  left: 0;
  font-size: var(--text-lg);
  line-height: 1;
}

.report-content strong {
  color: var(--color-primary);
  font-weight: 600;
}

/* Chat Interface */
#screen-chat {
  padding: 0;
  height: calc(100vh - 100px);
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-bg);
}

.chat-header {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: var(--glass-border);
  z-index: var(--z-sticky);
}

.chat-header h2 {
  margin-bottom: 0;
  font-size: var(--text-lg);
  margin-left: var(--space-2);
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chat-bubble {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  position: relative;
}

.chat-bubble.user {
  align-self: flex-end;
  background-color: var(--color-secondary);
  color: var(--color-accent);
  border-bottom-right-radius: var(--space-1);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background-color: var(--color-white);
  color: var(--color-accent);
  border: var(--glass-border);
  border-bottom-left-radius: var(--space-1);
  box-shadow: var(--shadow-sm);
}

.chat-bubble-content {
  margin-bottom: var(--space-1);
}

.chat-timestamp {
  font-size: 0.65rem;
  color: var(--color-warm-gray);
  text-align: right;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-2) var(--space-4);
  background: var(--color-white);
  border-radius: var(--radius-full);
  align-self: flex-start;
  width: fit-content;
  border: var(--glass-border);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-primary);
  border-radius: 50%;
  animation: typingDot 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: var(--glass-border);
}

.chat-input {
  flex-grow: 1;
  border: 1px solid rgba(139, 126, 126, 0.3);
  border-radius: var(--radius-full);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--color-white);
  transition: all var(--transition-fast);
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.chat-send-btn {
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
  color: var(--color-white);
  box-shadow: var(--shadow-sm);
}

.chat-send-btn:hover {
  background: linear-gradient(135deg, #e3c04c, #cda01d);
  transform: scale(1.05);
}

/* Toast */
.error-toast {
  position: fixed;
  bottom: var(--space-8);
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-accent);
  color: var(--color-white);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  animation: slideUp var(--transition-base);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-muted { color: var(--color-warm-gray); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* Scanner Interface */
.scanner-interface {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.camera-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1;
}

.scanner-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.premium-camera-circle {
  width: 320px;
  height: 320px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.15), inset 0 0 20px rgba(212, 175, 55, 0.2);
  border: 2px solid rgba(212, 175, 55, 0.4);
  background: #000;
  margin-bottom: var(--space-6);
  animation: breatheGlow 4s ease-in-out infinite alternate;
}

@media (max-width: 480px) {
  .premium-camera-circle {
    width: 280px;
    height: 280px;
  }
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror effect */
}

.scanner-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent, rgba(120, 200, 255, 0.9), transparent);
  box-shadow: 0 0 15px rgba(120, 200, 255, 0.8);
  top: 0;
  display: none; /* activated via js */
}

.scanner-line.active {
  display: block;
  animation: intelligentScan 12s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.scanner-instructions {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-6);
}

#scanner-text {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--color-white);
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  margin: 0;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

#scanner-text.visible {
  opacity: 1;
}
