/* Responsive Image Gallery Modal */

/* Overlay backdrop */
.preset-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

/* Gallery container - sized to fit image */
.preset-modal-gallery {
  position: relative;
  width: 100%;
  max-width: 90vw;
  background-color: transparent;
  border-radius: 8px;
  overflow: visible;
  display: flex;
  flex-direction: column;
  cursor: default;
  flex-shrink: 1;
}

/* Image wrapper - takes up most space */
.preset-modal-image-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  width: 100%;
}

.preset-modal-main-image {
  max-width: 100%;
  max-height: calc(100vh - 40px);
  object-fit: contain;
  width: auto;
  height: auto;
}

/* Close button - top right, outside modal on desktop */
.preset-modal-close {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1001;
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  backdrop-filter: blur(10px);
}

.preset-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

/* Info overlay - bottom left */
.preset-modal-info-overlay {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 999;
  background-color: rgba(255, 255, 255, 0.15);
  padding: 12px 16px;
  border-radius: 6px;
  backdrop-filter: blur(10px);
}

.preset-modal-title {
  font-size: 16px;
  color: white;
  margin: 0;
  font-weight: 600;
}

.preset-modal-timestamp {
  font-size: 12px;
  color: #aaa;
  margin: 5px 0 0 0;
}

.preset-modal-timelapse-button {
  margin-top: 8px;
  padding: 6px 12px;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.preset-modal-timelapse-button:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/* Controls overlay - bottom center */
.preset-modal-controls-overlay {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  backdrop-filter: blur(10px);
  max-width: 90%;
  padding: 0;
}

.preset-modal-controls-overlay > * {
  padding-left: 20px;
  padding-right: 20px;
}

.preset-modal-controls-overlay > *:last-child {
  padding-bottom: 12px;
}

/* Loading Progress */
.preset-modal-loading {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 300px;
  padding-top: 12px;
}

.preset-modal-loading.visible {
  display: flex;
}

.preset-modal-loading-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preset-modal-loading-label span {
  color: #ddd;
  font-size: 12px;
}

.preset-modal-progress-bar {
  width: 100%;
  height: 6px;
  background-color: #333;
  border-radius: 3px;
  overflow: hidden;
}

.preset-modal-progress-fill {
  width: 0%;
  height: 100%;
  background-color: #0066cc;
  transition: width 0.3s ease;
}

/* Timelapse Controls */
.preset-modal-timelapse-controls {
  display: none;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 12px;
  padding-bottom: 12px;
  padding-left: 20px;
  padding-right: 20px;
}

.preset-modal-timelapse-controls.visible {
  display: flex;
}

.preset-modal-timelapse-controls button {
  padding: 8px 16px;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  transition: background-color 0.2s;
}

.preset-modal-timelapse-controls button:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.preset-modal-timelapse-controls button:disabled {
  background-color: rgba(255, 255, 255, 0.1);
  cursor: not-allowed;
  opacity: 0.5;
}

.preset-modal-timelapse-controls label {
  color: #ddd;
  font-size: 12px;
  white-space: nowrap;
}

.preset-modal-scrubber-container {
  flex: 1;
  min-width: 150px;
  max-width: 400px;
}

.preset-modal-scrubber {
  position: relative;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  cursor: pointer;
}

.preset-modal-scrubber-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: #0066cc;
  border-radius: 2px;
  transition: width 0.05s linear;
}

.preset-modal-scrubber-playhead {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: left 0.05s linear;
}

