/* ========== 计算器 - calculator.js ========== */

/* 计算器样式 */
.input-area {
    margin-bottom: 10px;
}

.input-area label {
    display: block;
    margin-bottom: 3px;
    font-weight: bold;
}

.input-area input {
    width: 100%;
    padding: 10px 15px;
    font-size: 14px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box;
}

.result-display {
    min-height: 40px;
    padding: 6px 10px;
    margin-top: 5px;
    background-color: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 4px;
    font-size: 14px;
    color: #004085;
    overflow-y: auto;
    max-height: 100px;
}

.result-display.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.input-area button {
    margin-top: 10px;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}

.input-area button:hover {
    background-color: #0069d9;
}

/* 计算器布局样式 */
.calculator-layout {
    margin: 10px 0;
    padding: 8px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.calculator-layout h3 {
    margin-top: 0;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
}

#image-upload {
    display: none;
}

.custom-file-upload {
    display: inline-block;
    padding: 8px 16px;
    cursor: pointer;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    margin-bottom: 10px;
}

.custom-file-upload:hover {
    background-color: #45a049;
}

/* 图片裁剪模态框 */
.crop-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.7);
}

.crop-content {
    background-color: #fefefe;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 10px;
}

.close-crop {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-crop:hover {
    color: black;
}

#crop-container {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    border: 2px dashed #ccc;
    margin: 10px 0;
}

#crop-canvas {
    width: 100%;
    height: 100%;
}

#crop-box {
    position: absolute;
    border: 2px solid white;
    background: transparent;
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.6);
}

#crop-box::before,
#crop-box::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

#crop-box::before {
    top: -3px;
    left: -3px;
}

#crop-box::after {
    top: -3px;
    right: -3px;
}

.crop-corner-nw,
.crop-corner-ne,
.crop-corner-sw,
.crop-corner-se {
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.crop-corner-nw {
    top: -3px;
    left: -3px;
}

.crop-corner-ne {
    top: -3px;
    right: -3px;
}

.crop-corner-sw {
    bottom: -3px;
    left: -3px;
}

.crop-corner-se {
    bottom: -3px;
    right: -3px;
}

.crop-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.crop-controls button {
    padding: 10px 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.crop-controls button:hover {
    background: #45a049;
}

.transparency-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    padding: 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 5px;
}

.transparency-control label {
    font-weight: bold;
    color: #333;
}

.transparency-control input[type="range"] {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

.transparency-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #4CAF50;
    border-radius: 50%;
    cursor: pointer;
}

.transparency-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #4CAF50;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.transparency-control span {
    font-weight: bold;
    color: #333;
    min-width: 45px;
    text-align: right;
}

/* 计算器网格容器 */
.calculator-grid-new {
    display: grid;
    grid-template-columns: 2.5fr 2fr 1.5fr;
    grid-template-rows: auto auto;
    gap: 4px;
    background-color: #f5e6c1;
    padding: 8px;
    border-radius: 4px;
}

/* 顶部控制栏 - 跨越三列 */
.top-controls-full {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.top-controls-full .calc-btn {
    height: 100%;
}

/* 右侧完整区域 */
.right-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bottom-right-buttons {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* 左侧区域 */
.left-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* 左侧科学函数区域 */
.science-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

.science-section .calc-btn {
    height: 100%;
}

/* 中间数字区域 */
.number-area {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.number-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

.number-grid .calc-btn {
    height: 100%;
}

.number-functions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

.number-functions .calc-btn {
    height: 100%;
}

.space-bar {
    margin-top: 3px;
}

.space-btn {
    background-color: #B0BEC5;
    color: #333;
    width: 100%;
}

/* 右侧运算符区域 */
.operator-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 3px;
}

.operator-section .calc-btn {
    height: 100%;
}

/* 单位转换区域 */
.convert-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
}

.convert-section .calc-btn {
    height: 100%;
}

/* 方程求解区域 */
.equation-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
}

.equation-section .calc-btn {
    height: 100%;
}

