/* ===== 基础重置 ===== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa, #e4ecf7);
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    overflow-x: hidden;
    transition: background 0.3s ease;
}

.container {
    width: 1100px;
    max-width: 100%;
}

/* ============================= */
/* Header */
/* ============================= */

.header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

body.dark .logo-icon {
    color: #eee;
}

.logo-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    height: 36px;
}

.logo-text h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
    line-height: 1;
    color: #1a1a1a;
    letter-spacing: 0.5px;
}

.logo-text .subtitle {
    font-size: 11px;
    color: #666;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ===== 头部按钮容器 ===== */

.header-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
}

.header-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #888;
    padding: 0;
    width: 21px;
    height: 21px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    position: relative;
}

.header-btn:hover {
    color: #555;
}

body.dark .header-btn {
    color: #666;
}

body.dark .header-btn:hover {
    color: #aaa;
}

body.dark .logo-text h1 {
    color: #e8e8e8;
}

body.dark .logo-text .subtitle {
    color: #777;
}

/* 历史按钮 - 极简时钟图标 */
.history-btn {
    border: 1.5px solid #aaa;
    border-radius: 50%;
}

.history-btn::before,
.history-btn::after {
    content: "";
    position: absolute;
    background: #aaa;
    left: 50%;
    top: 50%;
    transform-origin: center center;
}

.history-btn::before {
    width: 1.5px;
    height: 6px;
    margin-left: -0.75px;
    margin-top: -6px;
}

.history-btn::after {
    width: 6px;
    height: 1.5px;
    margin-top: -0.75px;
    margin-left: -1px;
}

body.dark .history-btn {
    border-color: #666;
}

body.dark .history-btn::before,
body.dark .history-btn::after {
    background: #666;
}

/* ===== 极简滑块暗黑按钮 ===== */

.theme-toggle {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 20px;
    border: none;
    background: #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: white;
    transition: transform 0.3s ease;
}

body.dark .theme-toggle {
    background: #444;
}

body.dark .theme-toggle::before {
    transform: translateX(18px);
}

/* ============================= */
/* 布局 */
/* ============================= */

.translate-container {
    display: flex;
    gap: 40px;
}

.panel {
    flex: 1;
    min-width: 0;
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
    transition: background 0.3s ease;
    position: relative;
}

.panel h3 {
    margin-bottom: 15px;
    font-size: 18px;
    line-height: 1;
    color: #333;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* ============================= */
/* 输入框 */
/* ============================= */

.input-panel {
    position: relative;
}

#inputText {
    min-height: 180px;
    padding-bottom: 50px;
    outline: none;
    font-size: 15px;
    color: inherit;
    word-break: break-word;
}

#inputText:focus {
    outline: none;
}

#inputText:empty::before {
    content: attr(data-placeholder);
    color: #888;
    pointer-events: none;
}

/* ============================= */
/* 输出区 */
/* ============================= */

.result-box {
    min-height: 180px;
}

.placeholder {
    color: #888;
    margin: 0;
}

.translation-text {
    font-size: 15px;
    font-weight: 500;
    margin: 0;
    line-height: 1.6;
    white-space: pre-wrap;
}

.terms-box {
    background: #f4f6f9;
    padding: 15px;
    border-radius: 12px;
    font-size: 14px;
    color: #555;
}

.lang-badge {
    display: inline-block;
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 3px 10px;
    border-radius: 20px;
}

body.dark .lang-badge {
    background: #444;
    color: #aaa;
}

