/* Modern Responsive Grid */
.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: clamp(16px, 2.5vw, 28px);
  align-items: start;
}

@media (min-width: 1600px) {
  .wallpaper-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 640px) {
  .wallpaper-grid {
    grid-template-columns: 1fr;
  }
}

/* Wallpaper Card */
.wp-card {
  background: rgba(22, 30, 52, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  will-change: transform;
  content-visibility: auto;
  contain-intrinsic-size: 320px;
}

.wp-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  transform: skewX(-25deg);
  transition: left 0.6s ease;
  z-index: 9;
  pointer-events: none;
}

.wp-card:hover::before {
  left: 150%;
}

.wp-card:hover {
  transform: translateY(-6px);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(99, 102, 241, 0.15);
}

/* Media Stage */
.wp-media {
  position: relative;
  width: 100%;
  min-height: clamp(200px, 28vw, 420px);
  max-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0e1a;
  padding: 0;
  overflow: hidden;
}

.wp-media img {
  width: 100%;
  height: 100%;
  min-height: clamp(200px, 28vw, 420px);
  object-fit: cover;
  transition: transform 0.4s ease;
}

.wp-card:hover .wp-media img {
  transform: scale(1.04);
}

.wp-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 10;
}

.fav-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
  z-index: 10;
}

.fav-badge:hover {
  transform: scale(1.15);
  background: rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.5);
}

.wp-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(10, 14, 26, 0.85) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 8;
}

.wp-card:hover .wp-overlay {
  opacity: 1;
}

.view-btn {
  border-radius: 12px !important;
  padding: 10px 24px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4) !important;
}

.wp-info {
  padding: 14px 16px;
  background: rgba(16, 22, 40, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.wp-title {
  font-size: clamp(14px, 1.8vw, 16px);
  font-weight: 700;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.wp-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================ */
/* MODAL SYSTEM                                 */
/* ============================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 28px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal.open {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-container {
  background: rgba(16, 22, 40, 0.97);
  backdrop-filter: var(--backdrop);
  -webkit-backdrop-filter: var(--backdrop);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  width: 94%;
  max-width: 1100px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.modal-container::-webkit-scrollbar { width: 4px; }
.modal-container::-webkit-scrollbar-track { background: transparent; }
.modal-container::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 99px; }

#lightbox-modal .modal-container {
  height: 88vh;
  max-height: 88vh;
  overflow: hidden;
}

.modal.open .modal-container {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(22, 30, 52, 0.5);
  flex-shrink: 0;
}

.modal-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--accent-rose);
  color: #fff;
  border-color: transparent;
}

.modal-body {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 14px;
}

#lightbox-modal .modal-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 900px) {
  .modal-body {
    grid-template-columns: 1fr;
  }
  #lightbox-modal .modal-body {
    overflow-y: auto;
  }
}

/* Mockup Stage */
.mockup-stage {
  background: radial-gradient(circle at 50% 50%, #111827 0%, #0a0e1a 100%);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: 100%;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  overflow: hidden;
}

.mockup-stage > div:first-child {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.iphone-frame {
  width: clamp(150px, 16vw, 200px);
  flex: 1 1 0;
  min-height: 0;
  max-height: 100%;
  aspect-ratio: 9 / 19.5;
  background: #0a0e1a;
  border-radius: 28px;
  border: 5px solid #1e293b;
  position: relative;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  display: block;
}

.iphone-notch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 16px;
  background: #000;
  border-radius: 16px;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.iphone-screen {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0a0e1a;
  display: block;
}

.lockscreen-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 32px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.lockscreen-clock {
  font-size: clamp(28px, 4.5vw, 40px);
  font-weight: 800;
  letter-spacing: -1px;
}

.desktop-frame {
  width: 100%;
  max-width: 100%;
  max-height: calc(100% - 50px);
  aspect-ratio: 16 / 9;
  background: #0a0e1a;
  border: clamp(4px, 0.8vw, 7px) solid #1e293b;
  border-radius: 10px;
  position: relative;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  display: block;
}

.desktop-screen {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0a0e1a;
  display: block;
}

/* Studio Panel */
.studio-panel {
  background: rgba(16, 22, 40, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.25) transparent;
}

.studio-panel::-webkit-scrollbar { width: 4px; }
.studio-panel::-webkit-scrollbar-track { background: transparent; }
.studio-panel::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.25); border-radius: 99px; }

.studio-panel h3 {
  font-size: 13px !important;
  margin: 0 0 2px 0;
}

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

.slider-group label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}

.slider-group input[type="range"] {
  accent-color: #6366f1;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
}

.studio-preview-canvas {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-height: 90px;
  object-fit: contain;
  background: #0a0e1a;
  display: block;
  flex-shrink: 0;
}

.wp-meta-details {
  font-size: 11px !important;
  margin-top: 4px !important;
}

.wp-meta-details > div {
  line-height: 1.3;
}

/* Toast */
#toast-notification {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
  z-index: 20000;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

#toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.7s infinite linear;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
