/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* 防止移动端字体缩放 */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    /* 修改2: 为Safari添加高度修复 */
    height: -webkit-fill-available;
}

/* 页面基础样式 */
body {
    background: url('../img/background.png') no-repeat center center fixed;
    background-size: cover;
    color: #ffffff;
    min-height: 100vh;
    /* 修改3: 兼容Safari的视口高度 */
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* 修改4: 为iPhone Notch和Dynamic Island添加安全区域 */
    padding: calc(1.5rem + env(safe-area-inset-top)) 1rem 1.5rem 1rem;
    position: relative;
    overflow-x: hidden;
}

/* Logo样式 - 默认隐藏 */
.company-logo {
    position: absolute;
    /* 修改5: 考虑安全区域 */
    top: calc(1rem + env(safe-area-inset-top));
    left: 1rem;
    width: auto;
    height: 80px;
    max-width: 200px;
    object-fit: contain;
    z-index: 100;
    transition: opacity 0.3s ease;
    display: none; /* 默认不显示 */
}

/* Logo加载失败时显示备用样式 */
.company-logo.error {
    opacity: 0.5;
    filter: grayscale(100%);
}

/* 显示Logo的类 */
.company-logo.show {
    display: block; /* 验证成功且有Logo时显示 */
}

/* 标题样式 */
.page-title {
    font-size: 2.5rem;
    font-weight: normal;
    /* 修改6: 调整标题的上边距，确保在安全区域下方 */
    margin: calc(2rem + env(safe-area-inset-top)) 0 1.5rem;
    text-align: center;
    letter-spacing: 0.3px;
    line-height: 1.2;
    padding: 0 1rem;
}
.page-title span {
    color: #00e0e0;
    display: inline-block;
}

/* 输入框容器 - 包裹输入框和箭头 */
.serial-input-container {
    position: relative;
    width: 100%;
    max-width: 1010px;
    height: 70px;
    margin-bottom: 1rem;
    /* 修改7: 调整输入框容器的上边距 */
    margin-top: calc(100px + env(safe-area-inset-top));
}

/* 输入框 - 包含箭头区域 */
.serial-input {
    width: 100%;
    height: 100%;
    padding: 0 60px 0 1.5rem;
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid #00e0e0;
    border-radius: 35px;
    color: #ffffff;
    font-size: 1.1rem;
    outline: none;
    caret-color: #00e0e0;
    transition: all 0.3s ease;
    box-sizing: border-box;
}
.serial-input::placeholder {
    color: #cccccc;
    opacity: 1;
    font-size: 1.1rem;
}
.serial-input:focus {
    border-color: #00e0e0;
    box-shadow: 0 0 0 3px rgba(0, 224, 224, 0.3);
}

/* 输入框禁用状态 */
.serial-input:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    border-color: #888;
}

/* 箭头图标容器 - 绝对定位在输入框内部右侧 */
.arrow-container {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    touch-action: manipulation;
}

/* 箭头容器禁用状态 */
.arrow-container.disabled {
    cursor: not-allowed;
    opacity: 0.7;
    pointer-events: none;
}

