/* UX 组件库 - 增强用户体验 */

/* ==================== 加载 Spinner ==================== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-top-color: #64ffda;
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

.spinner-large {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

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

/* 按钮加载状态 */
button.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinner-rotate 0.6s linear infinite;
}

/* ==================== 骨架屏 ==================== */
.skeleton {
    background: linear-gradient(90deg,
            rgba(100, 255, 218, 0.05) 25%,
            rgba(100, 255, 218, 0.15) 50%,
            rgba(100, 255, 218, 0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* 骨架屏变体 */
.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-heading {
    height: 24px;
    width: 60%;
    margin-bottom: 16px;
}

.skeleton-card {
    height: 200px;
    border-radius: 8px;
}

.skeleton-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

/* ==================== 表单增强 ==================== */

/* 表单焦点状态 */
input:not([type="submit"]):not([type="button"]):focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #64ffda !important;
    box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.1) !important;
}

/* 表单错误状态 */
input.error,
textarea.error,
select.error {
    border-color: #ff6363 !important;
    box-shadow: 0 0 0 3px rgba(255, 99, 99, 0.1) !important;
}

/* 表单成功状态 */
input.success,
textarea.success,
select.success {
    border-color: #64ffda !important;
    box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.1) !important;
}

/* 内联错误提示 */
.form-error {
    display: block;
    color: #ff6363;
    font-size: 13px;
    margin-top: 6px;
    animation: form-error-slide 0.3s ease-out;
}

@keyframes form-error-slide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 表单成功提示 */
.form-success {
    display: block;
    color: #64ffda;
    font-size: 13px;
    margin-top: 6px;
    animation: form-error-slide 0.3s ease-out;
}

/* 禁用状态 */
button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

/* ==================== 按钮增强 ==================== */

/* 通用按钮改进 */
button,
.btn-primary,
.btn-secondary {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* 按钮波纹效果 */
button::before,
.btn-primary::before,
.btn-secondary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:active::before,
.btn-primary:active::before,
.btn-secondary:active::before {
    width: 300px;
    height: 300px;
}

/* ==================== 响应式导航菜单 ==================== */

/* 汉堡菜单按钮 */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    z-index: 1001;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    background: #ccd6f6;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* 汉堡菜单激活状态 */
.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* 移动端导航 */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    header nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        max-width: 300px;
        height: 100vh;
        background: rgba(10, 25, 47, 0.98);
        backdrop-filter: blur(10px);
        transition: right 0.3s ease;
        z-index: 1000;
        padding-top: 80px;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    }

    header nav.active {
        right: 0;
    }

    header nav ul {
        flex-direction: column;
        align-items: flex-start;
        padding: 0 20px;
    }

    header nav ul li {
        margin: 0;
        width: 100%;
        border-bottom: 1px solid rgba(100, 255, 218, 0.1);
    }

    header nav ul li a {
        display: block;
        padding: 16px 0;
    }

    /* 遮罩层 */
    .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .nav-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* ==================== 动画工具类 ==================== */

/* 淡入 */
.fade-in {
    animation: fade-in 0.5s ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 滑入 */
.slide-in-up {
    animation: slide-in-up 0.5s ease-out;
}

@keyframes slide-in-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 缩放 */
.scale-in {
    animation: scale-in 0.3s ease-out;
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== 辅助类 ==================== */

/* 文本截断 */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 多行文本截断 */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {

    /* 增大触摸目标 */
    button,
    a,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ==================== 可访问性增强 ==================== */

/* 跳转到主内容链接 */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #64ffda;
    color: #0a192f;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    font-weight: bold;
}

.skip-to-main:focus {
    top: 0;
}

/* 仅屏幕阅读器可见 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 聚焦指示器 */
*:focus-visible {
    outline: 2px solid #64ffda;
    outline-offset: 2px;
}