/* ═══════════════════════════════════════════════
   ItSave — Image Converter Styles
   ═══════════════════════════════════════════════ */

/* ── Converter Container ── */
.converter-container {
  max-width: 760px;
  margin: 0 auto 40px;
  padding: 0 16px;
}

/* ── Format Selectors ── */
.format-selectors {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 28px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.format-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.format-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.format-group label i {
  font-size: 0.9rem;
  color: var(--primary, #6366f1);
}

.format-group select {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--border, #d1d5db);
  background: var(--bg, #f9fafb);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #111827);
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.format-group select:focus {
  outline: none;
  border-color: var(--primary, #6366f1);
  box-shadow: 0 0 0 3px var(--primary-glow, rgba(99, 102, 241, 0.15));
}

.format-group select option:disabled {
  color: #ccc;
}

.swap-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--border, #d1d5db);
  background: var(--bg, #f9fafb);
  color: var(--primary, #6366f1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.swap-btn:hover {
  background: var(--primary, #6366f1);
  color: #fff;
  border-color: var(--primary, #6366f1);
  transform: rotate(180deg);
}

/* ── Upload Zone ── */
.upload-zone {
  border: 2.5px dashed var(--primary, #6366f1);
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: var(--card-bg, #fff);
  margin-bottom: 24px;
  background: var(--primary-glow, rgba(99, 102, 241, 0.05));
}

.upload-content {
  pointer-events: none;
}

.upload-icon {
  font-size: 2.5rem;
  color: var(--primary, #6366f1);
  margin-bottom: 12px;
}

.upload-zone h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text, #111827);
}

.upload-zone p {
  color: var(--text-muted, #6b7280);
  font-size: 0.95rem;
}

.upload-browse {
  color: var(--primary, #6366f1);
  font-weight: 600;
  text-decoration: underline;
}

.upload-hint {
  display: block;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted, #9ca3af);
}

/* ── Files Section ── */
.files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.files-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #111827);
  display: flex;
  align-items: center;
  gap: 8px;
}

.files-header h3 i {
  color: var(--primary, #6366f1);
}

.btn-clear {
  background: none;
  border: 1px solid var(--border, #d1d5db);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-clear:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  max-height: 280px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
}

.file-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-item-info i {
  color: var(--primary, #6366f1);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.file-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-muted, #9ca3af);
  white-space: nowrap;
}

.file-remove {
  background: none;
  border: none;
  color: var(--text-muted, #9ca3af);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.file-remove:hover {
  color: #dc2626;
}

/* ── Convert Actions ── */
.convert-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.quality-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.quality-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quality-group label i {
  color: var(--primary, #6366f1);
}

.quality-group input[type="range"] {
  flex: 1;
  accent-color: var(--primary, #6366f1);
  height: 6px;
}

.btn-convert {
  padding: 12px 32px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--primary, #6366f1), #8b5cf6);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn-convert:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-convert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Results Section ── */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  margin-top: 28px;
}

.results-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #16a34a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-download-all {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-download-all:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

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

.result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--card-bg, #fff);
  border: 1px solid #bbf7d0;
}

.result-item.result-error {
  border-color: #fecaca;
}

.result-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.result-info .fa-check-circle {
  color: #16a34a;
  font-size: 1.1rem;
}

.result-info .fa-exclamation-circle {
  color: #dc2626;
  font-size: 1.1rem;
}

.result-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.result-size {
  font-size: 0.8rem;
  color: var(--text-muted, #6b7280);
}

.result-status.error {
  font-size: 0.8rem;
  color: #dc2626;
}

.btn-download-single {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-download-single:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

/* ── Popular Conversions ── */
.popular-conversions {
  max-width: 760px;
  margin: 48px auto 0;
  padding: 0 16px;
}

.popular-conversions h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.popular-conversions h2 i {
  color: #f59e0b;
}

.conversion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.conversion-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  text-decoration: none;
  color: var(--text, #111827);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.conversion-link:hover {
  border-color: var(--primary, #6366f1);
  background: var(--primary-glow, rgba(99, 102, 241, 0.05));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.conversion-link i {
  color: var(--primary, #6366f1);
  font-size: 0.75rem;
}

.conv-from {
  padding: 2px 8px;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 700;
}

.conv-to {
  padding: 2px 8px;
  background: #dcfce7;
  color: #16a34a;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 700;
}

/* ── File Thumbnails ── */
.file-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--bg, #f9fafb);
  flex-shrink: 0;
}

.file-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* ── Result Item Actions ── */
.result-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-preview-single {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--primary, #6366f1);
  background: transparent;
  color: var(--primary, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.btn-preview-single:hover {
  background: var(--primary, #6366f1);
  color: #fff;
  transform: scale(1.08);
}

/* ── Preview All Button ── */
.btn-preview-all {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1.5px solid var(--primary, #6366f1);
  background: transparent;
  color: var(--primary, #6366f1);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-preview-all:hover {
  background: var(--primary, #6366f1);
  color: #fff;
  transform: translateY(-1px);
}

.results-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ═══════════════════════════════════════════════
   PREVIEW MODAL / LIGHTBOX
   ═══════════════════════════════════════════════ */
.preview-overlay,
.gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s,
    visibility 0.3s;
}

.preview-overlay.active,
.gallery-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Preview Modal Container ── */
.preview-modal {
  background: var(--card-bg, #fff);
  border-radius: 20px;
  width: 92vw;
  max-width: 960px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  animation: previewSlideIn 0.3s ease;
  overflow: hidden;
}

@keyframes previewSlideIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Preview Header ── */
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  gap: 12px;
}

.preview-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.preview-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.preview-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border, #d1d5db);
  background: var(--bg, #f9fafb);
  color: var(--text, #111827);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.preview-nav-btn:hover {
  background: var(--primary, #6366f1);
  border-color: var(--primary, #6366f1);
  color: #fff;
}

.preview-counter {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  min-width: 48px;
  text-align: center;
}

.preview-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--bg, #f3f4f6);
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.preview-close:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ── Preview Body — Side by Side ── */
.preview-body {
  flex: 1;
  overflow: auto;
  padding: 20px 24px;
}

.preview-comparison {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 260px;
}

.preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.preview-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
}

.preview-original .preview-label {
  background: #e0e7ff;
  color: #4338ca;
}

.preview-converted .preview-label {
  background: #dcfce7;
  color: #16a34a;
}

.preview-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  border-radius: 12px;
  background: var(--bg, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  padding: 12px;
  overflow: hidden;
}

.preview-img-wrap img {
  max-width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 6px;
}

.preview-meta {
  font-size: 0.78rem;
  color: var(--text-muted, #6b7280);
  text-align: center;
  word-break: break-all;
  padding: 0 8px;
}

.preview-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: var(--primary, #6366f1);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ── Preview Footer ── */
.preview-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border, #e5e7eb);
  display: flex;
  justify-content: center;
}

.preview-download-btn {
  padding: 10px 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.preview-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.35);
}

/* ═══════════════════════════════════════════════
   GALLERY MODAL
   ═══════════════════════════════════════════════ */
.gallery-modal {
  background: var(--card-bg, #fff);
  border-radius: 20px;
  width: 92vw;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  animation: previewSlideIn 0.3s ease;
  overflow: hidden;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.gallery-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text, #111827);
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-header h3 i {
  color: var(--primary, #6366f1);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.gallery-card {
  border-radius: 12px;
  border: 1.5px solid var(--border, #e5e7eb);
  background: var(--card-bg, #fff);
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}

.gallery-card:hover {
  border-color: var(--primary, #6366f1);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.15);
}

.gallery-thumb-wrap {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, #f9fafb);
  overflow: hidden;
  padding: 8px;
}

.gallery-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.gallery-card-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gallery-card-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card-size {
  font-size: 0.72rem;
  color: var(--text-muted, #9ca3af);
}

/* ── FAQ Section ── */
.converter-faq {
  max-width: 760px;
  margin: 48px auto 0;
  padding: 0 16px;
}

.converter-faq h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.converter-faq h2 i {
  color: var(--primary, #6366f1);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .format-selectors {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .swap-btn {
    align-self: center;
    transform: rotate(90deg);
  }

  .swap-btn:hover {
    transform: rotate(270deg);
  }

  .convert-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-convert {
    margin-left: 0;
    justify-content: center;
  }

  .quality-group {
    min-width: 0;
  }

  .file-name {
    max-width: 160px;
  }

  .conversion-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Dark mode overrides ── */
[data-theme="dark"] .conv-from {
  background: #312e81;
  color: #a5b4fc;
}

[data-theme="dark"] .conv-to {
  background: #14532d;
  color: #86efac;
}

[data-theme="dark"] .result-item {
  border-color: #166534;
}

[data-theme="dark"] .result-item.result-error {
  border-color: #991b1b;
}

[data-theme="dark"] .btn-clear:hover {
  background: #450a0a;
  border-color: #991b1b;
  color: #fca5a5;
}
