/* --- 全局基础样式 --- */
body {
    font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 16px;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

h1 {
    color: #1e88e5;
    margin-bottom: 20px;
    font-size: 24px;
    text-align: center;
    font-weight: bold;
}

/* --- 布局容器 --- */
.container {
    display: flex;
    gap: 20px;
    align-items: stretch;
    max-width: 1200px;
    margin: 0 auto;
}

.input-area, .config-area {
    width: 50%;
    display: flex;
    flex-direction: column;
}

/* 卡片样式 (白底圆角) */
.card {
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    box-sizing: border-box;
    height: 100%; /* 让两边等高 */
}
/* 结果区域样式 (确保在手机上也能全宽显示) */
.result-area {
    max-width: 1200px;
    margin: 20px auto !important; /* 覆盖 container 的 margin */
    width: 100%;
}


h2 {
    font-size: 18px;
    margin-top: 0;
    margin-bottom: 15px;
    color: #444;
    border-left: 4px solid #1e88e5;
    padding-left: 10px;
}

/* --- 表单元素 --- */
textarea {
    width: 100%;
    height: 200px; /* 默认高度 */
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #dcdfe6;
    font-size: 15px;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.2s;
    flex-grow: 1; /* 自动填充剩余空间 */
}

textarea:focus, input:focus, select:focus {
    border-color: #1e88e5;
    outline: none;
}

input[type="text"], 
input[type="password"], 
select {
    width: 100%;
    padding: 10px;
    font-size: 15px;
    margin-top: 5px;
    margin-bottom: 15px;
    border: 1px solid #dcdfe6;
    border-radius: 8px;
    box-sizing: border-box;
    background: #fff;
}

/* 文件上传框美化 */
input[type="file"] {
    width: 100%;
    padding: 10px;
    background: #f9fafc;
    border: 1px dashed #c0c4cc;
    border-radius: 8px;
    cursor: pointer;
    box-sizing: border-box;
}

/* --- 按钮样式 --- */
/* 按钮组容器 */
.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-weight: bold;
}

button:active {
    transform: scale(0.98);
}

/* 主按钮 (生成报告) - 蓝色 */
#generateBtn {
    background: #1e88e5;
    color: #ffffff;
    margin-top: 20px;
    box-shadow: 0 4px 10px rgba(30, 136, 229, 0.3);
}
#generateBtn:hover {
    background: #1976d2;
}

/* 次级按钮 (识别文字) - 灰色 */
.btn-secondary {
    background: #6c757d;
    color: #ffffff;
    margin-top: 0 !important; /* 在组里不需要顶部间距 */
}
.btn-secondary:hover {
    background: #5a6268;
}

/* 提示文字 */
.tip {
    margin-top: 8px;
    font-size: 13px;
    color: #888;
    line-height: 1.4;
}

/* --- 图片预览区域 --- */
.preview-box {
    margin-top: 12px;
    padding: 10px;
    border: 2px dashed #1e88e5; /* 蓝色虚线框 */
    border-radius: 8px;
    background: #f0f8ff;
    display: none; /* 默认隐藏，JS控制显示 */
    text-align: center;
    position: relative;
}

.preview-box img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 删除图片的红叉 */
.preview-close {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff5252;
    color: white;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    cursor: pointer;
    line-height: 24px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: 2px solid #fff;
}

/* --- 加载遮罩与动画 --- */
.loading-mask {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(4px); /* 毛玻璃效果 */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-mask.hidden {
    display: none;
}

.loading-box {
    background: #ffffff;
    padding: 25px 40px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    border: 1px solid #eee;
}

.spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 4px solid #f3f3f3;
    border-top-color: #1e88e5;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 15px;
    color: #555;
    font-weight: 500;
}


/* =========================================
   📱 手机端深度适配 (Expert Mobile Optimization)
   ========================================= */
@media (max-width: 768px) {
    body {
        margin: 10px;
        background: #f0f2f5;
    }

    h1 {
        font-size: 20px;
        margin-top: 10px;
        margin-bottom: 15px;
    }

    /* 强制改为单列布局 */
    .container {
        flex-direction: column; 
        gap: 15px;
    }

    .input-area, .config-area {
        width: 100%; /* 占满屏幕宽度 */
    }
    
    .card {
        padding: 15px; /* 减小内边距，节省空间 */
    }

    /* 输入框和按钮更大，方便手指触摸 */
    input[type="text"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 12px;
    }
    textarea {
        height: 150px; /* 手机上减小高度 */
    }

    input[type="file"] {
        padding: 15px; /* 更大的点击区域 */
    }

    button {
        padding: 14px;
        font-size: 17px;
        border-radius: 10px;
    }

    /* 调整预览图大小 */
    .preview-box img {
        max-height: 180px;
    }
    
    /* 调整加载框位置 */
    .loading-box {
        width: 80%;
        text-align: center;
    }
    
    /* 结果区域在手机上也要全屏显示 */
    .result-area {
        margin: 15px 0 !important;
    }
}