/* Global Styles */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
  --success-color: #10b981;
  --success-dark: #059669;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #3b82f6;
  --bg-color: #f9fafb;
  --bg-secondary: #f3f4f6;
  --border-color: #e5e7eb;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
}

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

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 40px 20px;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 40px;
}

.logo h1 {
  font-size: 2.5rem;
  margin-bottom: 5px;
}

.logo p {
  font-size: 1rem;
  opacity: 0.9;
}

.header-stats {
  display: flex;
  gap: 30px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px 25px;
  border-radius: var(--border-radius);
  backdrop-filter: blur(10px);
}

.stat-label {
  font-size: 0.85rem;
  opacity: 0.9;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: bold;
  margin-top: 5px;
}

/* Main Content */
.main {
  flex: 1;
  padding: 40px 20px;
}

.section {
  background: white;
  border-radius: var(--border-radius);
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  animation: slideIn 0.3s ease-out;
}

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

.section-header {
  margin-bottom: 30px;
  border-bottom: 2px solid var(--bg-secondary);
  padding-bottom: 20px;
}

.section-header h2 {
  font-size: 1.75rem;
  margin-bottom: 5px;
  color: var(--primary-color);
}

.section-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Form Styles */
.scraper-form {
  background: var(--bg-secondary);
  padding: 25px;
  border-radius: var(--border-radius);
  margin-bottom: 25px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
  display: block;
  color: var(--text-light);
  margin-top: 5px;
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-success {
  background-color: var(--success-color);
  color: white;
}

.btn-success:hover {
  background-color: var(--success-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-info {
  background-color: var(--info-color);
  color: white;
}

.btn-info:hover {
  background-color: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

.form-actions {
  display: flex;
  gap: 15px;
  margin-top: 20px;
}

/* Progress Section */
.progress-section {
  background: var(--bg-secondary);
  padding: 25px;
  border-radius: var(--border-radius);
  margin-bottom: 25px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.progress-header h3 {
  color: var(--primary-color);
}

.progress-percent {
  font-weight: bold;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 15px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--success-color) 100%);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

.progress-info p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0;
}

/* Results Section */
.results-section {
  border: 2px solid var(--success-color);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--bg-secondary);
}

.results-header h3 {
  color: var(--success-color);
  font-size: 1.5rem;
}

.results-stats {
  display: flex;
  gap: 20px;
  font-size: 0.95rem;
}

.results-stats span {
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Error Messages */
.error-messages {
  background-color: rgba(239, 68, 68, 0.1);
  border: 2px solid var(--error-color);
  border-radius: var(--border-radius);
  padding: 15px;
  margin-bottom: 20px;
}

.error-messages h4 {
  color: var(--error-color);
  margin-bottom: 10px;
}

.error-messages ul {
  list-style: none;
  padding-left: 0;
}

.error-messages li {
  color: var(--error-color);
  font-size: 0.9rem;
  padding: 5px 0;
  padding-left: 20px;
  position: relative;
}

.error-messages li:before {
  content: "⚠ ";
  position: absolute;
  left: 0;
}

/* Products Table */
.products-container {
  margin-bottom: 20px;
  overflow-x: auto;
}

.table-wrapper {
  overflow-x: auto;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.products-table thead {
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
}

.products-table th {
  padding: 15px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.products-table td {
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.products-table tbody tr:hover {
  background-color: var(--bg-secondary);
}

.products-table tbody tr:last-child td {
  border-bottom: none;
}

.price {
  font-weight: 600;
  color: var(--success-color);
}

.confidence {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.confidence.high {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.confidence.medium {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
}

.confidence.low {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--error-color);
}

.results-actions {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 2px solid var(--bg-secondary);
}

/* Products Section */
.filters {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.filter-input,
.filter-select {
  padding: 10px 15px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.95rem;
  flex: 1;
  min-width: 200px;
  transition: var(--transition);
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.product-image {
  width: 100%;
  height: 200px;
  background-color: var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 3rem;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.4;
  min-height: 2.8em;
}

.product-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 10px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 15px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.product-price {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--success-color);
  margin-bottom: 15px;
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 1.3rem;
  margin-bottom: 10px;
  color: var(--text-primary);
}

/* Footer */
.footer {
  background-color: var(--text-primary);
  color: white;
  padding: 30px 20px;
  text-align: center;
  border-top: 2px solid var(--border-color);
  margin-top: auto;
}

.footer-links {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 0.9rem;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }

  .header-stats {
    flex-direction: column;
    width: 100%;
  }

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

  .section {
    padding: 20px;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .results-stats {
    width: 100%;
    flex-wrap: wrap;
  }

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

  .products-table {
    font-size: 0.85rem;
  }

  .products-table th,
  .products-table td {
    padding: 10px;
  }

  .filters {
    flex-direction: column;
  }

  .filter-input,
  .filter-select {
    min-width: unset;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

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

.loading::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 10px;
}

/* Alert Styles */
.alert {
  padding: 15px;
  border-radius: var(--border-radius);
  margin-bottom: 15px;
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--success-color);
  color: var(--success-color);
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error-color);
  color: var(--error-color);
}

.alert-info {
  background-color: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--info-color);
  color: var(--info-color);
}
