/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  color: #333;
  margin: 0;
  padding: 20px;
  background-color: #f8fafc;
}

/* Typography */
h1, h2, h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  line-height: 1.3;
}

/* Links */
a {
  color: #3b82f6;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Buttons */
.button {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.button--primary {
  background-color: #3b82f6;
  color: white;
}

.button--primary:hover {
  background-color: #2563eb;
  text-decoration: none;
}

.button--secondary {
  background-color: #6b7280;
  color: white;
}

.button--secondary:hover {
  background-color: #4b5563;
  text-decoration: none;
}

.button--danger {
  background-color: #dc2626;
  color: white;
}

.button--danger:hover {
  background-color: #b91c1c;
  text-decoration: none;
}

/* Form Styles */
.crawl-form {
  max-width: 600px;
  margin: 0 auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.crawl-form__title {
  color: #1f2937;
  margin-bottom: 1.5rem;
}

.crawl-form__field {
  margin-bottom: 1.5rem;
}

.crawl-form__label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #374151;
}

.crawl-form__input, .crawl-form__select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 16px;
}

.crawl-form__input:focus, .crawl-form__select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.crawl-form__hint {
  display: block;
  margin-top: 0.25rem;
  color: #6b7280;
  font-size: 14px;
}

.crawl-form__submit {
  background-color: #3b82f6;
  color: white;
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  font-size: 16px;
}

.crawl-form__submit:hover {
  background-color: #2563eb;
}

.crawl-form__description {
  color: #6b7280;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.crawl-form__errors {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.crawl-form__errors h4 {
  color: #dc2626;
  margin: 0 0 0.5rem;
}

.crawl-form__errors ul {
  margin: 0;
  padding-left: 1.5rem;
}

.crawl-form__errors li {
  color: #dc2626;
  margin-bottom: 0.25rem;
}

.crawl-form__divider {
  text-align: center;
  margin: 1.5rem 0;
  position: relative;
}

.crawl-form__divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: #d1d5db;
}

.crawl-form__divider span {
  background: white;
  padding: 0 1rem;
  color: #6b7280;
  font-weight: 500;
}

/* Crawl Show Styles */
.crawl-show {
  max-width: 1200px;
  margin: 0 auto;
}

.crawl-show__title {
  color: #1f2937;
  margin-bottom: 1.5rem;
}

