/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #1F2937;
}

/* 容器样式 */
.container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 600px;
    width: 100%;
    animation: fadeIn 0.5s ease-out;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 16px;
}

.title {
    font-size: 28px;
    font-weight: 700;
    color: #1F2937;
    margin: 0;
    flex: 1;
}

/* 语言切换样式 */
.language-switch {
    display: flex !important;
    gap: 8px !important;
    background: #F3F4F6 !important;
    padding: 4px !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border: none !important;
}

.lang-btn {
    padding: 6px 12px !important;
    border: none !important;
    background: transparent !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    color: #6B7280 !important;
    font-family: inherit !important;
    line-height: 1.5 !important;
    outline: none !important;
    user-select: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.lang-btn:hover {
    color: #374151 !important;
    background: rgba(255, 255, 255, 0.5) !important;
}

.lang-btn:active {
    transform: translateY(1px) !important;
}

.lang-btn.active {
    background: white !important;
    color: #3B82F6 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(0) !important;
}

/* 确保header-top布局正确 */
.header-top {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 8px !important;
    flex-wrap: wrap !important;
    gap: 16px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.subtitle {
    font-size: 16px;
    color: #6B7280;
    font-weight: 400;
    margin: 0;
}

/* 主内容区域 */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 输入区域 */
.input-section {
    width: 100%;
}

.input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.text-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    font-size: 16px;
    resize: vertical;
    transition: all 0.3s ease;
    font-family: inherit;
}

.text-input:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.text-input::placeholder {
    color: #9CA3AF;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #6B7280;
    margin-top: 4px;
}

.char-count {
    font-weight: 500;
}

.example-text {
    font-style: italic;
}

/* 预览区域 */
.preview-section {
    width: 100%;
}

.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.qrcode-container {
    width: 250px;
    height: 250px;
    background: #F9FAFB;
    border: 2px dashed #E5E7EB;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
}

.qrcode-container.has-qrcode {
    background: white;
    border-style: solid;
    border-color: #E5E7EB;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #9CA3AF;
}

.placeholder-icon {
    color: #D1D5DB;
}

.placeholder-text {
    font-size: 14px;
    text-align: center;
    padding: 0 20px;
}

.qrcode-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

/* 加载状态 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #6B7280;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #E5E7EB;
    border-top: 4px solid #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误状态 */
.error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #EF4444;
    text-align: center;
    padding: 0 20px;
}

.error-icon {
    color: #EF4444;
}

/* 按钮区域 */
.button-section {
    width: 100%;
}

.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 120px;
}

.btn-primary {
    background: #3B82F6;
    color: white;
}

.btn-primary:hover {
    background: #2563EB;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #F3F4F6;
    color: #374151;
    border: 2px solid #E5E7EB;
}

.btn-secondary:hover {
    background: #E5E7EB;
    border-color: #D1D5DB;
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1F2937;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6B7280;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #F3F4F6;
    color: #374151;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 扫描区域 */
.scan-container {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.scan-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: #3B82F6;
    box-shadow: 0 0 10px #3B82F6;
    animation: scanLine 2s linear infinite;
}

@keyframes scanLine {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* 扫描结果 */
.scan-result {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.scan-result h3 {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.scan-result p {
    font-size: 16px;
    color: #1F2937;
    margin-bottom: 16px;
    word-break: break-all;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 24px;
        margin: 16px;
    }

    .title {
        font-size: 24px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .input-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .qrcode-container {
        width: 200px;
        height: 200px;
    }

    .modal-content {
        width: 95%;
        margin: 16px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
    }

    .title {
        font-size: 20px;
    }

    .subtitle {
        font-size: 14px;
    }

    .qrcode-container {
        width: 180px;
        height: 180px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .text-input {
        font-size: 14px;
        padding: 10px 14px;
    }
}