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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  text-align: center;
  margin-bottom: 30px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 10px;
}

.header p {
  color: #7f8c8d;
  font-size: 1.1rem;
}

.upload-section {
  background: white;
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.upload-buttons {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  min-width: 140px;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
  transform: translateY(-1px);
}

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

.file-input {
  display: none;
}

.drag-drop-zone {
  border: 2px dashed #bdc3c7;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  margin-top: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fafafa;
}

.drag-drop-zone:hover {
  border-color: #3498db;
  background: #f0f8ff;
}

.drag-drop-zone.drag-over {
  border-color: #3498db;
  background: #e3f2fd;
  transform: scale(1.02);
}

.drag-drop-zone:focus {
  outline: 2px solid #3498db;
  outline-offset: 2px;
}

.drag-drop-content {
  pointer-events: none;
}

.drag-drop-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  opacity: 0.7;
}

.drag-drop-text p {
  margin: 8px 0;
  color: #2c3e50;
}

.drag-drop-text strong {
  font-size: 1.1rem;
}

.drag-drop-formats {
  font-size: 0.9rem;
  color: #7f8c8d;
  margin-top: 15px;
}

.camera-section {
  margin-top: 20px;
}

.camera-preview {
  width: 100%;
  max-width: 500px;
  border-radius: 8px;
  margin: 0 auto;
  display: block;
}

.camera-controls {
  text-align: center;
  margin-top: 15px;
}

.preview-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: none;
}

.preview-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(231, 76, 60, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.process-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

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

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

.progress-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: none;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.progress-indicator {
  text-align: center;
}

.progress-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #ecf0f1;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.progress-text {
  font-size: 1.1rem;
  color: #2c3e50;
  margin-bottom: 10px;
}

.progress-steps {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.progress-step.pending {
  background: #ecf0f1;
  color: #95a5a6;
}

.progress-step.active {
  background: #3498db;
  color: white;
  animation: activePulse 1.5s ease-in-out infinite;
}

@keyframes activePulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.progress-step.completed {
  background: #27ae60;
  color: white;
  animation: completePulse 0.5s ease-in-out;
}

@keyframes completePulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.results-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: none;
}

.results-section h2 {
  color: #2c3e50;
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.result-item {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid #ecf0f1;
}

.result-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.image-counter {
  color: #7f8c8d;
  font-weight: normal;
  font-size: 0.9rem;
}

.result-item h3 {
  color: #34495e;
  margin-bottom: 10px;
  font-size: 1.2rem;
}

.extracted-text {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #3498db;
  white-space: pre-wrap;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
}

.analysis-content {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #27ae60;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag {
  background: #3498db;
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
  position: relative;
}

.tag:hover {
  background: #2980b9;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.tag:active,
.tag.tag-clicked {
  transform: translateY(0);
  background: #1f5f8b;
}

/* Category-based tag styling */
.tag-financial {
  background: #27ae60;
}

.tag-financial:hover {
  background: #229954;
}

.tag-legal {
  background: #8e44ad;
}

.tag-legal:hover {
  background: #7d3c98;
}

.tag-personal {
  background: #e67e22;
}

.tag-personal:hover {
  background: #d35400;
}

.tag-business {
  background: #34495e;
}

.tag-business:hover {
  background: #2c3e50;
}

.tag-temporal {
  background: #e74c3c;
}

.tag-temporal:hover {
  background: #c0392b;
}

.tag-document {
  background: #95a5a6;
}

.tag-document:hover {
  background: #7f8c8d;
}

/* Tag interaction elements */
.tag-message {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 8px;
  animation: fadeInOut 2s ease-in-out;
}

.tag-message-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.tag-message-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translateY(-5px);
  }
  20%, 80% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-5px);
  }
}

.tag-interaction-info {
  font-size: 0.75rem;
  color: #7f8c8d;
  margin-top: 8px;
  font-style: italic;
}

.tag-fallback-indicator {
  font-size: 0.75rem;
  color: #95a5a6;
  margin-top: 8px;
  font-style: italic;
}

.pdf-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #e74c3c;
  color: white;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  transition: background 0.3s ease;
}

.pdf-download:hover {
  background: #c0392b;
}

.error-section {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  display: none;
  animation: slideIn 0.3s ease-out;
}

.error-message {
  color: #e53e3e;
  font-weight: 500;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.error-message::before {
  content: '⚠️';
  font-size: 1.2rem;
}

.error-suggestions {
  color: #718096;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-line;
}

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .upload-section {
    padding: 20px;
  }

  .upload-buttons {
    flex-direction: column;
  }

  .btn {
    min-width: auto;
  }

  .drag-drop-zone {
    padding: 30px 15px;
    margin-top: 15px;
  }

  .drag-drop-icon {
    font-size: 2.5rem;
  }

  .drag-drop-text strong {
    font-size: 1rem;
  }

  .progress-steps {
    flex-direction: column;
    gap: 10px;
  }

  .process-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-images {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .preview-image {
    height: 150px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 10px;
  }

  .upload-section,
  .preview-section,
  .progress-section,
  .results-section {
    padding: 15px;
  }

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

/* Touch-friendly improvements for mobile */
@media (hover: none) and (pointer: coarse) {
  .btn {
    padding: 15px 24px;
    font-size: 1.1rem;
  }

  .preview-remove {
    width: 35px;
    height: 35px;
    font-size: 18px;
  }
}

/* Hidden elements */
.hidden {
  display: none !important;
}