/* ============================================================
   SIILA MODAL - Custom Modal Solution
   ============================================================ */

/* Modal Overlay */
.siila-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow: hidden;
}

.siila-modal.active {
  display: block;
  opacity: 1;
}

/* Lock body scroll when modal is open */
body.siila-modal-open {
  overflow: hidden !important;
  height: 100vh;
  position: fixed;
  width: 100%;
}

/* Ensure html doesn't scroll either */
html:has(.siila-modal-open) {
  overflow: hidden !important;
}

/* Modal Controls - Flytande (utan header bar) */
.siila-modal-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10002;
  display: flex;
  gap: 8px;
  background-color: rgba(0, 0, 0, 0.4);
  padding: 8px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.siila-modal-btn {
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  padding: 0;
  margin: 0;
}

.siila-modal-btn:hover {
  color: rgba(255, 255, 255, 1);
}

.siila-modal-btn:active {
  color: rgba(255, 255, 255, 0.5);
}

.siila-modal-btn i {
  pointer-events: none;
  line-height: 1;
}

/* Modal Content Container */
.siila-modal-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 60px 80px 120px 80px; /* Thumbnails nu i botten */
  scroll-padding-top: 70px; /* Better scroll positioning */
  -webkit-overflow-scrolling: touch;
}

/* Override case-window overflow when inside modal */
.siila-modal-content .case-window {
  overflow: hidden !important;
}

/* Thumbnail Navigation - Bottom */
.siila-thumbnails {
  position: fixed;
  left: 50%;
  top: auto;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  flex-direction: row;
  gap: 12px;
  max-width: 90vw;
  overflow-x: auto;
  overflow-y: visible;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

/* Custom scrollbar for modal content - exakt som index */
.siila-modal-content::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.siila-modal-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

.siila-modal-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 7px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.siila-modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.6);
  background-clip: content-box;
}

/* Firefox scrollbar */
.siila-modal-content {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.1);
}

/* Custom scrollbar for thumbnails */
.siila-thumbnails::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.siila-thumbnails::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.siila-thumbnails::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.siila-thumbnails::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Individual Thumbnail */
.siila-thumb {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 3px solid transparent;
  transition: all 0.3s ease;
  background-color: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.siila-thumb:hover {
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

.siila-thumb.active {
  border-color: #FF0077;
  box-shadow: 0 0 20px rgba(255, 0, 119, 0.5);
}

.siila-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Thumbnail number indicator */
.siila-thumb-number {
  position: absolute;
  top: 5px;
  left: 5px;
  background-color: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  padding: 3px 7px;
  border-radius: 4px;
  z-index: 2;
}

/* Thumbnail title overlay */
.siila-thumb-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.5) 70%, transparent 100%);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  padding: 18px 5px 6px 5px;
  text-align: center;
  line-height: 1.3;
  z-index: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  word-break: break-word;
  hyphens: manual;
  overflow-wrap: break-word;
}

/* Content Sections */
.siila-modal-content .case-window {
  margin-bottom: 0;
}

/* Fullscreen mode */
.siila-modal.fullscreen {
  z-index: 99999;
}

.siila-modal.fullscreen .siila-modal-content {
  padding: 40px 60px 120px 60px;
}

/* Responsive Design */
@media screen and (max-width: 1024px) {
  .siila-modal-content {
    padding: 60px 40px 120px 40px;
  }
  
  .siila-thumbnails {
    /* Samma som desktop - i botten */
  }
  
  .siila-thumb {
    width: 80px;
    height: 80px;
  }
  
  .siila-thumb-title {
    font-size: 9px;
    padding: 16px 4px 5px 4px;
  }
}

@media screen and (max-width: 768px) {
  /* Kontroller */
  .siila-modal-controls {
    top: 15px;
    right: 15px;
    padding: 6px;
  }
  
  .siila-modal-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  
  /* Dölj fullscreen-knappen på tablet */
  #siila-fullscreen-btn {
    display: none;
  }
  
  /* Move thumbnails to bottom on mobile */
  .siila-modal-content {
    padding: 60px 20px 120px 20px;
  }
  
  /* Thumbnails redan i botten som desktop */
  
  .siila-thumb {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
  }
  
  .siila-thumb-title {
    font-size: 9px;
    padding: 15px 4px 5px 4px;
    letter-spacing: 0.15px;
  }
  
  .siila-thumb-number {
    font-size: 10px;
    padding: 3px 6px;
  }
}

@media screen and (max-width: 480px) {
  .siila-modal-controls {
    top: 10px;
    right: 10px;
    padding: 4px;
  }
  
  .siila-modal-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  
  /* Dölj fullscreen-knappen på mobil */
  #siila-fullscreen-btn {
    display: none;
  }
  
  .siila-modal-content {
    padding: 50px 15px 100px 15px;
  }
  
  .siila-thumb {
    width: 60px;
    height: 60px;
  }
  
  .siila-thumb-number {
    font-size: 9px;
    padding: 2px 5px;
  }
  
  .siila-thumb-title {
    font-size: 7px;
    padding: 12px 3px 4px 3px;
    letter-spacing: 0.1px;
  }
}

/* Loading State */
.siila-modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 18px;
  text-align: center;
}

.siila-modal-loading::after {
  content: '';
  display: block;
  width: 40px;
  height: 40px;
  margin: 20px auto 0;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Smooth fade-in animation */
.siila-modal.active .siila-modal-content {
  animation: fadeInContent 0.4s ease;
}

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