/* 圆形箭头背景 */
.arrow-circle {
    width: 50px;
    height: 50px;
    border: 2px solid #00e0e0;
    border-radius: 50%;
    background: #00e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

/* 箭头禁用状态 */
.arrow-container.disabled .arrow-circle {
    border-color: #888;
    background: #888;
}

/* 箭头图标 */
.arrow-icon {
    width: 15px;
    height: 15px;
    border-top: 3px solid white;
    border-right: 3px solid white;
    transform: rotate(45deg);
    margin-left: 3px;
}

/* 箭头悬停效果（移动端使用active状态） */
.arrow-container:not(.disabled):active .arrow-circle {
    background: #00c8c8;
    border-color: #00c8c8;
    transform: scale(0.95);
}

/* 桌面端悬停效果 */
@media (hover: hover) and (pointer: fine) {
    .arrow-container:not(.disabled):hover .arrow-circle {
        background: #00c8c8;
        border-color: #00c8c8;
        transform: scale(1.05);
    }
}

/* 输入框聚焦时，箭头高亮效果 */
.serial-input:focus + .arrow-container:not(.disabled) .arrow-circle {
    box-shadow: 0 0 0 3px rgba(0, 224, 224, 0.4);
}

/* 验证按钮 */
.authenticate-btn {
    width: 100%;
    max-width: 475px;
    height: 60px;
    background: #00e0e0;
    border: none;
    border-radius: 30px;
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    margin: 1rem auto 1.5rem;
    display: block;
    transition: all 0.3s ease;
    padding: 0 2rem;
    -webkit-appearance: none;
    appearance: none;
}
.authenticate-btn:active {
    background: #00c8c8;
    transform: scale(0.98);
}

/* 桌面端悬停效果 */
@media (hover: hover) and (pointer: fine) {
    .authenticate-btn:hover {
        background: #00c8c8;
        transform: scale(1.03);
    }
}

/* 验证按钮禁用状态 */
.authenticate-btn:disabled {
    background: #888;
    cursor: not-allowed;
    transform: none;
}
.authenticate-btn:disabled:active {
    transform: none;
}

/* 验证状态框 */
.verification-panel {
    width: 100%;
    max-width: 1020px;
    min-height: 300px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 1.5rem;
    text-align: center;
    margin: 2rem auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* 加载图标和文本容器 - 修改为行内布局 */
.loading-container {
    display: flex;
    flex-direction: row; /* 改为水平排列 */
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    min-height: 100px;
    gap: 15px; /* 添加间距 */
}

/* 加载图标 - 添加旋转动画 */
.loading-icon {
    width: 50px;
    height: 50px;
    transform: rotate(0deg);
    transition: transform 0.3s ease;
    margin-bottom: 0; /* 移除底部边距 */
}

/* 旋转动画类 */
.loading-icon.spinning {
    animation: spin 1.5s linear infinite;
}

/* 旋转动画定义 */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 验证文本 */
.verifying-text {
    font-size: 1.5rem;
    letter-spacing: 0.2px;
    color: #ffffff;
    text-align: center;
    line-height: 1.4;
}

/* 验证成功状态文本 */
.verifying-text.success {
    color: #00e0e0;
}

/* 验证失败状态文本 */
.verifying-text.error {
    color: #ff5555;
}

/* 提示文本 */
.instruction-text {
    font-size: 1rem;
    color: #cccccc;
    letter-spacing: 0.1px;
    margin-top: 0.5rem;
    text-align: center;
    line-height: 1.4;
    padding: 0 0.5rem;
}

/* 版权信息 */
.copyright-text {
    position: relative;
    bottom: 0;
    font-size: 0.8rem;
    color: #bbbbbb;
    text-align: center;
    width: 100%;
    padding: 1rem;
    margin-top: auto;
}

/* 公司名称样式 */
.company-name {
    font-weight: bold;
    color: #00e0e0;
}

/* 验证结果消息 */
.verification-result {
    font-size: 1.2rem;
    color: #ffffff;
    margin-top: 1rem;
    padding: 0.8rem;
    border-radius: 10px;
    width: 100%;
    max-width: 90%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.verification-result.success {
    background: rgba(0, 224, 224, 0.2);
    border: 1px solid rgba(0, 224, 224, 0.5);
}

.verification-result.error {
    background: rgba(255, 85, 85, 0.2);
    border: 1px solid rgba(255, 85, 85, 0.5);
}

/* 验证结果信息样式 */
.verification-result.info {
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.5);
}

/* 移动设备特定样式 */
@media (max-width: 768px) {
    body {
        /* 修改8: 移动端同样考虑安全区域 */
        padding: calc(1rem + env(safe-area-inset-top)) 0.5rem 1rem 0.5rem;
    }

    .company-logo {
        position: relative;
        top: auto;
        left: auto;
        height: 70px;
        /* 修改9: 移动端Logo也考虑安全区域 */
        margin: calc(0.5rem + env(safe-area-inset-top)) auto 1rem;
        display: none; /* 保持默认隐藏 */
    }

    .company-logo.show {
        display: block; /* 验证成功时显示 */
    }

    .page-title {
        font-size: 1.8rem;
        /* 修改10: 移动端标题考虑安全区域 */
        margin: calc(1rem + env(safe-area-inset-top)) 0 1.5rem;
        padding: 0 0.5rem;
    }

    .serial-input-container {
        /* 修改11: 移动端输入框容器考虑安全区域 */
        margin-top: calc(50px + env(safe-area-inset-top));
        height: 60px;
        padding: 0 1rem;
    }

    .serial-input {
        font-size: 1rem;
        padding: 0 50px 0 1.2rem;
    }

    .serial-input::placeholder {
        font-size: 1rem;
    }

    .arrow-container {
        right: 20px;
        width: 45px;
        height: 45px;
    }

    .arrow-circle {
        width: 45px;
        height: 45px;
    }

    .arrow-icon {
        width: 14px;
        height: 14px;
    }

    .authenticate-btn {
        height: 55px;
        font-size: 1.3rem;
        border-radius: 27.5px;
        margin: 0.5rem auto 1rem;
    }

    .verification-panel {
        margin-top: 1rem;
        padding: 1.2rem;
        min-height: 250px;
        border-radius: 15px;
    }

    .loading-container {
        min-height: 80px;
        margin-bottom: 0.5rem;
        gap: 10px; /* 移动端减少间距 */
    }

    .loading-icon {
        width: 40px;
        height: 40px;
    }

    .verifying-text {
        font-size: 1.3rem;
    }

    .instruction-text {
        font-size: 0.9rem;
    }

    .verification-result {
        font-size: 1rem;
        padding: 0.7rem;
    }

    .copyright-text {
        font-size: 0.7rem;
        padding: 0.8rem;
    }
}

/* 小屏幕手机 */
@media (max-width: 480px) {
    .page-title {
        font-size: 1.5rem;
        margin: 0.5rem 0 1rem;
    }

    .serial-input-container {
        height: 55px;
        /* 修改12: 小屏幕考虑安全区域 */
        margin-top: calc(40px + env(safe-area-inset-top));
    }

    .serial-input {
        font-size: 0.9rem;
        padding: 0 45px 0 1rem;
        border-radius: 27.5px;
    }

    .serial-input::placeholder {
        font-size: 0.9rem;
    }

    .arrow-container {
        right: 15px;
        width: 40px;
        height: 40px;
    }

    .arrow-circle {
        width: 40px;
        height: 40px;
    }

    .arrow-icon {
        width: 12px;
        height: 12px;
    }

    .authenticate-btn {
        height: 50px;
        font-size: 1.2rem;
    }

    .verifying-text {
        font-size: 1.1rem;
    }

    .instruction-text {
        font-size: 0.8rem;
    }

    .loading-container {
        gap: 8px;
    }

    .loading-icon {
        width: 35px;
        height: 35px;
    }
}

/* 超小屏幕 */
@media (max-width: 360px) {
    .page-title {
        font-size: 1.3rem;
    }

    .serial-input-container {
        height: 50px;
    }

    .authenticate-btn {
        height: 45px;
        font-size: 1.1rem;
    }

    .loading-container {
        flex-direction: column; /* 超小屏幕恢复垂直布局 */
        gap: 5px;
    }
}

/* 平板设备 */
@media (min-width: 769px) and (max-width: 1024px) {
    body {
        /* 修改13: 平板设备也添加安全区域支持 */
        padding: calc(1.5rem + env(safe-area-inset-top)) 1rem 1.5rem 1rem;
    }

    .page-title {
        font-size: 3rem;
    }

    .serial-input-container {
        max-width: 800px;
        height: 90px;
    }

    .serial-input {
        font-size: 1.6rem;
        padding: 0 120px 0 2rem;
    }

    .serial-input::placeholder {
        font-size: 1.6rem;
    }

    .arrow-container {
        right: 30px;
        width: 70px;
        height: 70px;
    }

    .arrow-circle {
        width: 70px;
        height: 70px;
    }

    .arrow-icon {
        width: 20px;
        height: 20px;
    }

    .authenticate-btn {
        height: 75px;
        font-size: 1.8rem;
    }

    .loading-container {
        gap: 20px;
    }
}

/* 防止iOS表单样式 */
input, textarea, select, button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0;
}

/* 触摸设备优化 */
@media (pointer: coarse) {
    .arrow-container,
    .authenticate-btn {
        min-height: 44px; /* 苹果推荐的最小触摸目标尺寸 */
    }

    .serial-input {
        font-size: 16px; /* 防止iOS缩放 */
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
    }
}

/* 打印样式 */
@media print {
    .authenticate-btn,
    .arrow-container,
    .verification-panel {
        display: none !important;
    }
}

/* 加载状态优化 */
.loading-text {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

/* Safari特定修复 */
@supports (-webkit-touch-callout: none) {
    /* 仅Safari生效的样式 */
    body {
        /* Safari视口高度修复 */
        min-height: -webkit-fill-available;
    }
}

/* 针对iOS 15+的额外修复 */
@supports (padding-top: env(safe-area-inset-top)) {
    /* 仅支持安全区域的设备 */
    body {
        background-attachment: scroll; /* 某些情况下fixed background在iOS有问题 */
    }
}