/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  line-height: 1.6;
  color: #1a1a1a;
  background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Styles */
.header {
  padding: 2rem 0;
  text-align: center;
}

.header-content {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.logo i {
  font-size: 2.5rem;
  color: #fff;
}

.logo h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.subtitle {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 300;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem 0;
}

/* Section Base Styles */
section {
  margin-bottom: 3rem;
}

/* Upload Section */
.upload-section {
  animation: fadeInUp 0.6s ease-out;
}

.upload-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.upload-area {
  border: 3px dashed #666;
  border-radius: 15px;
  padding: 3rem 2rem;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  background: linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.05),
    rgba(50, 50, 50, 0.05)
  );
}

.upload-area:hover {
  border-color: #333;
  background: linear-gradient(45deg, rgba(0, 0, 0, 0.1), rgba(50, 50, 50, 0.1));
  transform: translateY(-2px);
}

.upload-area.drag-over {
  border-color: #333;
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.02);
}

/* Enhance drag-over affordance with subtle shadow */
.upload-area.drag-over {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.upload-icon i {
  font-size: 4rem;
  color: #333;
  margin-bottom: 1rem;
  display: block;
}

.upload-area h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #333;
}

.upload-area p {
  color: #666;
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

/* Subtle helper text under upload areas */
.upload-help {
  color: #7a7a7a;
  font-size: 0.9rem;
  margin-top: -0.75rem; /* pull closer to paragraph */
  margin-bottom: 1rem;
}

#fileInput {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

/* Hide the native product file input to keep only the custom Browse button */
#productFileInput {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.browse-btn {
  background: linear-gradient(135deg, #333, #1a1a1a);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.browse-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

/* File Preview */
.file-preview {
  margin-top: 2rem;
  animation: fadeInUp 0.4s ease-out;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.preview-header h4 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
}

.clear-btn {
  background: #ff4757;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.clear-btn:hover {
  background: #ff3742;
  transform: translateY(-1px);
}

.preview-content {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}

#previewImage,
#productPreviewImage {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.file-info {
  flex: 1;
  min-width: 0; /* allow flex child to shrink and avoid overflow */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.file-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  /* Wrap long filenames and keep within container */
  overflow-wrap: anywhere; /* break long tokens if needed */
  word-break: break-word;
  hyphens: auto;
}

.file-size {
  color: #666;
  font-size: 0.9rem;
}

.generate-btn {
  background: linear-gradient(135deg, #333, #1a1a1a);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 1.5rem;
}

/* Product Analyzer Fields */
.text-field,
.text-area {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-size: 0.95rem;
}
.text-field:focus,
.text-area:focus {
  outline: none;
  border-color: #9ca3af;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Improve focus visibility for keyboard users */
.browse-btn:focus-visible,
.generate-btn:focus-visible,
.clear-btn:focus-visible,
.new-generation-btn:focus-visible {
  outline: 3px solid rgba(17, 24, 39, 0.35);
  outline-offset: 2px;
}

/* Progress Section */
.progress-section {
  animation: fadeInUp 0.6s ease-out;
}

.progress-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
}

.progress-container h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
  color: #333;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 2rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #333, #1a1a1a);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-steps {
  display: flex;
  justify-content: space-around;
  margin-bottom: 2rem;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.step.active {
  opacity: 1;
}

.step.completed {
  opacity: 1;
  color: #4caf50;
}

.step i {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.step span {
  font-size: 0.9rem;
  font-weight: 500;
}

.progress-log {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 1rem;
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  color: #333;
  border: 1px solid #e9ecef;
}

/* Results Section */
.results-section {
  animation: fadeInUp 0.6s ease-out;
}

.results-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.results-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
}

.new-generation-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.new-generation-btn:hover {
  background: #218838;
  transform: translateY(-1px);
}

.analysis-results {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 15px;
  border: 1px solid #e9ecef;
}

.analysis-results h4 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #333;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.analysis-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.analysis-item label {
  font-weight: 500;
  color: #666;
  font-size: 0.9rem;
}

.analysis-item span {
  font-weight: 600;
  color: #333;
  font-size: 1rem;
}

/* License plate specific styles */
.license-plate-section .license-plate-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.license-origin {
  font-size: 0.85rem !important;
  color: #666 !important;
  font-weight: 500 !important;
}

.license-confidence {
  font-size: 0.8rem !important;
  color: #888 !important;
  font-weight: 400 !important;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.image-result {
  background: #f8f9fa;
  border-radius: 15px;
  padding: 1.5rem;
  border: 1px solid #e9ecef;
  transition: transform 0.3s ease;
}

.image-result:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.image-result h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #333;
  text-transform: capitalize;
}

.result-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.3s ease;
}