.crawl-show__meta {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.crawl-show__meta p {
  margin-bottom: 0.5rem;
}

.crawl-show__meta p:last-child {
  margin-bottom: 0;
}

.crawl-show__meta a {
  word-break: break-all;
  overflow-wrap: break-word;
  display: inline-block;
  max-width: 100%;
}

.crawl-show__subtitle {
  color: #1f2937;
  margin: 2rem 0 1rem;
}

.crawl-show__actions {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.crawl-show__actions form {
  display: inline-flex;
  margin: 0;
}

.crawl-show__actions form .button {
  margin: 0;
  white-space: nowrap;
}

/* Status Styles */
.crawl-status {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.crawl-status__row {
  margin-bottom: 0.5rem;
  display: flex;
  gap: 2rem;
}

.crawl-status__row:last-child {
  margin-bottom: 0;
}

.crawl-status__error {
  color: #dc2626;
  background-color: #fef2f2;
  padding: 1rem;
  border-radius: 6px;
  margin-top: 1rem;
  border-left: 4px solid #dc2626;
}

/* Gallery Styles */
.crawl-show__gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.crawl-show__gallery-items {
  display: contents;
}

.crawl-show__gallery-controls {
  grid-column: 1 / -1;
  margin: 0.5rem 0;
  padding: 0;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-start;
  align-items: center;
}

.crawl-show__image-wrapper {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
}

.crawl-show__image-wrapper:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.crawl-show__image {
  width: 100%;
  height: auto;
  display: block;
  max-height: 400px;
  object-fit: contain;
}

.crawl-show__no-screenshots {
  grid-column: 1 / -1;
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 2rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Index Styles */
.crawl-index {
  max-width: 1200px;
  margin: 0 auto;
}

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

.crawl-index__filters {
  margin-bottom: 1.5rem;
}

.crawl-index__filter-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.crawl-index__filter-label {
  font-weight: 600;
  color: #4b5563;
}

.crawl-index__filter-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background-color: white;
  color: #1f2937;
  font-size: 1rem;
}

.crawl-index__pagination {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.pagination__link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.pagination__link--disabled {
  color: #9ca3af;
  pointer-events: none;
  cursor: default;
}

.pagination__info {
  color: #4b5563;
  font-size: 0.95rem;
}

.crawl-index__title {
  color: #1f2937;
  margin: 0;
}

.crawl-card {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
  transition: box-shadow 0.2s;
}

.crawl-card:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.crawl-card__title {
  margin: 0 0 0.5rem;
  color: #1f2937;
}

.crawl-card__user {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: normal;
  font-style: italic;
}

.crawl-card__meta {
  color: #6b7280;
  font-size: 14px;
  margin-bottom: 1rem;
}

.crawl-card__status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.crawl-card__status--queued {
  background-color: #fef3c7;
  color: #92400e;
}

.crawl-card__status--running {
  background-color: #dbeafe;
  color: #1e40af;
}

.crawl-card__status--succeeded {
  background-color: #dcfce7;
  color: #166534;
}

.crawl-card__status--failed {
  background-color: #fecaca;
  color: #991b1b;
}

/* Crawl Status Styles */
.crawl-status {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.crawl-status__row {
  display: flex;
  gap: 2rem;
  margin-bottom: 0.75rem;
}

.crawl-status__error {
  margin-top: 1rem;
  padding: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #991b1b;
}

.crawl-status__error strong {
  color: #7f1d1d;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  .crawl-form {
    padding: 1rem;
  }
  
  .crawl-show__gallery {
    grid-template-columns: 1fr;
  }
  
  .crawl-show__actions {
    flex-direction: column;
  }
  
  .crawl-index__header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
}

/* Video Player Styles */
.crawl-show__recording {
  margin: 2rem 0;
}

.video-player {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
}

.video-player__element {
  width: 100%;
  height: auto;
  display: block;
  background: #000;
  max-height: 70vh;
}

.video-player__info {
  padding: 1rem;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.video-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.video-info__item {
  font-size: 14px;
  color: #6b7280;
}

.video-info__item strong {
  color: #374151;
}

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

.no-recording {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  text-align: center;
  color: #6b7280;
}

.no-recording p {
  margin: 0 0 0.5rem;
  font-size: 16px;
}

.no-recording small {
  font-size: 14px;
}

/* Video responsive design */
@media (max-width: 768px) {
  .video-info {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .video-actions {
    flex-direction: column;
  }
  
  .video-player__element {
    max-height: 50vh;
  }
}

/* Action Logs Styles */
.action-logs {
  margin: 2rem 0;
}

.action-logs__details {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1rem;
}

.action-logs__summary {
  cursor: pointer;
  font-weight: 600;
  color: #1f2937;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.action-logs__stats {
  font-weight: normal;
  color: #6b7280;
  font-size: 14px;
}

.action-logs__content {
  margin-top: 1rem;
}

.action-logs__filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.button--small {
  padding: 6px 12px;
  font-size: 12px;
}

/* Gallery control buttons styling */
.crawl-show__gallery-controls .button {
  border: 1px solid #d1d5db;
  background-color: #ffffff;
  color: #111827;
}

.crawl-show__gallery-controls .button:hover {
  background-color: #f3f4f6;
  text-decoration: none;
}

.action-logs__list {
  max-height: 600px;
  overflow-y: auto;
}

.action-log {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #f9fafb;
}

.action-log--error {
  border-color: #fca5a5;
  background: #fef2f2;
}

.action-log--duplicate {
  border-color: #fde68a;
  background: #fffbeb;
}

.action-log__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.action-log__number {
  font-weight: 600;
  color: #374151;
  min-width: 40px;
}

.action-log__tool {
  flex: 1;
  color: #1f2937;
}

.action-log__time {
  font-size: 12px;
  color: #6b7280;
  font-family: monospace;
}

.action-log__badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.action-log__badge--duplicate {
  background: #fbbf24;
  color: #78350f;
}

.action-log__badge--error {
  background: #ef4444;
  color: white;
}

.action-log__error {
  background: white;
  padding: 0.75rem;
  border-radius: 4px;
  margin-top: 0.5rem;
  color: #991b1b;
  font-size: 14px;
}

.action-log__analysis,
.action-log__details {
  margin-top: 0.75rem;
}

.action-log__analysis summary,
.action-log__details summary {
  cursor: pointer;
  color: #3b82f6;
  font-size: 14px;
  font-weight: 500;
}

.action-log__analysis-content,
.action-log__technical {
  background: white;
  padding: 0.75rem;
  border-radius: 4px;
  margin-top: 0.5rem;
  font-size: 13px;
}

.action-log__technical pre {
  margin: 0.5rem 0;
  padding: 0.5rem;
  background: #f3f4f6;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 12px;
}

/* Enhanced Screenshot Styles */
.crawl-show__image-wrapper {
  position: relative;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.crawl-show__image-info {
  padding: 0.75rem;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.crawl-show__image-number {
  display: inline-block;
  background: #374151;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.crawl-show__image-description {
  margin: 0.5rem 0;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}

.crawl-show__image-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-right: 0.5rem;
  margin-top: 0.25rem;
}

.crawl-show__image-badge--duplicate {
  background: #fde68a;
  color: #78350f;
}

.crawl-show__image-badge--info {
  background: #e0f2fe;
  color: #075985;
}

.crawl-show__image-badge--registration {
  background: #86efac;
  color: #14532d;
}

.crawl-show__image-label {
  display: block;
  margin-top: 0.5rem;
  font-size: 12px;
  color: #6b7280;
  font-family: monospace;
}

/* Screen Analysis Toggle Styles */
.crawl-show__analysis-toggle {
  margin-top: 0.75rem;
  padding: 6px 12px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: #374151;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}

.crawl-show__analysis-toggle:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.crawl-show__screen-analysis {
  margin-top: 0.75rem;
  padding: 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
}

.analysis-field {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.analysis-field:last-child {
  margin-bottom: 0;
}

.analysis-field strong {
  color: #4b5563;
  display: inline-block;
  min-width: 100px;
}

.analysis-elements {
  margin: 0.5rem 0 0 1rem;
  padding-left: 1rem;
  list-style-type: disc;
}

.analysis-elements li {
  margin: 0.25rem 0;
  color: #1f2937;
}

.analysis-all-elements {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

.analysis-all-elements summary {
  cursor: pointer;
  color: #3b82f6;
  font-weight: 500;
  padding: 0.25rem;
}

.analysis-all-elements summary:hover {
  color: #2563eb;
}

.analysis-elements-compact {
  margin: 0.5rem 0 0 0;
  padding-left: 1.5rem;
  list-style-type: circle;
  max-height: 200px;
  overflow-y: auto;
}

.analysis-elements-compact li {
  margin: 0.2rem 0;
  font-size: 12px;
  color: #6b7280;
}

.analysis-raw {
  background: white;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 11px;
  color: #374151;
  margin: 0;
}

/* Screenshot Modal */
.screenshot-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.screenshot-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.screenshot-modal__dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 95vw;
  max-height: 90vh;
  background: #111827;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.screenshot-modal__image {
  display: block;
  max-width: 95vw;
  max-height: 85vh;
  width: auto;
  height: auto;
}

.screenshot-modal__close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  color: #111827;
}

.screenshot-modal__close:hover {
  background: white;
}

/* Example crawls styles */
.crawl-form__examples {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.crawl-form__examples-title {
  color: #0369a1;
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.crawl-form__examples-list {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.crawl-form__example-link {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: white;
  border: 1px solid #0ea5e9;
  border-radius: 4px;
  color: #0369a1;
  font-size: 0.875rem;
  text-decoration: none;
  transition: all 0.2s;
}

.crawl-form__example-link:hover {
  background: #0ea5e9;
  color: white;
  text-decoration: none;
}

/* Example badge in show page */
.crawl-show__example-badge {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

/* Admin controls */
.crawl-show__admin-controls {
  background: linear-gradient(135deg, #fef3f3 0%, #fff5f5 100%);
  border: 1px solid #fca5a5;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  position: relative;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.08);
}

.crawl-show__admin-controls::before {
  content: '🔒';
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 1.25rem;
  opacity: 0.5;
}

.crawl-show__admin-controls h2.crawl-show__subtitle {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #dc2626;
  font-size: 1.125rem;
  font-weight: 600;
}

.crawl-show__admin-controls .admin-form__field {
  margin-bottom: 1rem;
}

.admin-form__field {
  margin-bottom: 1.25rem;
}

.admin-form__field:last-of-type {
  margin-bottom: 1rem;
}

.admin-form__field--checkbox {
  display: flex;
  align-items: center;
}

.admin-form__checkbox {
  margin-right: 0.5rem;
  vertical-align: middle;
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-form__label {
  display: inline-block;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
}

.admin-form__field > .admin-form__label {
  display: block;
  margin-bottom: 0.375rem;
  cursor: default;
}

.admin-form__field--checkbox .admin-form__label {
  display: inline-block;
  margin-bottom: 0;
  cursor: pointer;
}

.admin-form__input {
  width: 100%;
  max-width: 400px;
  padding: 0.625rem 0.875rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  transition: all 0.2s;
}

.admin-form__input:hover {
  border-color: #d1d5db;
}

.admin-form__input:focus {
  outline: none;
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
  background: white;
}

.admin-form__input::placeholder {
  color: #9ca3af;
}

.admin-form__notice {
  color: #6b7280;
  font-style: italic;
  margin: 0;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 6px;
  border-left: 3px solid #d1d5db;
}

.admin-form .button--primary {
  background: #dc2626;
  border-color: #dc2626;
}

.admin-form .button--primary:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* Device info */
.crawl-show__device-info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
}

.device-details {
  margin-top: 0.5rem;
}

.device-details summary {
  cursor: pointer;
  color: #0284c7;
  font-weight: 500;
  user-select: none;
}

.device-details summary:hover {
  color: #0369a1;
}

.device-details ul {
  margin-top: 0.75rem;
  padding-left: 1.5rem;
}

.device-details li {
  margin-bottom: 0.25rem;
  color: #475569;
}
