<template>
  <div class="login">
    <div v-show="theme.showColorPicker" class="login-right-tools">
      <vab-color-picker />
      <vab-dark v-show="theme.showDark" />
    </div>
    
    <div class="login-left-bg">
      <div class="login-left-content">
        <div class="logo-box">
          <!-- <vab-icon icon="building-4-line" class="logo-icon" /> -->
          <span class="logo-text">浙大国际校区</span>
        </div>
        <div class="slogan-box">
          <h1 class="main-title">智慧公寓<br>一站式服务平台</h1>
          <p class="sub-title">Smart Apartment Management System</p>
          <div class="feature-list">
            <div class="feature-item">
              <vab-icon icon="shield-check-line" />
              <span>安全保障</span>
            </div>
            <div class="feature-item">
              <vab-icon icon="flashlight-line" />
              <span>高效便捷</span>
            </div>
            <div class="feature-item">
              <vab-icon icon="service-line" />
              <span>贴心服务</span>
            </div>
          </div>
        </div>
        <div class="copyright">
          Copyright © 2026 浙大海宁国际校区 All Rights Reserved.
        </div>
      </div>
    </div>
    <div class="login-right-form">
      <div class="form-wrapper">
        <slot></slot>
        <div class="login-footer-links">
          <a href="javascript:void(0)">忘记密码</a>
          <span class="divider">|</span>
          <a href="javascript:void(0)">帮助中心</a>
        </div>
        <div class="related-links">
          <p class="links-title">相关导航</p>
          <div class="links">
            <a href="https://www.intl.zju.edu.cn/zh-hans" target="_blank" class="link-item">
              <div class="icon-box school"><vab-icon icon="bank-line" /></div>
              <span class="link-text">访客预约</span>
            </a>
            <a href="javascript:void(0)" class="link-item">
              <div class="icon-box dormitory"><vab-icon icon="community-line" /></div>
              <span class="link-text">宿管中心</span>
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useSettingsStore } from '/@/store/modules/settings'

defineOptions({
  name: 'LoginContainer',
})

const settingsStore = useSettingsStore()
const { theme } = storeToRefs(settingsStore)
</script>

