/* ═══════════════════════════════════════════════
   ItSave — Instagram Downloader Styles
   ═══════════════════════════════════════════════ */

/* ── Form card Instagram gradient accent ── */
.form-card::before {
  background: linear-gradient(
    90deg,
    #f09433,
    #e6683c,
    #dc2743,
    #cc2366,
    #bc1888
  ) !important;
}

/* ── Page header Instagram icon gradient ── */
.tool-page-header .fa-instagram {
  background: linear-gradient(
    45deg,
    #f09433,
    #e6683c,
    #dc2743,
    #cc2366,
    #bc1888
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ═══════════════════════════════════════════════
   Loading Overlay & Animations
   ═══════════════════════════════════════════════ */
@keyframes igSpinnerRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes igLoadingPulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes igBarFill {
  0% {
    width: 0%;
  }
  50% {
    width: 70%;
  }
  100% {
    width: 100%;
  }
}

.ig-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1999;
  padding: 16px;
}

.ig-loading-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: igLoadingPulse 1.2s ease-in-out infinite;
}

.ig-loading-spinner {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ig-spinner-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid var(--border);
  border-top-color: transparent;
  border-right-color: #e1306c;
  border-radius: 50%;
  animation: igSpinnerRotate 1.5s linear infinite;
}

.ig-spinner-icon {
  position: relative;
  z-index: 10;
  font-size: 32px;
  background: linear-gradient(
    45deg,
    #f09433,
    #e6683c,
    #dc2743,
    #cc2366,
    #bc1888
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ig-loading-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.ig-loading-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 20px;
  line-height: 1.5;
}

.ig-loading-bar {
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.ig-loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #e1306c, #833ab4);
  border-radius: 10px;
  animation: igBarFill 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════
   Fade-in animations for results
   ═══════════════════════════════════════════════ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.4s ease-out;
}

/* ═══════════════════════════════════════════════
   Gallery Grid
   ═══════════════════════════════════════════════ */
.ig-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 32px;
  animation: igGalleryIn 0.4s ease;
}

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

/* ── Media Card ── */
.ig-media-card {
  background: var(--surface, #fff);
  border: 1.5px solid var(--surface-border, #e5e7eb);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    transform 0.28s ease,
    box-shadow 0.28s ease,
    border-color 0.28s ease;
}

.ig-media-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
  border-color: rgba(225, 48, 108, 0.28);
}

/* ── Thumbnail ── */
.ig-media-thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-alt, #f3f4f6);
  cursor: pointer;
}

.ig-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.ig-media-card:hover .ig-media-thumb img {
  transform: scale(1.06);
}

/* ── Hover overlay ── */
.ig-media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0.15) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.28s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ig-media-card:hover .ig-media-overlay {
  opacity: 1;
}

.ig-preview-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition:
    transform 0.2s,
    background 0.2s;
}

.ig-preview-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.12);
}

/* ── Card footer ── */
.ig-media-footer {
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ig-media-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(225, 48, 108, 0.09);
  color: #c0255a;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.ig-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e1306c, #833ab4);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.ig-download-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════
   Preview Modal
   ═══════════════════════════════════════════════ */
@keyframes igOverlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes igModalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.93) translateY(-14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.ig-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* JS toggles this class to open/close */
.ig-modal-overlay.active {
  display: flex;
  animation: igOverlayIn 0.22s ease;
}

.ig-modal {
  background: var(--surface, #fff);
  border: 1px solid var(--surface-border, #e5e7eb);
  border-radius: 20px;
  width: 100%;
  max-width: 700px;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  animation: igModalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Modal Header ── */
.ig-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 22px;
  border-bottom: 1px solid var(--surface-border, #e5e7eb);
  flex-shrink: 0;
}

.ig-modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text, #111827);
  margin: 0;
}

.ig-modal-title .fa-instagram {
  font-size: 1.15rem;
  background: linear-gradient(
    45deg,
    #f09433,
    #e6683c,
    #dc2743,
    #cc2366,
    #bc1888
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ig-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--surface-border, #e5e7eb);
  background: var(--bg-alt, #f9fafb);
  color: var(--text-muted, #6b7280);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.18s,
    color 0.18s,
    border-color 0.18s;
  border: none;
  padding: 0;
}

.ig-modal-close:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ── Modal Body ── */
.ig-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt, #f8f9fa);
  min-height: 180px;
}

.ig-modal-img {
  max-width: 100%;
  max-height: 62vh;
  border-radius: 12px;
  object-fit: contain;
  display: block;
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.14);
}

/* ── Modal Footer ── */
.ig-modal-footer {
  padding: 15px 22px;
  border-top: 1px solid var(--surface-border, #e5e7eb);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.ig-modal-label {
  font-size: 0.83rem;
  color: var(--text-muted, #6b7280);
  font-style: italic;
}

.ig-modal-dl {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 22px;
  background: linear-gradient(135deg, #e1306c, #833ab4);
  color: #fff;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  white-space: nowrap;
  border: none;
  cursor: pointer;
}

.ig-modal-dl:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════
   Dark mode
   ═══════════════════════════════════════════════ */
[data-theme="dark"] .ig-media-badge {
  background: rgba(225, 48, 108, 0.18);
  color: #f472b6;
}

[data-theme="dark"] .ig-media-card:hover {
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  border-color: rgba(244, 114, 182, 0.3);
}

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

[data-theme="dark"] .ig-modal-body {
  background: var(--bg-alt);
}

[data-theme="dark"] .ig-loading-card {
  background: var(--bg-alt);
  border-color: var(--border);
}

/* ═══════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .ig-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .ig-loading-card {
    padding: 40px 24px;
  }
}

@media (max-width: 480px) {
  .ig-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 24px;
  }

  .ig-media-footer {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .ig-download-btn {
    justify-content: center;
    padding: 9px 12px;
  }

  .ig-modal-body {
    padding: 18px 16px;
  }

  .ig-modal-footer {
    padding: 12px 16px;
    justify-content: center;
  }

  .ig-modal-label {
    display: none;
  }

  .ig-loading-card {
    padding: 32px 20px;
  }

  .ig-loading-spinner {
    width: 60px;
    height: 60px;
    margin-bottom: 16px;
  }

  .ig-spinner-icon {
    font-size: 24px;
  }

  .ig-loading-title {
    font-size: 1rem;
  }

  .ig-loading-text {
    font-size: 0.85rem;
    margin-bottom: 16px;
  }
}

@media (max-width: 380px) {
  .ig-gallery {
    grid-template-columns: 1fr;
  }
}