/* 按钮基础样式 */
.calc-btn {
    padding: 4px 6px;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid #9e8f7a;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 30px;
    height: auto;
    box-sizing: border-box;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1px;
}

.calc-btn:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

/* 按钮颜色 */
/* 科学函数按钮 - 灰色 */
.science-btn {
    background-color: #C3C3C3;
    color: #333;
}

/* 数字按钮 - 浅灰色 */
.number-btn {
    background-color: #E3E3E3;
    color: #333;
}

/* 运算符按钮 - 蓝色 */
.operator-btn {
    background-color: #97CEF7;
    color: #3F48CC;
}

/* 删除按钮 - 红色 */
.del-btn {
    background-color: #FF7376;
    color: #CC0000;
}

/* 单位转换按钮 - 浅绿色 */
.convert-btn {
    background-color: #C7CAB5;
    color: #333;
}

/* 方程求解按钮 - 灰绿色 */
.equation-btn {
    background-color: #A3AE9B;
    color: #333;
}

/* 其他功能按钮 - 深灰色 */
.other-btn {
    background-color: #9E9E9E;
    color: #333;
}

/* ANS按钮 - 紫色 */
.ans-btn {
    background-color: #C8BFE7;
    color: #333;
}

/* 等于按钮 - 蓝色 */
.equal-btn {
    background-color: #007BFF;
    color: white;
    font-size: 16px;
}

/* 装饰按钮 - 黑色 */
.decoration-btn {
    background-color: #000000;
    color: white;
}

/* 顶部控制按钮 - 灰色 */
.top-control-btn {
    background-color: #9E9E9E;
    color: #333;
}

.clr-btn {
    background-color: #6D6D6D;
    color: white;
}

/* 内存按钮 - 灰色 */
.memory-btn {
    background-color: #C3C3C3;
    color: #333;
}

/* 顶部控制栏 */
.history {
    margin-top: 20px;
}

.history h3 {
    color: #495057;
}

.history-list {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 5px;
    border-bottom: 1px solid #dee2e6;
}

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

.usage-guide {
    margin-top: 20px;
}

.usage-guide h3 {
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

.guide-content h4 {
    color: #007bff;
    margin-top: 15px;
    margin-bottom: 5px;
}

.guide-content p {
    margin: 5px 0;
    line-height: 1.4;
}

.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    padding: 10px;
    margin-top: 10px;
    color: #721c24;
}

/* 移动端响应式 - 计算器部分 */
@media (max-width: 768px) {
    /* 计算器输入框 */
    .calculator-input {
        font-size: 14px;
        padding: 5px;
        margin-bottom: 2px;
    }
    
    .result-display {
        min-height: 30px;
        max-height: 60px;
        font-size: 11px;
        padding: 4px 8px;
        margin-bottom: 3px;
    }
    
    /* 计算器按钮 */
    .calc-btn {
        padding: 1px 1px;
        font-size: 8px;
        height: 22px;
        min-width: 22px;
        border-radius: 2px;
        border: 2px solid #9e8f7a;
        margin: 1px;
    }
    
    /* 计算器主网格 */
    .calculator-grid-new {
        grid-template-columns: 2fr 2fr 1.5fr;
        gap: 3px;
        padding: 6px;
    }
    
    /* 左侧区域 */
    .left-section {
        display: flex;
        flex-direction: column;
        gap: 3px;
    }
    
    /* 科学函数区域 */
    .science-section {
        grid-template-columns: repeat(3, 1fr);
        gap: 3px;
    }
    
    /* 数字区域 */
    .number-area {
        display: flex;
        flex-direction: column;
        gap: 3px;
    }
    
    .number-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 3px;
    }
    
    /* 运算符区域 */
    .operator-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
    }
    
    /* 单位转换区域 */
    .convert-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
    }
    
    /* 方程求解区域 */
    .equation-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
    }
    
    /* 底部控制区域 */
    .bottom-controls {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
        margin-top: 3px;
    }
    
    /* 等于按钮 */
    .equal-btn {
        font-size: 11px;
    }
}
