/* Dashboard styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
}

/* 顶部导航栏样式 */
header {
    background-color: #333;
    color: white;
    padding: 1rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    flex-shrink: 0;  /* 防止标题被压缩 */
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;  /* 将控制区域推到右边 */
}

.language-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;  /* 防止文字换行 */
}

.language-switch a {
    color: white;
    text-decoration: none;
    padding: 0.25rem;
    display: inline-block;  /* 确保链接是内联块级元素 */
}

.language-switch a:hover,
.language-switch a.active {
    text-decoration: underline;
}

/* 设置按钮样式 */
.settings-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    margin: 0 0.5rem;  /* 添加水平间距 */
}

.settings-btn:hover {
    opacity: 0.8;
}

/* 登出按钮样式 */
.logout-btn {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    background-color: #dc3545;
    border-radius: 4px;
    white-space: nowrap;  /* 防止文字换行 */
    margin-left: 0.5rem;  /* 添加左侧间距 */
}

.logout-btn:hover {
    background-color: #c82333;
}

main {
    max-width: 1000px;
    margin: 0 auto;
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.add-token {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

.add-token h2 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.5rem;
}

.add-token form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-weight: 500;
    color: #555;
}

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

.form-group input:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
}

.add-token button {
    background-color: #4285f4;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.add-token button:hover {
    background-color: #3367d6;
}

.add-token button:active {
    background-color: #2a56c6;
}

.token-list h2 {
    margin-bottom: 1rem;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 500px;
}

label {
    font-weight: bold;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
}

.form-group input {
    width: 100%;
    height: 36px;
    padding: 8px 12px;
    font-size: 14px;
    color: #333;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    box-sizing: border-box;
    transition: all 0.3s;
}

.form-group input:hover {
    border-color: #c0c4cc;
}

.form-group input:focus {
    outline: none;
    border-color: #409eff;
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.1);
}

.form-group input:invalid,
.form-group input:-moz-ui-invalid {
    box-shadow: none;
    border-color: #dcdfe6;
}

button {
    padding: 0.5rem 1rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}

.token-list ul {
    list-style: none;
    padding: 0;
}

.token-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 1rem;
    border: 1px solid #ddd;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.token-info {
    flex: 1;
    min-width: 0;
}

.token-info h3 {
    margin: 0 0 0.5rem 0;
}

.token-info p {
    margin: 0;
    color: #666;
}

.remove-form {
    margin-left: 1rem;
}

.remove-btn {
    background-color: #ff4444;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: white;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.remove-btn:hover {
    background-color: #ff0000;
}

.remove-btn svg {
    vertical-align: middle;
}

.code-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0;
}

.code-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

.current-code {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: #007bff;
    letter-spacing: 2px;
}

.code-with-copy {
    position: relative;
    display: flex;
    align-items: center;
}

.copy-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: #6c757d;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.copy-btn.copied {
    color: #28a745;
    background-color: rgba(40, 167, 69, 0.1);
}

.copy-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.copy-feedback {
    position: absolute;
    right: -24px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    animation: fadeInOut 2s ease-in-out;
    white-space: nowrap;
}

.copy-feedback.success {
    color: #2ecc71;
}

.copy-feedback.error {
    color: #e74c3c;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateY(-50%) translateX(-10px);
    }
    20% {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
    80% {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-50%) translateX(10px);
    }
}

.timer-container {
    position: relative;
    width: 36px;
    height: 36px;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.timer-background {
    fill: none;
    stroke: #e9ecef;
    stroke-width: 3;
}

.timer-progress {
    fill: none;
    stroke: #28a745;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: bold;
    color: #495057;
}

.settings-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.settings-btn:hover {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    visibility: hidden;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 450px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.2s ease-out;
}

.settings-modal.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.settings-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
}

.settings-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.close-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.settings-content {
    padding: 20px;
}

.settings-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #eee;
}

.settings-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.settings-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s;
}

.form-group input:hover {
    border-color: #bbb;
}

.form-group input:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
}

.settings-btn {
    width: 100%;
    padding: 10px;
    background: #4285f4;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: #3b78e7;
}

.settings-btn:active {
    background: #3367d6;
}