.result-image:hover {
  transform: scale(1.02);
}

.image-actions {
  display: flex;
  gap: 0.5rem;
}

.view-btn {
  background: linear-gradient(135deg, #333, #1a1a1a);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 15px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
}

.view-btn:hover {
  background: linear-gradient(135deg, #1a1a1a, #000);
  transform: translateY(-1px);
}

.download-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 15px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: center;
}

.download-btn:hover {
  background: #0056b3;
  transform: translateY(-1px);
}

/* Error Section */
.error-section {
  animation: fadeInUp 0.6s ease-out;
}

.error-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 3rem 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
}

.error-icon i {
  font-size: 4rem;
  color: #ff4757;
  margin-bottom: 1rem;
}

.error-container h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #333;
}

.error-message {
  color: #666;
  margin-bottom: 2rem;
  font-size: 1rem;
  line-height: 1.6;
}

.retry-btn {
  background: #ff4757;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.retry-btn:hover {
  background: #ff3742;
  transform: translateY(-2px);
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-spinner i {
  font-size: 3rem;
  color: #fff;
  animation: spin 1s linear infinite;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }

  .logo h1 {
    font-size: 2rem;
  }

  .upload-area {
    padding: 2rem 1rem;
  }

  .upload-icon i {
    font-size: 3rem;
  }

  .preview-content {
    flex-direction: column;
    text-align: center;
  }

  .results-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .images-grid {
    grid-template-columns: 1fr;
  }

  .progress-steps {
    flex-direction: column;
    gap: 1rem;
  }

  .modal-content {
    max-width: 98vw;
    max-height: 98vh;
  }

  .modal-header,
  .modal-footer {
    padding: 1rem;
  }

  .modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .modal-zoom-controls {
    justify-content: center;
  }

  .image-actions {
    flex-direction: column;
    gap: 0.5rem;
  }
}

@media (max-width: 480px) {
  .header-content {
    padding: 1.5rem;
  }

  .logo {
    flex-direction: column;
    gap: 0.5rem;
  }

  .logo h1 {
    font-size: 1.8rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .upload-container,
  .options-container,
  .progress-container,
  .results-container,
  .error-container {
    padding: 1.5rem;
  }
}

/* Image Viewer Modal */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 15px;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalFadeIn 0.3s ease-out;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #e9ecef;
  background: #f8f9fa;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #666;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
}

.modal-close:hover {
  background: #e9ecef;
  color: #333;
}

.modal-body {
  flex: 1;
  padding: 1rem;
  overflow: auto;
  background: #f8f9fa;
  min-height: 0;
}

.modal-body img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid #e9ecef;
  background: #f8f9fa;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.modal-zoom-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.zoom-btn {
  background: #333;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
}

.zoom-btn:hover {
  background: #1a1a1a;
  transform: translateY(-1px);
}

.zoom-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.zoom-level {
  font-size: 0.9rem;
  color: #666;
  min-width: 50px;
  text-align: center;
}

.modal-download-btn {
  background: linear-gradient(135deg, #333, #1a1a1a);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Custom Scrollbar */
.progress-log::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.progress-log::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.progress-log::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

.progress-log::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
  background: #1a1a1a;
}
