@use 'sass:color';

// Variables
$footer-bg: #1a1a1a;
$text-primary: rgba(255, 255, 255, 0.95);
$text-secondary: rgba(255, 255, 255, 0.6);
$text-muted: rgba(255, 255, 255, 0.4);
$border-color: rgba(255, 255, 255, 0.08);
$hover-bg: rgba(255, 255, 255, 0.08);
$active-color: #4a90e2;
$transition-fast: 150ms ease;

.cbx-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 1000;
  background: linear-gradient(135deg, #2d2d2d 0%, #1f1f1f 100%);
  border-top: 1px solid #404040;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
  color: $text-primary;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;

  &.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
}

.page-nav-left,
.page-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.series-nav {
  flex: 0 0 auto;
  min-width: 110px;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.nav-btn {
  background: rgba(51, 51, 51, 0.9);
  border: 1px solid #555;
  color: $text-primary;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all $transition-fast;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: bold;

  &:hover:not(:disabled) {
    background: #4a4a4a;
    border-color: #666;
  }

  &:disabled {
    background: #2a2a2a;
    color: #666;
    cursor: not-allowed;
    border-color: #333;
  }

  &.series-btn {
    gap: 6px;
    padding: 6px 12px;
    background: $active-color;
    border-color: $active-color;

    .label {
      font-size: 12px;
      font-weight: 500;
    }

    &:hover:not(:disabled) {
      background: color.adjust($active-color, $lightness: -10%);
    }

    &:disabled {
      background: #555;
      border-color: #555;
      opacity: 0.5;
    }
  }
}

.page-info {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  min-width: 90px;
  text-align: center;

  .current {
    color: $active-color;
    font-weight: 600;
  }

  .separator {
    color: $active-color;
    font-weight: 600;
  }

  .total {
    color: $text-secondary;
  }
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
  max-width: none;
}

.slider-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;

  .page-slider {
    width: 100%;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background: none;
    cursor: pointer;

    /* ===== Track ===== */
    &::-webkit-slider-runnable-track {
      width: 100%;
      height: 6px;
      background: rgba(255, 255, 255, 0.12);
      border-radius: 3px;
      cursor: pointer;
    }

    &::-moz-range-track {
      width: 100%;
      height: 6px;
      background: rgba(255, 255, 255, 0.12);
      border-radius: 3px;
      cursor: pointer;
    }

    &::-ms-fill-lower,
    &::-ms-fill-upper {
      background: rgba(255, 255, 255, 0.12);
      border-radius: 3px;
    }

    /* ===== Thumb ===== */
    &::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: $active-color;
      cursor: pointer;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
      transition: transform $transition-fast, box-shadow $transition-fast;
      margin-top: calc((6px - 18px) / 2); /* center thumb on track */
    }

    &::-moz-range-thumb {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: $active-color;
      cursor: pointer;
      border: none;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
      transition: transform $transition-fast, box-shadow $transition-fast;
      margin-top: calc((6px - 18px) / 2);
    }

    &::-ms-thumb {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: $active-color;
      cursor: pointer;
      border: none;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    }
  }

  /* ===== Tick marks ===== */
  datalist {
    display: flex;
    justify-content: space-between;
    position: absolute;
    width: 100%;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    height: 10px;
    box-sizing: border-box;

    option {
      width: 0;
      position: relative;
      padding: 0;

      &::before {
        content: '';
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: 2px;
        height: 10px;
        background: rgba(255, 255, 255, 0.5);
        top: 0;
      }
    }
  }
}

.goto-page {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(51, 51, 51, 0.9);
  border-radius: 4px;
  padding: 2px;
  border: 1px solid #555;

  .page-input {
    width: 55px;
    padding: 4px 6px;
    border: none;
    border-radius: 3px;
    background: #404040;
    color: $text-primary;
    font-size: 12px;
    text-align: center;
    transition: all 0.2s ease;

    &:focus {
      outline: none;
      background: #4a4a4a;
      box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.5);
    }

    &::placeholder {
      color: #999;
    }
  }

  .go-btn {
    padding: 4px 10px;
    background: $active-color;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;

    &:hover:not(:disabled) {
      background: color.adjust($active-color, $lightness: -10%);
    }

    &:disabled {
      background: #666;
      cursor: not-allowed;
      opacity: 0.6;
    }
  }
}

@media (max-width: 768px) {
  .cbx-footer {
    height: 48px;
    padding: 0 8px;
    gap: 8px;
    justify-content: center;
  }

  .page-nav-left .series-btn,
  .page-nav-right .series-btn {
    display: none;
  }

  .page-nav-left {
    gap: 4px;
  }

  .page-nav-right {
    display: none;
  }

  .page-nav-left {
    margin: 0 auto;
    justify-content: center;
    flex: 1;
  }

  .page-controls {
    display: none;
  }

  .slider-wrapper {
    display: none;
  }

  .goto-page-wrapper {
    display: none;
  }

  .hide-on-mobile {
    display: none !important;
  }
}
