/**
 * Hi-Kataloog Premium Magazine Viewer v0.4.0
 * Minimalist bottom toolbar with glass effect
 */

/* ============================================
   MAGAZINE VIEWER - Base
   ============================================ */

.hk-magazine-viewer {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #0d0d0f;
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.hk-magazine-viewer.is-open {
  display: block;
}

.hk-viewer-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ============================================
   FLOATING ACTION BUTTONS (Top Right)
   ============================================ */

.hk-floating-actions {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  gap: 8px;
}

.hk-float-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(20, 20, 25, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.hk-float-btn:hover {
  background: rgba(40, 40, 50, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.hk-float-btn--close {
  background: rgba(220, 53, 69, 0.8);
}

.hk-float-btn--close:hover {
  background: rgba(220, 53, 69, 1);
}

/* ============================================
   BOTTOM TOOLBAR - Minimalist Glass
   ============================================ */

.hk-toolbar--bottom {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(20, 20, 25, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s ease;
}

.hk-toolbar--bottom:hover {
  background: rgba(30, 30, 35, 0.85);
}

/* Hide toolbar on inactive */
.hk-magazine-viewer.is-inactive .hk-toolbar--bottom {
  opacity: 0;
  pointer-events: none;
}

.hk-magazine-viewer.is-inactive .hk-floating-actions {
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   TOOL BUTTONS
   ============================================ */

.hk-tool-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hk-tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: scale(1.1);
}

.hk-tool-btn:active {
  transform: scale(0.95);
}

.hk-tool-btn--search {
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding-right: 16px;
  margin-right: 4px;
  border-radius: 0;
}

/* Control Group */
.hk-control-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.hk-zoom-level {
  min-width: 50px;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

/* Page Navigation */
.hk-page-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 12px;
}

.hk-page-info {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  white-space: nowrap;
}

/* ============================================
   SEARCH PANEL (Collapsible from bottom)
   ============================================ */

.hk-search-panel {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  z-index: 190;
  background: rgba(20, 20, 25, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 400px;
}

.hk-search-panel.is-open {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.hk-search-panel__inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hk-search-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.hk-search-input:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(76, 175, 80, 0.5);
}

.hk-search-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.hk-search-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hk-search-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hk-search-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.hk-search-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.hk-search-results {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  min-width: 50px;
  text-align: center;
}

.hk-search-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hk-search-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ============================================
   SPREAD CONTAINER
   ============================================ */

.hk-spread-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 40px 20px 120px;
}

/* ============================================
   NAVIGATION ARROWS
   ============================================ */

.hk-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 150;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(20, 20, 25, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.hk-magazine-viewer:hover .hk-nav-arrow {
  opacity: 1;
  pointer-events: auto;
}

.hk-nav-arrow:hover {
  background: rgba(40, 40, 50, 0.9);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.hk-nav-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

.hk-nav-arrow--left {
  left: 30px;
}

.hk-nav-arrow--right {
  right: 30px;
}

.hk-nav-arrow:disabled {
  opacity: 0.2 !important;
  cursor: not-allowed;
}

/* ============================================
   SPREAD & PAGES
   ============================================ */

.hk-spread {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  max-height: 100%;
  perspective: 1500px;
}

.hk-page {
  position: relative;
  background: #fff;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.hk-page:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.hk-page__inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.hk-page__canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.hk-text-layer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0.2;
  line-height: 1;
}

.hk-text-layer > span {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

/* Binding shadow */
.hk-binding {
  width: 3px;
  height: 100%;
  background: linear-gradient(to right, 
    rgba(0,0,0,0.2), 
    transparent 50%, 
    rgba(0,0,0,0.2)
  );
  border-left: 1px solid rgba(0,0,0,0.1);
  border-right: 1px solid rgba(0,0,0,0.1);
}

/* ============================================
   LOADING STATE
   ============================================ */

.hk-page__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.hk-page__loading.is-hidden {
  opacity: 0;
}

.hk-spinner-ring {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #4CAF50;
  border-radius: 50%;
  animation: hk-spin 0.8s linear infinite;
}

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

/* ============================================
   RESPONSIVE MOBILE
   ============================================ */

@media (max-width: 768px) {
  .hk-floating-actions {
    top: 12px;
    right: 12px;
    gap: 6px;
  }
  
  .hk-float-btn {
    width: 40px;
    height: 40px;
  }
  
  .hk-toolbar--bottom {
    bottom: 12px;
    padding: 8px 14px;
    gap: 8px;
    border-radius: 40px;
  }
  
  .hk-tool-btn {
    width: 36px;
    height: 36px;
  }
  
  .hk-zoom-level {
    font-size: 12px;
    min-width: 45px;
  }
  
  .hk-page-info {
    font-size: 12px;
  }
  
  .hk-search-panel {
    min-width: calc(100vw - 40px);
    bottom: 70px;
  }
  
  .hk-nav-arrow {
    width: 48px;
    height: 48px;
  }
  
  .hk-nav-arrow--left {
    left: 12px;
  }
  
  .hk-nav-arrow--right {
    right: 12px;
  }
  
  .hk-spread-container {
    padding: 20px 10px 90px;
  }
  
  .hk-spread {
    gap: 4px;
  }
}

/* Hide on extra small screens */
@media (max-width: 480px) {
  .hk-control-group {
    padding: 0 8px;
  }
  
  .hk-tool-btn--search {
    padding-right: 8px;
  }
  
  .hk-page-nav {
    padding-left: 8px;
  }
}
/* Page Input */
.hk-page-input {
  width: 48px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  outline: none;
  transition: all 0.2s ease;
}

.hk-page-input:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.hk-page-input:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.hk-page-separator {
  margin: 0 4px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

.hk-page-total {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 500;
}

/* Remove number input arrows */
.hk-page-input::-webkit-inner-spin-button,
.hk-page-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.hk-page-input[type=number] {
  -moz-appearance: textfield;
}

/* Hide loading spinner when page is loaded */
.hk-page.is-loaded .hk-page__loading {
  opacity: 0;
  pointer-events: none;
}

/* Search Highlight Styles */
.hk-text-layer > span.highlight {
  background-color: rgba(255, 20, 147, 0.5) !important;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 20, 147, 0.7);
}

.hk-text-layer > span.highlight.selected {
  background-color: rgba(76, 175, 80, 0.5) !important;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.8);
  animation: pulse-highlight 1s ease-in-out;
}

@keyframes pulse-highlight {
  0%, 100% { 
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.8);
  }
  50% { 
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 1);
  }
}

  0% {
    transform: perspective(800px) rotateY(0deg);
    opacity: 1;
  }
  100% {
    transform: perspective(800px) rotateY(90deg);
    opacity: 0.3;
  }
}

/* Page Transition Animation - Smooth Fade & Scale */
.hk-spread.is-flipping .hk-page {
  animation: pageTransition 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes pageTransition {
  0% {
    opacity: 1;
    transform: scale(1) translateZ(0);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.95) translateZ(-20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateZ(0);
  }
}

/* Share Button (Top Left) */
.hk-floating-share {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 200;
}

.hk-float-btn--share.is-active {
  background: rgba(76, 175, 80, 0.2);
  border-color: rgba(76, 175, 80, 0.4);
}

/* Share Dropdown Menu */
.hk-share-menu {
  position: absolute;
  top: 54px;
  left: 0;
  background: rgba(20, 20, 25, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 8px;
  min-width: 180px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.hk-share-menu.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.hk-share-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.hk-share-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hk-share-menu-item svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.hk-share-menu-item span {
  flex: 1;
  text-align: left;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .hk-floating-share {
    top: 12px;
    left: 12px;
  }
}
