/* ===========================================
   CLEAN AI OVERLAY (NO DOT, NO CROP)
   =========================================== */
/* ===========================================
   CLEAN AI OVERLAY — WITH 3 DOTS
   =========================================== */

#ai-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;

  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);

  overflow: hidden;
}

.ai-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  width: 92%;
  max-width: 420px;
  padding: 0 6px;

  display: flex;
  flex-direction: column;
  align-items: center;
}

/* === Processing Title === */
.ai-title {
  font-size: 1.7em;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 18px;

  display: flex;
  align-items: center;
  gap: 6px;

  text-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}

/* === Three-dot animation === */
.ai-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 3px;
}

.ai-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
  opacity: 0.6;

  animation: dotBlink 1.4s infinite ease-in-out;
}

.ai-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBlink {
  0%, 80%, 100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* === Live typewriter line === */
.ai-thinking-line {
  width: 100%;
  min-height: 2.2em;
  margin-bottom: 14px;
  padding: 8px 12px;

  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;

  color: #ffffff;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;

  position: relative;
}
/* === Tag chips (per image result) === */
.ai-tag-row {
  padding-left: 10px;
  margin-left: 2px;
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  opacity: 0;
  animation: fadeSlide 0.25s forwards ease-out;
}

.ai-tag-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-tag-selfie {
  background: rgba(255, 82, 82, 0.55);
  border-color: rgba(255, 82, 82, 0.7);
}

/* === Steps Log (history) === */
.ai-steps {
  width: 100%;
  max-height: 160px;
  margin-bottom: 14px;
  padding-right: 4px;

  overflow-y: auto;
  scrollbar-width: none;

  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.45;

  -webkit-overflow-scrolling: touch;
}
.ai-steps::-webkit-scrollbar { display: none; }

.ai-step-entry {
  padding-left: 10px;
  margin-left: 2px;
  margin-bottom: 3px;

  border-left: 2px solid rgba(255, 255, 255, 0.18);
  opacity: 0;

  animation: fadeSlide 0.25s forwards ease-out;
}

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

/* === Progress Bar === */
#ai-progress-container {
  width: 100%;
}

#ai-progress-bar {
  width: 0%;
  height: 5px;
  border-radius: 4px;
  background: linear-gradient(90deg, #ffffff, #c8c8c8);
  transition: width 0.3s ease-out;
}

#ai-progress-info {
  text-align: center;
  margin-top: 7px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}








/* ==============ends overlay================== */







/* ===== Modal Background ===== */
.stats-modal {
  display: none; /* hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 15, 0.55);
  backdrop-filter: blur(6px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  animation: fadeInBg 0.3s ease;
}

/* ===== Modal Content ===== */
.stats-modal-content {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 30px 35px;
  width: 90%;
  max-width: 600px; /* smaller and more compact */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  animation: fadeIn 0.3s ease;
  position: relative;
  color: #222;
  font-family: 'Inter', 'Segoe UI', sans-serif;
}

/* ===== Header ===== */
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.stats-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #333;
  letter-spacing: 0.5px;
}

.stats-close {
  position: absolute;
  top: 5px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 26px;
  color: #777;
  cursor: pointer;
  transition: color 0.2s ease;
}

.stats-close:hover {
  color: #222;
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 20px;
}

/* ===== Stat Card ===== */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 25px 10px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.stat-card h1 {
  font-size: 36px;
  font-weight: 800;
  margin: 0;
  color: #2b2b2b;
}

.stat-card p {
  font-size: 15px;
  font-weight: 600;
  color: #555;
  margin: 6px 0;
}

.stat-card span {
  font-size: 13px;
  color: #888;
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInBg {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ends here */


/* AI pop-up box */

.ai-popup {
    position: absolute;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.13), 0 2px 8px rgba(0,0,0,0.07);
    padding: 8px;
    width: 270px;
    z-index: 9999;
    transform-origin: bottom center;
    animation: aiPopupFadeIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    border: 1px solid rgba(0,0,0,0.06);
}

.ai-popup.hidden {
    display: none;
}

.ai-popup-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 13px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease;
    text-decoration: none;
}

.ai-popup-item:hover {
    background: #f4f6ff;
    transform: translateX(2px);
}

.ai-popup-item:hover .ai-popup-title {
    color: #2563eb;
}

.ai-popup-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
}

.ai-icon-bg {
    background: #eef2ff;
}

.ai-icon-instant {
    background: #fef9ec;
}

.ai-popup-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.ai-popup-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
    letter-spacing: -0.01em;
    transition: color 0.15s ease;
}

.ai-subtext {
    font-size: 11.5px;
    font-weight: 400;
    color: #6b7280;
    line-height: 1.45;
    white-space: normal;
}

.ai-popup-divider {
    height: 1px;
    background: #f0f0f0;
    margin: 2px 6px;
}

/* AI model selector inside popup */
.ai-model-selector {
    padding: 10px 12px 6px;
}

.ai-model-label {
    font-size: 10.5px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 7px;
}

.ai-model-pills {
    display: flex;
    gap: 6px;
}

.ai-model-pill {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 7px 6px;
    border-radius: 9px;
    border: 1.5px solid #e5e7eb;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #fafafa;
}

.ai-model-pill:hover {
    border-color: #a5b4fc;
    background: #f5f3ff;
}

.ai-model-pill.active {
    border-color: #6366f1;
    background: #eef2ff;
}

.ai-model-pill-name {
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    letter-spacing: -0.01em;
}

.ai-model-pill.active .ai-model-pill-name {
    color: #4f46e5;
}

.ai-model-pill-sub {
    font-size: 9.5px;
    color: #9ca3af;
    margin-top: 1px;
}

