/* ==========================================
   圖像裁切編輯器樣式
   ========================================== */

.image-crop-editor-modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.image-crop-editor-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
}

.image-crop-editor-dialog {
    position: relative;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
}

/* 標題欄 */
.image-crop-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.image-crop-editor-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

.image-crop-editor-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-crop-editor-close-btn:hover {
    color: #111827;
}

/* 主體 */
.image-crop-editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1.5rem;
    padding: 1.5rem;
    background: #f9fafb;
}

.image-crop-editor-preview-wrapper {
    display: flex;
    flex: 1;
    gap: 1.5rem;
    min-width: 0;
}

.image-crop-editor-preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: grab;
    user-select: none;
    position: relative;
    min-width: 300px;
    aspect-ratio: 1;
}

.image-crop-editor-preview-container:active {
    cursor: grabbing;
}

.image-crop-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 圓形頭像預覽遮罩 */
.image-crop-avatar-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    border-radius: 50%;
    /* 使用 box-shadow 創建外部遮罩效果 */
    box-shadow: inset 0 0 0 9999px rgba(0, 0, 0, 0.25);
    /* 圓形邊框 */
    border: 3px solid rgba(255, 255, 255, 0.7);
}

.image-crop-mask-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 11;
}

/* 控制面板 */
.image-crop-editor-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 220px;
}

.image-crop-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.image-crop-control-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.5;
}

.image-crop-slider-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.image-crop-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.image-crop-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
    border: 2px solid #fff;
}

.image-crop-slider::-webkit-slider-thumb:hover {
    background: #2563eb;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.6);
}

.image-crop-slider::-webkit-slider-thumb:active {
    transform: scale(1.1);
}

.image-crop-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid #fff;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.image-crop-slider::-moz-range-thumb:hover {
    background: #2563eb;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.6);
}

.image-crop-value-display {
    min-width: 50px;
    text-align: right;
    font-size: 0.875rem;
    font-weight: 600;
    color: #3b82f6;
    background: #dbeafe;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
}

/* 頁腳 */
.image-crop-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.image-crop-btn-cancel,
.image-crop-btn-confirm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.image-crop-btn-cancel {
    background: #e5e7eb;
    color: #374151;
}

.image-crop-btn-cancel:hover {
    background: #d1d5db;
    transform: translateY(-1px);
}

.image-crop-btn-cancel:active {
    transform: translateY(0);
}

.image-crop-btn-confirm {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.image-crop-btn-confirm:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.image-crop-btn-confirm:active {
    transform: translateY(0);
}

/* 響應式設計 */
@media (max-width: 900px) {
    .image-crop-editor-body {
        flex-direction: column;
        gap: 1rem;
    }

    .image-crop-editor-preview-wrapper {
        flex-direction: column;
    }

    .image-crop-editor-controls {
        min-width: unset;
    }

    .image-crop-editor-preview-container {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .image-crop-editor-dialog {
        max-width: 95%;
        max-height: 95vh;
        width: 95%;
    }

    .image-crop-editor-header,
    .image-crop-editor-body,
    .image-crop-editor-footer {
        padding: 1rem;
    }

    .image-crop-editor-header h2 {
        font-size: 1rem;
    }

    .image-crop-editor-body {
        gap: 1rem;
    }
}

@media (max-width: 600px) {
    .image-crop-editor-dialog {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        width: 100%;
    }

    .image-crop-editor-header,
    .image-crop-editor-body,
    .image-crop-editor-footer {
        padding: 0.75rem;
    }

    .image-crop-editor-header h2 {
        font-size: 0.95rem;
    }

    .image-crop-editor-footer {
        flex-direction: row-reverse;
        gap: 0.5rem;
    }

    .image-crop-btn-cancel,
    .image-crop-btn-confirm {
        flex: 1;
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .image-crop-btn-cancel i,
    .image-crop-btn-confirm i {
        display: none;
    }

    .image-crop-editor-controls {
        min-width: unset;
        gap: 1rem;
    }

    .image-crop-editor-preview-container {
        min-width: 100%;
        aspect-ratio: 1;
        height: auto;
    }

    .image-crop-editor-preview-wrapper {
        gap: 1rem;
    }
}

/* 打印樣式 */
@media print {
    .image-crop-editor-modal {
        display: none !important;
    }
}
