/* ==================== HOME ADMIN STYLES ==================== */

/* ==================== MASONRY + INFINITE SCROLL ==================== */

.service-wrapper {
  overflow: hidden;
}

/* Scroll wrapper — hides overflow and fits to screen width */
.carousel-scroll-wrapper {
  overflow: hidden !important;
  width: 100% !important;
  position: relative;
  height: 18vw; /* Fixed height, width will adjust */
  display: flex !important;
  align-items: stretch !important;
  margin-bottom: 20px;
}

/* Hide scrollbar for clean masonry look */
.carousel-scroll-wrapper::-webkit-scrollbar {
  display: none;
}
.carousel-scroll-wrapper {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* The track that holds masonry items */
.carousel-scroll-track {
  display: flex;
  align-items: stretch;
  width: 100%; /* Force to screen width instead of max-content */
  height: 100%;
}

/* Static track (no animation) */
.carousel-scroll-track.static {
  animation: none !important;
}

/* Masonry item — scales proportionally to fit the screen */
.masonry-item {
  flex: 1 1 auto; /* Grow and shrink proportionally based on content width */
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  margin-right: 0.5vw; /* Fixed even gap */
  display: flex;
}

/* Remove margin from the last item so it aligns perfectly with the right edge */
.masonry-item:last-child {
  margin-right: 0;
}

/* Images inside masonry items */
.masonry-item > img.img-service {
  width: 100% !important; /* Force width to match the flex box */
  height: 100% !important;
  object-fit: cover !important;
  display: block;
}

/* Videos inside masonry items */
.masonry-item .video-cont-p2 {
  height: 100%;
  width: auto;
  aspect-ratio: 16/9; /* Prevent videos from collapsing if metadata takes time */
}

.masonry-item .video-cont-p2 .code-video {
  height: 100%;
  width: 100%;
}

.masonry-item .video-cont-p2 video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Keyframes — Right to Left (default) */
@keyframes scrollRTL {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* Keyframes — Left to Right */
@keyframes scrollLTR {
  0% {
    transform: translateX(-50%);
  }
  100% {
    transform: translateX(0);
  }
}

/* Admin add button floating in carousel */
.carousel-add-btn {
  position: absolute !important;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  width: 50px !important;
  height: 50px !important;
  min-width: unset !important;
  min-height: unset !important;
  border-radius: 50% !important;
  font-size: 1.5rem !important;
  background: rgba(0, 0, 0, 0.7) !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  backdrop-filter: blur(10px);
  display: flex !important;
  align-items: center;
  justify-content: center;
}

/* Section-level admin toolbar */
.home-admin-section-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.service-wrapper:hover .home-admin-section-toolbar {
  opacity: 1;
}

.home-admin-btn {
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
  white-space: nowrap;
}

.home-admin-btn:hover {
  background: rgba(37, 108, 249, 0.9);
  border-color: rgba(37, 108, 249, 0.5);
}

.home-admin-btn.danger {
  background: rgba(220, 53, 69, 0.85);
  border-color: rgba(220, 53, 69, 0.3);
}

.home-admin-btn.danger:hover {
  background: rgba(220, 53, 69, 1);
}

/* Global Add Section button */
.home-admin-add-section-bar {
  display: flex;
  justify-content: center;
  padding: 20px 0;
  position: relative;
  z-index: 50;
}

.home-admin-add-section-btn {
  padding: 12px 28px;
  background: rgba(37, 108, 249, 0.9);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(37, 108, 249, 0.3);
}

.home-admin-add-section-btn:hover {
  background: rgba(37, 108, 249, 1);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(37, 108, 249, 0.4);
}

/* Media item overlay remove button */
.home-admin-media-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  background: rgba(220, 53, 69, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 28px;
  text-align: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.mask-img-service:hover .home-admin-media-remove {
  opacity: 1;
}

.home-admin-media-remove:hover {
  transform: scale(1.2);
  background: rgba(220, 53, 69, 1);
}

/* Add media button inside carousel */
.home-admin-add-media-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  height: 100%;
  min-height: 80px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.5);
  font-family: 'Inter', sans-serif;
  font-size: 2rem;
  transition: all 0.3s;
  flex-shrink: 0;
}

.home-admin-add-media-btn:hover {
  background: rgba(37, 108, 249, 0.1);
  border-color: rgba(37, 108, 249, 0.5);
  color: rgba(37, 108, 249, 0.8);
}

/* ==================== MODAL ==================== */
.home-admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.home-admin-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.home-admin-modal {
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s;
}

.home-admin-modal-overlay.active .home-admin-modal {
  transform: translateY(0);
}

.home-admin-modal h2 {
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 1.3rem;
  margin-bottom: 20px;
  font-weight: 600;
}

.home-admin-modal label {
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  display: block;
  margin-bottom: 6px;
  margin-top: 14px;
}

.home-admin-modal input,
.home-admin-modal textarea {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.home-admin-modal input:focus,
.home-admin-modal textarea:focus {
  border-color: rgba(37, 108, 249, 0.6);
}

.home-admin-modal textarea {
  resize: vertical;
  min-height: 80px;
}

.home-admin-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  justify-content: flex-end;
}

.home-admin-modal-actions button {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.home-admin-modal-actions .save-btn {
  background: rgba(37, 108, 249, 0.9);
  color: white;
}

.home-admin-modal-actions .save-btn:hover {
  background: rgba(37, 108, 249, 1);
}

.home-admin-modal-actions .cancel-btn {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.home-admin-modal-actions .cancel-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Upload progress */
.home-admin-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  z-index: 20;
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}

/* Toast */
.home-admin-toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: #111;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  z-index: 10002;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid #28a745;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
}

.home-admin-toast.error {
  border-left-color: #dc3545;
}

.home-admin-toast.show {
  transform: translateX(0);
  opacity: 1;
}

/* ==================== MODAL MEDIA GRID ==================== */

.home-admin-modal {
  max-height: 85vh;
  overflow-y: auto;
}

.home-modal-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 12px;
  min-height: 40px;
}

.home-modal-media-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  border: 2px solid transparent;
  transition: border-color 0.2s, opacity 0.2s, transform 0.2s;
  aspect-ratio: 4/3;
}

.home-modal-media-item:active {
  cursor: grabbing;
}

.home-modal-media-item.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.home-modal-media-item.drag-over {
  border-color: rgba(37, 108, 249, 0.8);
  transform: scale(1.05);
}

.home-modal-media-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 6px;
}

.home-modal-media-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(220, 53, 69, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s;
}

.home-modal-media-item:hover .home-modal-media-remove {
  opacity: 1;
}

.home-modal-media-remove:hover {
  background: rgba(220, 53, 69, 1);
  transform: scale(1.15);
}

.home-modal-add-media-btn {
  width: 100%;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.home-modal-add-media-btn:hover {
  background: rgba(37, 108, 249, 0.1);
  border-color: rgba(37, 108, 249, 0.5);
  color: rgba(37, 108, 249, 0.9);
}

.home-modal-add-media-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

@media screen and (max-width: 768px) {
  .carousel-scroll-wrapper {
    height: auto !important;
    display: block !important;
  }
  .carousel-scroll-track.static {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto auto !important;
    gap: 0.5vw !important;
  }
}


