/* 自定义样式 */
body {
    background-color: #f8f9fa;
}

/* 确保页面最小高度占满整个视口 */
html,
body {
    height: 100%;
}

.min-vh-100 {
    min-height: 100vh !important;
}

.flex-grow-1 {
    flex-grow: 1 !important;
}

/* 页面标题行平滑过渡 */
#page-title-row {
    transition: opacity 0.3s ease, max-height 0.3s ease;
    max-height: 200px;
    /* 足够容纳标题的高度 */
}

#page-title-row.d-none {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
    /* 禁用所有子元素的交互 */
}
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.375rem;
}

.card-header {
    background-color: #ffffff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

#image-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
}

/* 结果图片容器 - 保持固定高度避免布局抖动 */
#result-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 600px;
    max-height: 600px;
    overflow: visible;
}

#result-image {
    max-height: 600px;
    max-width: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    border: 2px solid #dee2e6;
    border-radius: 0.375rem;
}

/* 手机端调整容器高度 */
@media (max-width: 768px) {
    #result-image-container {
        min-height: 400px;
        max-height: 400px;
    }

    #result-image {
        max-height: 400px;
    }
}
.corner-point {
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: #007bff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    cursor: grab;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    /* 移除transform的transition以提升拖拽性能 */
    will-change: transform;
    /* 提示浏览器这个元素会发生变换，优化渲染 */
}

/* 放大镜样式 */
.magnifier {
    position: absolute;
    width: 150px;
    height: 150px;
    border: 3px solid #007bff;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
    display: none;
}

.magnifier canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.magnifier::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 20px;
    background-color: rgba(255, 0, 0, 0.8);
    transform: translate(-50%, -50%);
    z-index: 2;
    pointer-events: none;
}

.magnifier::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 2px;
    background-color: rgba(255, 0, 0, 0.8);
    transform: translate(-50%, -50%);
    z-index: 2;
    pointer-events: none;
}

.corner-point:hover {
    background-color: #0056b3;
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

.corner-point.dragging {
    cursor: grabbing;
    background-color: #28a745;
    transform: translate(-50%, -50%) scale(1.4);
    box-shadow: 0 4px 16px rgba(40, 167, 69, 0.4);
    transition: none;
    /* 拖拽时完全禁用transition */
}

.selection-area {
    position: absolute;
    border: 2px solid #007bff;
    background-color: rgba(0, 123, 255, 0.1);
    pointer-events: none;
    z-index: 5;
}

#result-image {
    border-radius: 0.375rem;
}

.btn {
    border-radius: 0.375rem;
}

/* Loading animation */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Alert styles */
.alert {
    border-radius: 0.375rem;
    margin-top: 1rem;
}

/* Progress indicator */
.step-indicator {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.step {
    display: flex;
    align-items: center;
    margin: 0 1rem;
}

.step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #6c757d;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    font-weight: bold;
}

.step.active .step-number {
    background-color: #007bff;
}

.step.completed .step-number {
    background-color: #28a745;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
}

/* Canvas container for relative positioning */
.canvas-container {
    position: relative;
    display: inline-block;
}

/* Utility classes */
.cursor-pointer {
    cursor: pointer;
}

.text-muted-light {
    color: #8a8a8a !important;
}

/* Footer样式 - 粘性底部 */
.footer {
    background-color: #343a40;
    color: #d6d8db;
    padding: 0.75rem 0;
    border-top: 3px solid #007bff;
    text-align: center;
    font-size: 0.9rem;
}

.footer a {
    color: #d6d8db;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* GitHub链接样式 */
.github-link {
    position: absolute;
    top: 0;
        right: 0;
    color: #6c757d;
    z-index: 1000;
    transition: color 0.3s ease, transform 0.2s ease;
}

.github-link:hover {
    color: #007bff;
    transform: scale(1.1);
}

/* 纵横比调整控件 */
.aspect-ratio-control {
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
}

.aspect-ratio-control .form-range {
    cursor: pointer;
}

.aspect-ratio-control .form-range::-webkit-slider-thumb {
    background-color: #007bff;
}

.aspect-ratio-control .form-range::-moz-range-thumb {
    background-color: #007bff;
}

/* 响应式：窄屏下调整控件布局 */
@media (max-width: 576px) {
    .aspect-ratio-control {
        width: 100%;
        justify-content: center;
    }

    .aspect-ratio-control .form-range {
        flex-grow: 1;
        max-width: 200px;
    }
}

/* 手机端优化 */
@media (max-width: 768px) {
    .corner-point:hover {
        transform: translate(-50%, -50%) scale(1.2);
        /* 减少移动端的hover缩放 */
    }

    .corner-point.dragging {
        transform: translate(-50%, -50%) scale(1.3);
        /* 减少移动端的拖拽缩放 */
    }

    /* 防止手机端选择文本 */
    .canvas-container {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    /* 优化canvas在手机端的显示 */
    #image-canvas {
        touch-action: none;
        /* 防止浏览器处理触摸手势 */
    }
}

/* 响应式设计改进 */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .card {
        margin-bottom: 1rem;
    }
}