.tfa-status {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tfa-toggle {
    margin-left: auto;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.tfa-toggle.enabled {
    background: #34a853;
    color: white;
}

.tfa-toggle:not(.enabled) {
    background: #ea4335;
    color: white;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-out;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 自定义滚动条 */
.settings-modal::-webkit-scrollbar {
    width: 8px;
}

.settings-modal::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.settings-modal::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.settings-modal::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.mfa-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.mfa-status span {
    font-size: 0.875rem;
    color: #495057;
}

.toggle-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    background-color: #28a745;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.toggle-btn.enabled {
    background-color: #dc3545;
}

.toggle-btn:hover {
    opacity: 0.9;
}

.qr-container {
    margin-top: 1rem;
    padding: 1.25rem;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.qr-section {
    text-align: center;
    margin-bottom: 1.25rem;
}

.qr-section img {
    max-width: 180px;
    margin-bottom: 0.75rem;
}

.qr-section p {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
}

.secret-section {
    padding-top: 1.25rem;
    border-top: 1px solid #e9ecef;
}

.secret-key {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.875rem;
}

.secret-key code {
    flex: 1;
    font-family: monospace;
    color: #007bff;
    word-break: break-all;
}

.copy-btn {
    padding: 0.25rem;
    color: #6c757d;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.15s ease-in-out;
    line-height: 1;
}

.copy-btn:hover {
    color: #343a40;
}

.copy-btn.copied {
    color: #28a745;
}

.verify-2fa {
    margin-top: 1.25rem;
}

.verify-2fa p {
    font-size: 0.875rem;
    color: #495057;
    margin: 0 0 0.75rem 0;
}

.verify-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.verify-form input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    font-family: monospace;
    text-align: center;
    letter-spacing: 0.25rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.verify-form input:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.verify-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    background-color: #28a745;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.verify-btn:hover {
    background-color: #218838;
}

.verify-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.65;
}

.verify-error {
    font-size: 0.875rem;
    color: #ffffff;
    margin: 0.5rem 0 0 0;
}

.flash-messages {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 300px;
}

.flash-message {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: slideIn 0.3s ease-out;
    font-size: 0.875rem;
}

.flash-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-message.info {
    background-color: #cce5ff;
    color: #004085;
    border: 1px solid #b8daff;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* 消息提示样式 */
.alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    animation: slideIn 0.3s ease-out;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

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

/* 表单样式优化 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.form-group input:focus {
    outline: none;
    border-color: #4a90e2;
    background: white;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.submit-btn {
    width: 100%;
    padding: 0.75rem;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.submit-btn:hover {
    background: #357abd;
}

.submit-btn:active {
    transform: translateY(1px);
}

/* 表单帮助文本 */
.form-text {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* 输入框验证样式 */
.form-group input:invalid {
    border-color: #dcdfe6;
}

.form-group input:invalid:focus {
    border-color: #dcdfe6;
    box-shadow: none;
}

.form-group input:valid {
    border-color: #28a745;
}

.form-group input:valid:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* 密码修改表单样式 */
.password-form {
    position: relative;
}

.password-input-group {
    position: relative;
    margin-bottom: 1rem;
}

.password-input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-right: 2.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.password-input-group input:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.password-input-group .toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0.25rem;
}

.password-input-group .toggle-password:hover {
    color: #343a40;
}

.password-strength {
    height: 4px;
    margin-top: 0.5rem;
    border-radius: 2px;
    background: #e9ecef;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    width: 0;
    transition: width 0.3s, background-color 0.3s;
}

.password-strength-text {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    color: #6c757d;
}

.password-requirements {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

.password-requirement {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.password-requirement.met {
    color: #28a745;
}

.password-requirement i {
    font-size: 0.875rem;
}

/* 令牌详情模态框 */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    visibility: hidden;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.2s ease-out;
}

.modal.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.modal-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.modal-body {
    padding: 20px;
}

.token-info-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.token-info-section h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.qr-section img {
    max-width: 200px;
    height: auto;
}

.token-actions {
    display: flex;
    gap: 8px;
}

.token-actions .detail-btn {
    background-color: #3498db;
    border: none;
    border-radius: 4px;
    padding: 6px;
    margin-right: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.token-actions .detail-btn:hover {
    background-color: #2980b9;
}

.token-actions .detail-btn svg {
    stroke: white;
}

/* 令牌列表项布局调整 */
.token-list li {
    padding: 1rem;
    border: 1px solid #ddd;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.token-info {
    flex: 1;
    min-width: 0;
}

.token-info h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.token-actions {
    display: flex;
    gap: 8px;
}

.detail-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.detail-btn:hover {
    background: #f5f5f5;
    color: #333;
}

/* 令牌详情模态框 */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    visibility: hidden;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.2s ease-out;
}

.modal.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.modal-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.modal-body {
    padding: 20px;
}

.token-info-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.token-info-section h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.qr-section img {
    max-width: 200px;
    height: auto;
}
