<template>
  <div>
    <h4>整体外观</h4>
    <el-radio-group
      v-model="currentDisplayMode"
      @change="changeDisplayMode"
      size="small"
      class="display-mode-group"
    >
      <el-radio-button value="system">
        <span class="icon system"></span> 默认
      </el-radio-button>
      <el-radio-button value="light">
        <span class="icon light"></span> 浅色
      </el-radio-button>
      <el-radio-button value="dark">
        <span class="icon dark"></span> 深色
      </el-radio-button>
    </el-radio-group>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useSettingsStore } from '@/store/settings';
import { ElRadioGroup, ElRadioButton } from 'element-plus';

const settingsStore = useSettingsStore();
const currentDisplayMode = ref(settingsStore.displayMode);

const changeDisplayMode = (newMode) => {
  settingsStore.updateDisplayMode(newMode);
  currentDisplayMode.value = newMode;
};
</script>

<style lang="scss" scoped>
.display-mode-group {
  display: flex;
  width: 100%;
  margin-bottom: 5px;
  gap: 8px;
  .el-radio-button {
    flex: 1;
    :deep(.el-radio-button__inner) {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 4px !important;
      border: 1px solid var(--el-border-color-lighter);
      box-shadow: none;
      padding: 8px 5px;
      font-size: 12px;

      .icon {
        display: inline-block;
        width: 14px;
        height: 14px;
        margin-right: 5px;
        border-radius: 2px;
        border: 1px solid var(--el-border-color);

        &.system { background: linear-gradient(135deg, #fff 50%, #222 50%); border-color: #888; }
        &.light { background-color: #fff; }
        &.dark { background-color: #222; border-color: #555; }
      }
    }

    &.is-active :deep(.el-radio-button__inner) {
      background-color: var(--el-color-primary-light-9);
      border-color: var(--el-color-primary);
      color: var(--el-color-primary);
      box-shadow: none;
    }
  }

  .el-radio-button + .el-radio-button {
    margin-left: 0;
  }
}
</style> 