/* QR Code Scanner — page specific overrides (uses variables from main.css) */
.tool-container { padding: 80px 0; min-height: calc(100vh - 200px); }
.tool-header { text-align:center; margin-bottom: 40px; }
.tool-header h1 { font-size: 2.2rem; margin-bottom: 8px; color: var(--text); }
.tool-header p { color: var(--text-light); }

.scanner-container {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 30px;
  margin-bottom: 60px;
}

.scanner-controls, .scanner-preview, .tool-info {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}
.scanner-preview { 
  display: flex; 
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.scanner-header, .preview-header {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: 2px solid rgba(227,6,19,.2);
}

/* Tabs */
.scanning-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 20px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  background: #f8fafc;
  border: none;
  padding: 12px 16px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-btn:hover {
  background: #eef2f7;
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* Camera Controls */
.camera-controls {
  margin-bottom: 20px;
}

.camera-permission {
  text-align: center;
  padding: 20px;
  background: #f8fafc;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.camera-permission p {
  margin-bottom: 15px;
  color: var(--text-light);
}

.camera-options {
  padding: 15px;
  background: #f8fafc;
  border-radius: var(--radius);
}

.option-group {
  margin-bottom: 15px;
}

.option-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: .9rem;
}

.option-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  background: #fff;
  font-size: .95rem;
}

.option-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(227,6,19,.1);
}

.option-group label[for="torch-toggle"] {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
}

.option-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* Upload Controls */
.upload-controls {
  margin-bottom: 20px;
}

.upload-area {
  border: 2px dashed #e5e7eb;
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  margin-bottom: 20px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.upload-area:hover {
  border-color: var(--primary);
  background: rgba(227,6,19,.02);
}

.upload-area.dragover {
  border-color: var(--primary);
  background: rgba(227,6,19,.05);
}

.upload-area i {
  font-size: 3rem;
  color: #e5e7eb;
  margin-bottom: 10px;
}

.upload-area h4 {
  margin-bottom: 8px;
  color: var(--text);
}

.upload-area p {
  color: var(--text-light);
  margin-bottom: 15px;
}

.upload-area input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.supported-formats {
  padding: 15px;
  background: #f8fafc;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-light);
}

.supported-formats p {
  margin-bottom: 5px;
}

/* Scanning Tips */
.scanning-tips {
  padding: 15px;
  background: #f0f9ff;
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
}

.scanning-tips h4 {
  margin-bottom: 10px;
  color: var(--primary);
}

.scanning-tips ul {
  margin-left: 20px;
  color: var(--text-light);
}

.scanning-tips li {
  margin-bottom: 5px;
}

/* Scan Results */
.scan-results {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

.scan-results h4 {
  margin-bottom: 15px;
}

.result-content {
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 15px;
}

.result-type {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.type-label {
  font-weight: 600;
  margin-right: 8px;
}

.type-value {
  background: var(--primary);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.result-data label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: .9rem;
}

.result-data textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  background: #fff;
  font-size: .95rem;
  resize: vertical;
  min-height: 80px;
  margin-bottom: 12px;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.result-actions .btn-secondary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Scanner Preview */
.preview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.scanner-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 400px;
}

.empty-scanner {
  text-align: center;
  color: white;
  z-index: 1;
}

.empty-scanner i {
  font-size: 4rem;
  margin-bottom: 15px;
  opacity: 0.7;
}

.empty-scanner p {
  margin-bottom: 20px;
  opacity: 0.8;
}

.scanner-guide {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.guide-frame {
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(255,255,255,0.5);
  border-radius: 12px;
}

#video-element,
#image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#video-element.active,
#image-preview.active {
  display: block;
}

/* Scanner Overlay */
.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  display: none; /* Hidden by default */
}

.scanner-overlay.active {
  display: block; /* Show only when camera is active */
}

.scan-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border: 2px solid rgba(255,255,255,0.8);
  border-radius: 12px;
}

.frame-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid var(--primary);
}

.frame-corner.top-left {
  top: -3px;
  left: -3px;
  border-right: none;
  border-bottom: none;
  border-radius: 8px 0 0 0;
}

.frame-corner.top-right {
  top: -3px;
  right: -3px;
  border-left: none;
  border-bottom: none;
  border-radius: 0 8px 0 0;
}

.frame-corner.bottom-left {
  bottom: -3px;
  left: -3px;
  border-right: none;
  border-top: none;
  border-radius: 0 0 0 8px;
}

.frame-corner.bottom-right {
  bottom: -3px;
  right: -3px;
  border-left: none;
  border-top: none;
  border-radius: 0 0 8px 0;
}

.scan-line {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 180px;
  height: 2px;
  background: var(--primary);
  animation: scan 2s ease-in-out infinite;
  box-shadow: 0 0 10px var(--primary);
}

@keyframes scan {
  0%, 100% {
    top: 30%;
  }
  50% {
    top: 70%;
  }
}

/* Preview Info */
.preview-info {
  display: flex;
  justify-content: space-between;
  padding: 15px;
  background: rgba(0,0,0,0.8);
  color: white;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-bottom: 4px;
}

.info-value {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Status indicator */
.status-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  background: #d1d5db; /* gray */
}

.status-indicator.ready { background: #22c55e; } /* green */
.status-indicator.processing { background: #eab308; } /* yellow */
.status-indicator.error { background: #ef4444; } /* red */
.status-indicator.active { 
  background: #3b82f6; /* blue */
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Success animation */
@keyframes success {
  0% { background: #22c55e; }
  50% { background: #16a34a; }
  100% { background: #22c55e; }
}

.status-indicator.success {
  animation: success 1s ease-in-out;
}

/* Responsive */
@media (max-width: 980px) {
  .scanner-container { 
    grid-template-columns: 1fr; 
  }
  
  .scanning-tabs {
    flex-direction: column;
  }
  
  .tab-btn {
    border-radius: 8px;
    margin-bottom: 4px;
  }
  
  .scan-frame {
    width: 180px;
    height: 180px;
  }
  
  .scanner-guide {
    width: 180px;
    height: 180px;
  }
}

@media (max-width: 640px) {
  .preview-info {
    flex-direction: column;
    gap: 10px;
  }
  
  .result-actions {
    flex-direction: column;
  }
  
  .scan-frame {
    width: 160px;
    height: 160px;
  }
  
  .scanner-guide {
    width: 160px;
    height: 160px;
  }
}

/* Tool info */
.tool-info h2 { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 2px solid rgba(227,6,19,.2); }
.tool-info h3 { margin: 18px 0 10px; color: var(--primary); }
.tool-info ul, .tool-info ol { margin-left: 18px; margin-bottom: 12px; }
.tool-info li { margin-bottom: 6px; }