.preset-modal-speed-dropdown {
  padding: 6px 12px;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.preset-modal-speed-dropdown:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.preset-modal-speed-dropdown option {
  background-color: #222;
  color: white;
}

.preset-modal-speed-label {
  color: #ddd;
  font-size: 12px;
  width: 40px;
  text-align: right;
  white-space: nowrap;
}

.preset-modal-speed-control {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Action Buttons */
.preset-modal-action-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.preset-modal-action-buttons button {
  padding: 10px 20px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.preset-modal-action-buttons button:hover {
  background-color: #45a049;
}

/* ============================================
   TABLET STYLES (768px - 1024px)
   ============================================ */

@media (max-width: 1024px) {
  .preset-modal-overlay {
    padding: 15px;
  }

  .preset-modal-gallery {
    max-width: 95vw;
  }

  .preset-modal-close {
    width: 36px;
    height: 36px;
    font-size: 20px;
    top: 15px;
    right: 15px;
  }

  .preset-modal-controls-overlay {
    bottom: 15px;
    padding: 0;
  }

  .preset-modal-controls-overlay > * {
    padding-left: 16px;
    padding-right: 16px;
  }

  .preset-modal-controls-overlay > *:last-child {
    padding-bottom: 10px;
  }

  .preset-modal-timelapse-controls {
    padding-top: 10px;
  }

  .preset-modal-info-overlay {
    bottom: 15px;
    left: 15px;
    padding: 10px 14px;
  }
}

/* Fade in/out animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.preset-modal-info-loading {
  opacity: 0;
  animation: none;
}

.preset-modal-info-loading.loaded {
  animation: fadeIn 0.3s ease-in forwards;
}

/* ============================================
   MOBILE STYLES (max-width: 768px)
   ============================================ */

@media (max-width: 768px) {
  .preset-modal-overlay {
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0;
  }

  .preset-modal-gallery {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100%;
    border-radius: 0;
    flex-direction: column;
    gap: 0;
  }

  .preset-modal-image-wrapper {
    flex: 1;
    max-height: none;
  }

  /* Unified bottom sheet panel */
  .preset-modal-info-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 0;
    z-index: 10;
    box-sizing: border-box;
    padding: 12px 16px;
    margin: 0;
    width: 100%;
  }

  .preset-modal-title {
    font-size: 14px;
    color: white;
    margin: 0;
    padding: 0;
    font-weight: 600;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    grid-column: 1;
    grid-row: 1;
  }

  .preset-modal-timestamp {
    font-size: 11px;
    color: #aaa;
    margin: 0;
    padding: 0;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    grid-column: 1;
    grid-row: 2;
  }

  .preset-modal-timelapse-button {
    padding: 6px 12px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    width: auto;
    margin: 0;
    white-space: nowrap;
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
  }

  .preset-modal-timelapse-button:active {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(0.98);
  }

  .preset-modal-controls-overlay {
    position: fixed;
    bottom: 65px;
    left: 0;
    right: 0;
    transform: none;
    display: none;
    flex-direction: column;
    gap: 0;
    align-items: stretch;
    flex-shrink: 0;
    padding: 0;
    background: none;
    backdrop-filter: none;
    z-index: 11;
    box-sizing: border-box;
    max-width: none;
    border-radius: 0;
    top: auto;
    height: auto;
  }

  .preset-modal-controls-overlay:has(.preset-modal-timelapse-controls.visible) {
    display: flex;
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
  }

  /* Loading section styling */
  .preset-modal-controls-overlay .preset-modal-loading {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* Playback controls section */
  .preset-modal-timelapse-controls.visible {
    display: flex !important;
    flex-direction: row;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .preset-modal-controls-overlay:has(.preset-modal-timelapse-controls.visible) .preset-modal-timelapse-controls.visible button {
    padding: 8px 16px;
    white-space: nowrap;
    font-size: 13px;
    flex-shrink: 0;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.2);
    width: auto;
    transition: background-color 0.2s, transform 0.1s;
    color: white;
    border: none;
    cursor: pointer;
  }

  .preset-modal-controls-overlay:has(.preset-modal-timelapse-controls.visible) .preset-modal-timelapse-controls.visible button:active {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(0.98);
  }

  .preset-modal-controls-overlay:has(.preset-modal-timelapse-controls.visible) .preset-modal-scrubber-container {
    flex: 1;
    min-width: 150px;
    max-width: none;
  }

  .preset-modal-controls-overlay:has(.preset-modal-timelapse-controls.visible) .preset-modal-speed-dropdown {
    flex-shrink: 0;
  }

  .preset-modal-close {
    top: 12px;
    right: 12px;
  }
}

/* ============================================
   LANDSCAPE MODE AUTO-HIDE (any width, landscape orientation)
   ============================================ */

@media (orientation: landscape) and (max-height: 600px) {
  .preset-modal-overlay {
    animation: fadeIn 0.3s ease-in forwards;
  }

  .preset-modal-info-overlay,
  .preset-modal-controls-overlay {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease-out !important;
    animation: none !important;
  }

  .preset-modal-info-overlay.active,
  .preset-modal-controls-overlay.active {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .preset-modal-overlay:hover .preset-modal-info-overlay,
  .preset-modal-overlay:hover .preset-modal-controls-overlay {
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}

