@use '../../../../shared/styles/settings-shared' as settings;

.epub-preferences-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);

  .group-title {
    font-size: settings.$settings-section-title-size;
    font-weight: settings.$settings-section-title-weight;
    color: var(--p-text-color);
    margin: 0 0 0.5rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
  }
}

.setting-item {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  padding: 0.25rem 0;

  &:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  @media (max-width: 768px) {
    flex-direction: column;
    gap: 1rem;
  }
}

.setting-info {
  flex: 1;
  min-width: 0;

  .setting-label {
    display: block;
    font-weight: settings.$settings-section-title-weight;
    color: var(--p-text-color);
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .setting-label-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;

    .setting-label {
      margin-bottom: 0;
      flex-shrink: 0;
      min-width: 100px;
    }
  }

  .setting-description {
    color: var(--p-text-muted-color);
    font-size: settings.$settings-section-description-size;
    line-height: 1.5;
    margin: 0;
  }
}

.radio-group {
  display: flex;
  gap: 1.5rem;

  @media (max-width: 768px) {
    flex-direction: column;
    gap: 0.75rem;
  }
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  label {
    font-size: settings.$settings-section-description-size;
    color: var(--p-text-color);
    cursor: pointer;
  }
}

.font-size-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  .font-size-value {
    min-width: 3rem;
    text-align: center;
    font-weight: settings.$settings-label-weight;
    color: var(--p-text-color);
  }
}

.theme-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;

  .theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: color-mix(in srgb, var(--text-color) 5%, transparent);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-width: 48px;

    .theme-colors {
      display: flex;
      gap: 0;
      padding: 0;
      border-radius: 0.5rem;
      overflow: hidden;
      border: 2px solid color-mix(in srgb, var(--text-color) 20%, transparent);
      box-sizing: border-box;
      width: 72px;
      height: 36px;
      background: none;
    }

    .theme-color {
      width: 36px;
      height: 36px;
      display: inline-block;
      border-radius: 0;
      border: none;
      margin: 0;
      padding: 0;
    }

    i {
      position: absolute;
      top: 4px;
      right: 4px;
      font-size: 0.75rem;
      color: var(--primary-color);
      margin-left: 0;
      padding-left: 0;
    }

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);

      .theme-colors {
        border-color: color-mix(in srgb, var(--primary-color) 40%, transparent);
      }
    }

    &.selected {
      .theme-colors {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 15%, transparent);
      }
      color: var(--primary-color);
      background: color-mix(in srgb, var(--primary-color) 10%, transparent);

      &:hover {
        transform: translateY(-2px);
      }
    }
  }
}

.button-group {
  @include settings.settings-button-group;

  .option-button {
    &.font-button {
      font-size: 1rem;

      &[data-font="serif"] .option-text {
        font-family: Georgia, 'Times New Roman', serif;
      }

      &[data-font="sans-serif"] .option-text {
        font-family: Arial, Helvetica, sans-serif;
      }

      &[data-font="roboto"] .option-text {
        font-family: 'Roboto', sans-serif;
      }

      &[data-font="cursive"] .option-text {
        font-family: cursive;
      }

      &[data-font="monospace"] .option-text {
        font-family: 'Courier New', monospace;
      }

      // Custom font buttons use the loaded font
      &[data-font^="custom:"] .option-text {
        font-size: settings.$settings-section-description-size;
      }
    }

    &.separator {
      cursor: default;
      pointer-events: none;
      opacity: 0.6;
      background: transparent;
      border-color: transparent;
      font-weight: settings.$settings-section-title-weight;
      color: var(--p-text-muted-color);
      min-width: auto;
      padding: 0.25rem 0.5rem;

      &:hover {
        transform: none;
        box-shadow: none;
      }
    }
  }
}
