/**
 * Universal Side Panel Component
 * Provides consistent slide-out panel UX with close button and responsive layout
 */

/* ===== SIDE PANEL OVERLAY ===== */
.gmg-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gmg-panel-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== SIDE PANEL CONTAINER ===== */
.gmg-side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--color-surface, var(--card-bg, #1a2332));
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}

.gmg-side-panel.active {
  transform: translateX(0);
}

/* Left-side variant */
.gmg-side-panel.panel-left {
  right: auto;
  left: 0;
  transform: translateX(-100%);
}

.gmg-side-panel.panel-left.active {
  transform: translateX(0);
}

/* ===== PANEL HEADER ===== */
.gmg-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border, var(--border-color, #2d3748));
  background: var(--color-surface, var(--card-bg, #1a2332));
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.gmg-panel-title {
  margin: 0;
  font-family: var(--font-display, 'Cinzel', serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--arcane, var(--primary-color, #8B5CF6));
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gmg-panel-subtitle {
  font-size: 0.875rem;
  color: var(--steel, var(--text-muted, #8899a6));
  margin: 0;
}

/* ===== CLOSE BUTTON ===== */
.gmg-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--steel, var(--text-muted, #8899a6));
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.gmg-panel-close:hover {
  background: rgba(139, 92, 246, 0.15);
  color: var(--arcane, var(--primary-color, #8B5CF6));
}

.gmg-panel-close:focus {
  outline: 2px solid var(--arcane, var(--primary-color, #8B5CF6));
  outline-offset: 2px;
}

.gmg-panel-close:active {
  transform: scale(0.95);
}

/* ===== PANEL CONTENT ===== */
.gmg-panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.25rem;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar styling */
.gmg-panel-content::-webkit-scrollbar {
  width: 6px;
}

.gmg-panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.gmg-panel-content::-webkit-scrollbar-thumb {
  background: var(--steel, var(--text-muted, #8899a6));
  border-radius: 3px;
}

.gmg-panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--arcane, var(--primary-color, #8B5CF6));
}

/* ===== PANEL FOOTER ===== */
.gmg-panel-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--color-border, var(--border-color, #2d3748));
  background: var(--color-surface, var(--card-bg, #1a2332));
  flex-shrink: 0;
}

/* ===== THEME SUPPORT ===== */

/* Light mode */
[data-theme="light"] .gmg-side-panel,
.mode-light .gmg-side-panel {
  background: var(--color-surface, #ffffff);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .gmg-panel-header,
.mode-light .gmg-panel-header,
[data-theme="light"] .gmg-panel-footer,
.mode-light .gmg-panel-footer {
  background: var(--color-surface, #ffffff);
  border-color: var(--color-border, #e2e8f0);
}

[data-theme="light"] .gmg-panel-close,
.mode-light .gmg-panel-close {
  color: var(--steel, #64748b);
}

[data-theme="light"] .gmg-panel-close:hover,
.mode-light .gmg-panel-close:hover {
  background: rgba(139, 92, 246, 0.1);
  color: var(--arcane, #8B5CF6);
}

/* Dark mode */
[data-theme="dark"] .gmg-side-panel,
.mode-dark .gmg-side-panel {
  background: var(--color-surface, #1a1f2e);
}

[data-theme="dark"] .gmg-panel-close,
.mode-dark .gmg-panel-close {
  color: var(--steel, #94a3b8);
}

[data-theme="dark"] .gmg-panel-close:hover,
.mode-dark .gmg-panel-close:hover {
  background: rgba(139, 92, 246, 0.2);
  color: var(--arcane, #a78bfa);
}

/* Genre theme integration */
.genre-theme-scifi .gmg-panel-title {
  color: var(--arcane, #00d4ff);
}

.genre-theme-horror .gmg-panel-title {
  color: var(--arcane, #dc2626);
}

.genre-theme-steampunk .gmg-panel-title {
  color: var(--arcane, #d97706);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
  .gmg-side-panel {
    max-width: 100%;
    width: 90%;
  }
}

/* Mobile (< 768px) - Full screen sheet */
@media (max-width: 767px) {
  .gmg-side-panel {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }
  
  .gmg-panel-header {
    padding: 0.875rem 1rem;
  }
  
  .gmg-panel-title {
    font-size: 1.125rem;
  }
  
  .gmg-panel-content {
    padding: 1rem;
  }
  
  .gmg-panel-footer {
    padding: 0.875rem 1rem;
  }
}

/* ===== MODAL VARIANT ===== */
/* For centered modals instead of side panels */
.gmg-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gmg-modal.active {
  opacity: 1;
  visibility: visible;
}

.gmg-modal-content {
  background: var(--color-surface, var(--card-bg, #1a2332));
  border: 1px solid var(--color-border, var(--border-color, #2d3748));
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.gmg-modal.active .gmg-modal-content {
  transform: scale(1);
}

.gmg-modal-large .gmg-modal-content {
  max-width: 800px;
}

.gmg-modal-fullscreen .gmg-modal-content {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  border-radius: 0;
}

/* Use same header for modals */
.gmg-modal .gmg-panel-header {
  position: relative;
}

.gmg-modal .gmg-panel-content {
  flex: 1;
  overflow-y: auto;
}

/* ===== UTILITY CLASSES ===== */
.panel-no-scroll {
  overflow: hidden;
}

body.panel-open {
  overflow: hidden;
}

/* Animation for panel entry */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

.gmg-side-panel.animating-in {
  animation: slideInRight 0.3s ease forwards;
}

.gmg-side-panel.animating-out {
  animation: slideOutRight 0.3s ease forwards;
}
