/* 
 * Custom styles for alOCR-api
 * Application-specific components and utilities
 */

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

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

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-fade-in {
  animation: fadeIn 0.2s ease;
}

.animate-shimmer {
  animation: shimmer 1.5s infinite;
  background-size: 200% 100%;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Card Component */
.card {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  padding: 1.5rem;
}

.card-secondary {
  background-color: #f9fafb;
}

.card-compact {
  padding: 1rem;
}

/* Button Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.25rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 150ms;
  text-decoration: none;
}

.btn-primary {
  background-color: #000000;
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #1f2937;
}

.btn-primary:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: #ffffff;
  color: #000000;
  border-color: #e5e7eb;
}

.btn-secondary:hover {
  background-color: #f9fafb;
  border-color: #9ca3af;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 0.25rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms;
}

.btn-icon:hover {
  color: #055A45;
  background-color: #f3f4f6;
}

.btn-success {
  background-color: #0C7A43 !important;
  border-color: #0C7A43 !important;
  color: #ffffff !important;
}

/* Input Components */
.input {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  background-color: #ffffff;
  color: #000000;
  transition: border-color 150ms;
}

.input:focus {
  outline: none;
  border-color: #055A45;
}

.input::placeholder {
  color: #9ca3af;
}

/* Language Toggle */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.25rem;
  cursor: pointer;
  color: #6b7280;
  transition: all 150ms;
}

.lang-toggle:hover {
  background-color: #f9fafb;
  color: #000000;
  border-color: #9ca3af;
}

/* Dropzone */
.dropzone {
  border: 2px dashed #e5e7eb;
  border-radius: 0.375rem;
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: all 150ms;
  background-color: #ffffff;
}

.dropzone:hover {
  border-color: #055A45;
  background-color: #f9fafb;
}

.dropzone.active {
  border-style: solid;
  border-color: #055A45;
  background-color: #f9fafb;
}

/* File Info */
.file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: #f9fafb;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  color: #000000;
}

[dir="rtl"] .file-info {
  flex-direction: row-reverse;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  text-transform: capitalize;
}

.badge-gray {
  background-color: #f3f4f6;
  color: #6b7280;
}

.badge-indigo {
  background-color: #e0e7ff;
  color: #3730a3;
}

.badge-amber {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-green {
  background-color: #dcfce7;
  color: #166534;
}

.badge-red {
  background-color: #fef2f2;
  color: #b91c1c;
}

/* Progress Bar */
.progress-bar {
  height: 0.5rem;
  background-color: #f3f4f6;
  border-radius: 0.25rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: #055A45;
  border-radius: 0.25rem;
  transition: width 300ms ease;
}

/* Alert */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
}

[dir="rtl"] .alert {
  flex-direction: row-reverse;
}

.alert-error {
  background-color: #fef2f2;
  color: #b91c1c;
}

/* OCR Content */
.ocr-content {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.875rem;
  line-height: 1.625;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #000000;
  margin: 0;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 2rem;
}

[dir="rtl"] .ocr-content {
  text-align: right;
  direction: rtl;
  padding-right: 0;
  padding-left: 2rem;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.25rem;
}

/* Details/Summary styling */
details summary::-webkit-details-marker {
  display: none;
}

details summary {
  list-style: none;
}

details[open] .chevron {
  transform: rotate(180deg);
}

/* HTMX Loading Indicators */
.htmx-request .htmx-indicator {
  opacity: 1;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms, visibility 200ms;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-content img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-close {
  position: absolute;
  top: -3rem;
  right: 0;
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 150ms;
}

[dir="rtl"] .modal-close {
  right: auto;
  left: 0;
}

.modal-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.modal-caption {
  color: #ffffff;
  margin-top: 1rem;
  font-size: 0.875rem;
  text-align: center;
}