<style lang="scss" scoped>
.login {
  position: relative;
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background-color: #fff;

  .login-left-bg {
    flex: 1;
    height: 100%;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    position: relative;
    overflow: hidden;

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(135deg, rgba(31, 41, 55, 0.9) 0%, rgba(17, 24, 39, 0.7) 100%);
      z-index: 1;
    }

    // 背景微缩放动画
    animation: kenBurns 20s ease-out infinite alternate;

    .login-left-content {
      position: relative;
      z-index: 2;
      height: 100%;
      display: flex;
      flex-direction: column;
      padding: 60px 80px;
      color: #fff;
      
      .logo-box {
        display: flex;
        align-items: center;
        gap: 12px;
        opacity: 0;
        animation: fadeInDown 0.8s ease-out 0.2s forwards;

        .logo-icon {
          font-size: 32px;
          color: var(--el-color-primary);
        }
        
        .logo-text {
          font-size: 24px;
          font-weight: 600;
          letter-spacing: 1px;
        }
      }

      .slogan-box {
        margin-top: auto;
        margin-bottom: auto;

        .main-title {
          font-size: 56px;
          font-weight: 800;
          line-height: 1.2;
          margin-bottom: 20px;
          letter-spacing: 2px;
          text-shadow: 0 4px 10px rgba(0,0,0,0.3);
          opacity: 0;
          transform: translateX(-30px);
          animation: slideInLeft 0.8s ease-out 0.4s forwards;
        }

        .sub-title {
          font-size: 20px;
          font-weight: 300;
          letter-spacing: 1px;
          opacity: 0.8;
          margin-bottom: 40px;
          opacity: 0;
          transform: translateX(-30px);
          animation: slideInLeft 0.8s ease-out 0.6s forwards;
        }

        .feature-list {
          display: flex;
          gap: 30px;
          
          .feature-item {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 16px;
            background: rgba(255, 255, 255, 0.1);
            padding: 8px 16px;
            border-radius: 20px;
            backdrop-filter: blur(5px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            opacity: 0;
            transform: translateY(20px);
            animation: fadeInUp 0.8s ease-out forwards;

            &:nth-child(1) { animation-delay: 0.8s; }
            &:nth-child(2) { animation-delay: 0.9s; }
            &:nth-child(3) { animation-delay: 1.0s; }

            .vab-icon {
              font-size: 18px;
              color: var(--el-color-primary);
            }
          }
        }
      }

      .copyright {
        font-size: 12px;
        opacity: 0.5;
        letter-spacing: 0.5px;
        opacity: 0;
        animation: fadeIn 1s ease-in 1.2s forwards;
      }
    }
  }

  .login-right-form {
    width: 600px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    position: relative;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.08);
    z-index: 10;

    .form-wrapper {
      width: 100%;
      max-width: 440px;
      padding: 0 40px;
      
      .login-footer-links {
        margin-top: 20px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 14px;
        color: #909399;
        opacity: 0;
        animation: fadeInUp 0.8s ease-out 0.8s forwards;
        
        a {
          color: #606266;
          text-decoration: none;
          transition: color 0.3s;
          
          &:hover {
            color: var(--el-color-primary);
          }
        }
        
        .divider {
          margin: 0 15px;
          color: #e4e7ed;
        }
      }

      .related-links {
        margin-top: 40px;
        text-align: center;
        opacity: 0;
        animation: fadeInUp 0.8s ease-out 1.0s forwards;

        .links-title {
          font-size: 12px;
          color: #c0c4cc;
          margin-bottom: 20px;
          position: relative;
          
          &::before, &::after {
            content: '';
            position: absolute;
            top: 50%;
            width: 30%;
            height: 1px;
            background: #f2f6fc;
          }
          &::before { left: 0; }
          &::after { right: 0; }
        }

        .links {
          display: flex;
          justify-content: space-between;
          gap: 15px;

          .link-item {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            height: 44px;
            background: #f8fbfd;
            border: 1px solid #ebedf0;
            border-radius: 8px;
            text-decoration: none;
            transition: all 0.3s;
            cursor: pointer;

            .icon-box {
              display: flex;
              align-items: center;
              justify-content: center;
              font-size: 18px;
              
              &.school { color: #1890ff; }
              &.dormitory { color: #52c41a; }
            }

            .link-text {
              font-size: 14px;
              color: #606266;
              font-weight: 500;
            }

            &:hover {
              background: #fff;
              border-color: var(--el-color-primary);
              box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
              transform: translateY(-2px);
              
              .link-text {
                color: var(--el-color-primary);
              }
            }
          }
        }
      }
    }
  }

  .login-right-tools {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid #eee;
    border-radius: 30px;
    padding: 8px 15px;
    z-index: 20;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);

    &:hover {
      background: #ffffff;
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    }
    
    :deep() {
      .el-icon {
        color: #606266;
      }
    }
  }

  :deep() {
    .login-form {
      position: relative;
      width: 100%;
      background: transparent;
      box-shadow: none;
      border: none;
      animation: formAppear 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;

      .title {
        margin-bottom: 15px;
        font-size: 32px;
        font-weight: 800;
        color: #111827;
        text-align: left;
        letter-spacing: -0.5px;
        opacity: 0;
        animation: fadeInUp 0.8s cubic-bezier(0.23, 1, 0.32, 1) 0.2s forwards;
      }

      .title-tips {
        margin-bottom: 40px;
        font-size: 16px;
        color: #6b7280;
        text-align: left;
        font-weight: 500;
        opacity: 0;
        animation: fadeInUp 0.8s cubic-bezier(0.23, 1, 0.32, 1) 0.3s forwards;
      }

      .el-form-item {
        margin-bottom: 25px;
        animation: fadeInUp 0.8s cubic-bezier(0.23, 1, 0.32, 1) both;
        
        &:nth-of-type(1) {
          animation-delay: 0.4s;
        }
        
        &:nth-of-type(2) {
          animation-delay: 0.5s;
        }

        .el-input {
          height: 52px;
          
          .el-input__wrapper {
            background-color: #f9fafb;
            box-shadow: none;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            padding-left: 20px;
            transition: all 0.3s ease;

            .el-input__inner {
              color: #111827;
              font-size: 16px;
              height: 100%;
              &::placeholder {
                color: #9ca3af;
              }
            }

            .el-input__prefix {
              color: #9ca3af;
              font-size: 20px;
              transition: all 0.3s;
            }

            &:hover {
              background-color: #f3f4f6;
              border-color: #d1d5db;
            }

            &.is-focus {
              background-color: #ffffff;
              border-color: var(--el-color-primary);
              box-shadow: 0 0 0 4px rgba(var(--el-color-primary-rgb), 0.1) !important;

              .el-input__prefix {
                color: var(--el-color-primary);
              }
            }
          }
        }
      }

      .login-btn {
        width: 100%;
        height: 52px;
        font-size: 16px;
        font-weight: 600;
        letter-spacing: 1px;
        border-radius: 8px;
        margin-top: 15px;
        background: var(--el-color-primary);
        border: none;
        box-shadow: 0 4px 6px -1px rgba(var(--el-color-primary-rgb), 0.2), 0 2px 4px -1px rgba(var(--el-color-primary-rgb), 0.1);
        transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
        opacity: 0;
        animation: fadeInUp 0.8s cubic-bezier(0.23, 1, 0.32, 1) 0.6s forwards;

        &:hover {
          transform: translateY(-2px);
          box-shadow: 0 10px 15px -3px rgba(var(--el-color-primary-rgb), 0.3), 0 4px 6px -2px rgba(var(--el-color-primary-rgb), 0.1);
        }
        
        &:active {
          transform: translateY(0);
        }
      }
      
      .left-img {
        display: none;
      }
    }
  }

  @media (max-width: 992px) {
    .login-left-bg {
      display: none;
    }
    
    .login-right-form {
      width: 100%;
      
      .form-wrapper {
        padding: 0 20px;
      }
    }
  }
}

@keyframes kenBurns {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-50px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes formAppear {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
</style>