.ai-model-pill.active .ai-model-pill-sub {
    color: #818cf8;
}

@keyframes aiPopupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#ai-red-fighter:hover,
.analyze-with-ai:hover {
    filter: brightness(1.15);
    cursor: pointer;
}





  /* ===== AI Background Indicator ===== */
#ai-background-indicator {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 10px 16px;
  border-radius: 25px;
  font-size: 14px;
  font-family: "Inter", "Segoe UI", sans-serif;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.4s ease;
}


#ai-background-indicator.active {
  opacity: 1;
}

.ai-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #4CAF50;
  margin-right: 8px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

.ai-indicator-text {
  letter-spacing: 0.3px;
}


#cancel-task {
  margin-left: 8px;
  background: #FF5242;
  color: white;
  border: none;
  outline: none;
  border-radius: 10px;
  /* padding: 8px; */
  text-align: center;
  height: 25px;
  cursor: pointer;
  z-index: 10000;
}

/* ===== AI Image Viewer Modal ===== */
#ai-image-viewer-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(10, 10, 18, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10001;
  justify-content: center;
  align-items: center;
  animation: fadeInBg 0.25s ease;
}

.ai-viewer-content {
  width: 94%;
  max-width: 960px;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.12);
  animation: fadeIn 0.25s ease;
  font-family: 'Inter', 'Segoe UI', sans-serif;
}

/* ── Header ── */
.ai-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px 16px;
  background: linear-gradient(135deg, #1c1c2e 0%, #2d2d44 100%);
  flex-shrink: 0;
}

.ai-viewer-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ai-viewer-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.ai-viewer-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ai-viewer-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
}

.ai-viewer-subtitle {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.ai-viewer-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.ai-viewer-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 24px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
}

/* Back button replaces × close */
.ai-viewer-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: background 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.ai-viewer-back-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

/* ── Thumbnail Grid ── */
.ai-viewer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  padding: 16px;
  background: #f7f7f9;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #d0d0d8 transparent;
}

.ai-viewer-grid::-webkit-scrollbar        { width: 5px; }
.ai-viewer-grid::-webkit-scrollbar-track  { background: transparent; }
.ai-viewer-grid::-webkit-scrollbar-thumb  { background: #d0d0d8; border-radius: 10px; }

.ai-viewer-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  background-color: #e2e2e8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, outline 0.18s ease;
  outline: 2px solid transparent;
  outline-offset: 2px;
  position: relative;
  overflow: hidden;
}

.ai-thumb-label {
  position: absolute;
  bottom: 5px;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
  line-height: 1.3;
  pointer-events: none;
}
.ai-thumb-label.env-label    { left: 5px;  background: rgba(20,100,60,0.85); }
.ai-thumb-label.social-label { right: 5px; background: rgba(60,60,180,0.85); }
.ai-thumb-label.selfie-label { left: 50%; transform: translateX(-50%); background: rgba(200,40,40,0.82); }

.ai-viewer-thumb:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  outline-color: #5b5bf0;
}

.ai-viewer-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
  color: #aaa;
  font-size: 14px;
  gap: 8px;
}

.ai-viewer-empty::before {
  content: "🔍";
  font-size: 32px;
}

/* ── Footer ── */
.ai-viewer-footer {
  padding: 11px 20px;
  border-top: 1px solid #ebebf0;
  background: #ffffff;
  flex-shrink: 0;
}

.ai-viewer-footer-text {
  font-size: 12px;
  color: #888;
  font-weight: 500;
  letter-spacing: 0.2px;
}


/* ===================================================
   AI IMAGE VIEWER — DETAIL VIEW
   =================================================== */
.ai-viewer-detail {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left: full-height image area */
.ai-viewer-detail-img-wrap {
  position: relative;
  flex: 1;
  background: #12121e;
  min-width: 0;
  display: flex;
  align-items: stretch;
}

.ai-viewer-detail-img {
  flex: 1;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Nav buttons float over the image */
.ai-viewer-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.88);
  font-size: 18px;
  color: #222;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
  line-height: 1;
}
#ai-detail-prev { left: 14px; }
#ai-detail-next { right: 14px; }
.ai-viewer-nav-btn:hover { background: #fff; color: #1c1c2e; }
.ai-viewer-nav-btn:disabled { opacity: 0.2; cursor: default; pointer-events: none; }

/* Right: info panel */
.ai-viewer-detail-info {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 18px 16px;
  border-left: 1px solid #ebebf0;
  background: #fff;
  overflow-y: auto;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #d8d8e4 transparent;
}
.ai-viewer-detail-info::-webkit-scrollbar       { width: 4px; }
.ai-viewer-detail-info::-webkit-scrollbar-thumb { background: #d8d8e4; border-radius: 10px; }

.ai-detail-info-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #aaa;
  margin-bottom: 6px;
}

.ai-detail-badges {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-detail-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  width: fit-content;
}
.ai-detail-badge.selfie { background: rgba(220,50,50,0.1);  color: #b0302a; border: 1px solid rgba(220,50,50,0.25); }
.ai-detail-badge.env    { background: rgba(20,120,60,0.1);  color: #177040; border: 1px solid rgba(20,120,60,0.25); }
.ai-detail-badge.social { background: rgba(60,60,200,0.08); color: #2828aa; border: 1px solid rgba(60,60,200,0.2);  }

.ai-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ai-detail-tag-chip {
  padding: 3px 10px;
  background: #f0f0f6;
  border: 1px solid #e0e0ea;
  border-radius: 20px;
  font-size: 11px;
  color: #555;
}

.ai-detail-nav-label {
  margin-top: auto;
  padding-top: 12px;
  font-size: 11px;
  color: #bbb;
  text-align: center;
  border-top: 1px solid #f0f0f5;
}