.lang-badges-container {
    position: absolute;
    bottom: 20px;
    left: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-badge-wrapper {
    position: relative;
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    overflow: hidden;
    z-index: 100;
    min-width: 80px;
}

.lang-dropdown.show {
    display: block;
}

.lang-dropdown-item {
    padding: 8px 12px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
}

.lang-dropdown-item:hover {
    background: #f0f0f0;
}

.lang-dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.lang-dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

body.dark .lang-dropdown {
    background: #2a2a2a;
}

body.dark .lang-dropdown-item {
    color: #eee;
}

body.dark .lang-dropdown-item:hover {
    background: #444;
}

/* ============================= */
/* 极简图标按钮 */
/* ============================= */

.clear-btn,
.copy-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn {
    color: #888;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.clear-btn:hover {
    color: #555;
}

body.dark .clear-btn {
    color: #666;
}

body.dark .clear-btn:hover {
    color: #aaa;
}

.copy-btn {
    color: #888;
    font-size: 0;
    width: 18px;
    height: 18px;
    opacity: 0.6;
    position: relative;
}

.copy-btn:hover {
    opacity: 1;
}

.copy-btn::before,
.copy-btn::after {
    content: "";
    position: absolute;
    border-radius: 3px;
    border: 1.5px solid currentColor;
}

.copy-btn::before {
    width: 10px;
    height: 10px;
    top: 5px;
    left: 1px;
}

.copy-btn::after {
    width: 10px;
    height: 10px;
    top: 1px;
    left: 5px;
    background: white;
}

body.dark .copy-btn {
    color: #888;
}

body.dark .copy-btn:hover {
    color: #aaa;
}

body.dark .copy-btn::after {
    background: #2a2a2a;
}

body.dark .copy-btn {
    color: #888;
}

body.dark .copy-btn:hover {
    color: #aaa;
}

.copy-btn.copied {
    color: #4caf50;
}

.copy-tooltip {
    position: fixed;
    transform: translateX(-50%) translateY(-100%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    animation: fadeInUp 0.2s ease;
    z-index: 9999;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(calc(-100% + 5px));
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(-100%);
    }
}

/* ============================= */
/* 按钮区域 */
/* ============================= */

.controls {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.translate-btn {
    position: relative;
    background: black;
    color: white;
    border: none;
    padding: 16px 60px;
    border-radius: 999px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 200px;
}

.translate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.translate-btn:active {
    transform: scale(0.97);
}

.translate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading {
    display: none;
    align-items: center;
    gap: 8px;
}

.translate-btn.loading .btn-text {
    display: none;
}

.translate-btn.loading .btn-loading {
    display: inline-flex;
}

/* ============================= */
/* spinner */
/* ============================= */

.spinner {
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================= */
/* 结果动画 */
/* ============================= */

.result-content {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.result-content.show {
    opacity: 1;
    transform: translateY(0);
}

/* ============================= */
/* 🌙 暗黑模式 */
/* ============================= */

body.dark {
    background: linear-gradient(135deg, #1e1e1e, #111);
    color: #eee;
}

body.dark .panel {
    background: #2a2a2a;
}

body.dark #inputText {
    color: #fff !important;
}

body.dark .terms-box {
    background: #333;
    color: #ddd;
}

body.dark .translate-btn {
    background: white;
    color: black;
}

body.dark .panel h3 {
    color: #eee;
}

body.dark .placeholder {
    color: #888;
}

body.dark #inputText:empty::before {
    color: #888;
}

/* ============================= */
/* 历史记录下拉 */
/* ============================= */

.history-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    width: 320px;
    max-height: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}

.history-dropdown.show {
    display: flex;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.clear-history-btn {
    border: none;
    background: transparent;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clear-history-btn:hover {
    background: #f0f0f0;
    color: #555;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    max-height: 340px;
}

/* 滚动条样式 */
.history-list::-webkit-scrollbar {
    width: 4px;
    -webkit-appearance: none;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
    -webkit-appearance: none;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #ccc;
    -webkit-appearance: none;
}

.history-list::-webkit-scrollbar-thumb:active {
    background: #ccc;
    -webkit-appearance: none;
}

body.dark .history-list::-webkit-scrollbar-thumb {
    background: #555;
}

body.dark .history-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

body.dark .history-list::-webkit-scrollbar-thumb:active {
    background: #555;
}

.history-empty {
    padding: 30px 15px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.history-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s ease;
}

.history-item:hover {
    background: #f9f9f9;
}

.history-item:last-child {
    border-bottom: none;
}

.history-original {
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.4;
    word-break: break-word;
    text-align: left;
}

.history-translation {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
    line-height: 1.4;
    word-break: break-word;
    text-align: left;
}

.history-meta {
    font-size: 11px;
    color: #aaa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-delete-btn {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

.history-delete-btn:hover {
    color: #888;
}

.history-delete-btn.confirm {
    color: #e53935;
}

body.dark .history-dropdown {
    background: #2a2a2a;
}

body.dark .history-header {
    border-bottom-color: #444;
    color: #eee;
}

body.dark .clear-history-btn:hover {
    background: #444;
    color: #ddd;
}

body.dark .history-item {
    border-bottom-color: #333;
}

body.dark .history-item:hover {
    background: #333;
}

body.dark .history-original {
    color: #eee;
}

body.dark .history-translation {
    color: #ccc;
}

body.dark .history-meta {
    color: #888;
}

body.dark .history-delete-btn {
    color: #666;
}

body.dark .history-delete-btn:hover {
    color: #888;
}

body.dark .history-delete-btn.confirm {
    color: #e53935;
}

body.dark .history-empty {
    color: #888;
}

/* ============================= */
/* 响应式 */
/* ============================= */

@media (max-width: 900px) {
    .translate-container {
        flex-direction: column;
        gap: 25px;
    }
}

@media (max-width: 600px) {

    body {
        padding: 15px;
    }

    .logo-title {
        gap: 10px;
    }

    .logo-icon {
        width: 30px;
        height: 30px;
    }

    .logo-icon svg {
        width: 30px;
        height: 30px;
    }

    .logo-text {
        height: 30px;
        gap: 2px;
    }

    .logo-text h1 {
        font-size: 18px;
    }

    .logo-text .subtitle {
        font-size: 10px;
        letter-spacing: 1.5px;
    }

    .panel {
        padding: 20px;
    }

    textarea {
        font-size: 15px;
    }

    .translation-text {
        font-size: 16px;
    }

    .translate-btn {
        width: 100%;
        max-width: 320px;
    }
}

/* ============================= */
/* 登录/注册相关样式 */
/* ============================= */

/* 认证按钮 */
.auth-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    color: #666;
}

.auth-btn:hover {
    background: #f0f0f0;
}

.register-btn {
    background: #000;
    color: #fff;
}

.register-btn:hover {
    background: #333;
}

.logout-btn {
    color: #888;
}

.logout-btn:hover {
    color: #e53935;
}

/* 用户信息 */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

#usernameDisplay {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 登录弹窗 */
.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.auth-modal.show {
    display: flex;
}

.auth-modal-content {
    background: white;
    border-radius: 16px;
    width: 380px;
    max-width: 90%;
    padding: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

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

body.dark .auth-modal-content {
    background: #2a2a2a;
}

.auth-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

body.dark .auth-modal-header {
    border-bottom-color: #444;
}

.auth-tabs {
    display: flex;
    gap: 20px;
}

.auth-tab {
    border: none;
    background: transparent;
    font-size: 16px;
    padding: 8px 0;
    cursor: pointer;
    color: #888;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.auth-tab.active {
    color: #000;
    border-bottom-color: #000;
    font-weight: 500;
}

body.dark .auth-tab.active {
    color: #fff;
    border-bottom-color: #fff;
}

body.dark .auth-tab {
    color: #aaa;
}

.auth-modal-close {
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: #888;
    padding: 0;
    line-height: 1;
}

.auth-modal-close:hover {
    color: #333;
}

body.dark .auth-modal-close:hover {
    color: #fff;
}

/* 表单样式 */
.auth-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

body.dark .form-group label {
    color: #eee;
}

.form-group input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #000;
}

body.dark .form-group input {
    background: #333;
    border-color: #555;
    color: #fff;
}

body.dark .form-group input:focus {
    border-color: #fff;
}

.captcha-group {
    gap: 8px;
}

.captcha-input-wrapper {
    display: flex;
    gap: 10px;
}

.captcha-input-wrapper input {
    flex: 1;
}

.captcha-img {
    width: 100px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #ddd;
}

.auth-error {
    color: #e53935;
    font-size: 13px;
    min-height: 18px;
}

.auth-submit-btn {
    background: #000;
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.auth-submit-btn:hover {
    background: #333;
}

.auth-submit-btn:active {
    transform: scale(0.98);
}

body.dark .auth-submit-btn {
    background: #fff;
    color: #000;
}

body.dark .auth-submit-btn:hover {
    background: #ddd;
}
