/* ========================================
   鍏ㄥ睆涔﹀啓鍔熻兘鏍峰紡
   ======================================== */

/* 涔﹀啓鐢诲竷灞?- 瑕嗙洊鍦℅GB涓婃柟 */
.drawing-canvas-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    pointer-events: none;
}

.drawing-canvas-layer.active {
    pointer-events: auto;
    cursor: crosshair;
}

.drawing-canvas-layer.active.eraser-mode {
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="rgba(255,255,255,0.3)" stroke="white" stroke-width="2"/></svg>') 12 12, auto;
}

.drawing-canvas-layer.active.shape-mode {
    cursor: crosshair;
}

.drawing-canvas-layer canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 涔﹀啓宸ュ叿鍒囨崲鎸夐挳 */
.drawing-toggle-btn {
    position: fixed;
    bottom: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(147, 51, 234, 0.9));
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    z-index: 10001;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    transition: all 0.3s ease;
    animation: toggle-btn-appear 0.4s ease-out;
}

.drawing-toggle-btn.position-right {
    right: 20px;
    left: auto;
}

.drawing-toggle-btn.position-left {
    left: 20px;
    right: auto;
}

.drawing-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.5);
}

.drawing-toggle-btn:active {
    transform: scale(0.95);
}

.drawing-toggle-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
}

@keyframes toggle-btn-appear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 涔﹀啓宸ュ叿鏍?*/
.drawing-toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 8px 6px;
    background: rgba(30, 30, 46, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 10001;
    user-select: none;
    opacity: 0;
    max-width: calc(100vw - 24px);
}

.drawing-toolbar.visible {
    display: flex;
    animation: toolbar-slide-in 0.35s ease-out forwards;
}

@keyframes toolbar-slide-in {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.drawing-toolbar.dragging {
    transition: none;
    cursor: grabbing;
}

/* 鎷栧姩鎵嬫焺 */
.drawing-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 42px;
    flex: 0 0 auto;
    cursor: grab;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin-right: 2px;
}

.drawing-drag-handle:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.1);
}

.drawing-drag-handle:active {
    cursor: grabbing;
}

/* 宸ュ叿鏍忔寜閽?*/
.drawing-toolbar-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 0 0 auto;
}

.drawing-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.08);
}

.drawing-toolbar-btn.active {
    background: var(--subject-color, #3b82f6);
    box-shadow: 0 0 12px var(--subject-color, #3b82f6);
}

/* 婵€鍏夌瑪鎸夐挳鐗规畩鏍峰紡 */
.drawing-toolbar-btn.laser-btn.active {
    background: #ef4444;
    box-shadow: 0 0 15px #ef4444;
}

.drawing-toolbar-btn.geometry-btn.active {
    background: #10b981;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.75);
}

/* 棰滆壊鎸夐挳 - 鑹茬浉鐜?*/
.drawing-color-trigger {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: conic-gradient(hsl(0, 100%, 50%),
            hsl(30, 100%, 50%),
            hsl(60, 100%, 50%),
            hsl(90, 100%, 50%),
            hsl(120, 100%, 50%),
            hsl(150, 100%, 50%),
            hsl(180, 100%, 50%),
            hsl(210, 100%, 50%),
            hsl(240, 100%, 50%),
            hsl(270, 100%, 50%),
            hsl(300, 100%, 50%),
            hsl(330, 100%, 50%),
            hsl(360, 100%, 50%));
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    flex: 0 0 auto;
}

.drawing-color-trigger::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, #fff 50%, transparent 51%);
}

.drawing-color-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.drawing-color-trigger .current-color {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* 绗旇Е澶у皬鎸夐挳 */
.drawing-size-trigger {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.drawing-size-trigger:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.08);
}

.drawing-size-trigger .size-preview {
    border-radius: 50%;
    background: #fff;
    transition: all 0.2s ease;
}

/* 寮瑰嚭閫夋嫨鍣?- 閫氱敤鏍峰紡 */
.drawing-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(30, 30, 46, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10002;
}

.drawing-popup.show {
    opacity: 1;
    visibility: visible;
}

.drawing-popup::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: rgba(30, 30, 46, 0.98);
}

.geometry-popup {
    display: grid;
    grid-template-columns: repeat(2, minmax(78px, 1fr));
    gap: 8px;
    min-width: 220px;
}

.geometry-popup-btn {
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    min-height: 38px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.geometry-popup-btn:hover,
.geometry-popup-btn.active {
    background: rgba(16, 185, 129, 0.9);
}

.geometry-popup-btn i {
    width: 18px;
    text-align: center;
}

.geometry-popup-btn span {
    font-size: 13px;
}

/* 棰滆壊寮瑰嚭閫夋嫨鍣?*/
.color-popup {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    min-width: 160px;
}

.color-popup-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-popup-btn:hover {
    transform: scale(1.15);
}

.color-popup-btn.active {
    border-color: #fff;
    box-shadow: 0 0 10px currentColor;
}

/* 绗旇Е澶у皬寮瑰嚭閫夋嫨鍣?*/
.size-popup {
    display: flex;
    gap: 10px;
    padding: 8px;
}

.size-popup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.size-popup-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.size-popup-btn.active {
    border-color: var(--subject-color, #3b82f6);
    background: rgba(59, 130, 246, 0.2);
}

.size-popup-btn .dot {
    border-radius: 50%;
    background: #fff;
}

/* 姗＄毊鎿﹀脊鍑洪€夋嫨鍣?*/
.eraser-popup {
    display: flex;
    gap: 10px;
    padding: 8px;
}

.eraser-popup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.eraser-popup-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.eraser-popup-btn.active {
    border-color: var(--subject-color, #3b82f6);
    background: rgba(59, 130, 246, 0.2);
}

.eraser-popup-btn .eraser-dot {
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    border: 2px solid #fff;
}

/* 姗＄毊鎿︽寜閽縺娲荤姸鎬?*/
.drawing-toolbar-btn.eraser-btn.active {
    background: #6b7280;
    box-shadow: 0 0 12px rgba(107, 114, 128, 0.6);
}

/* 鍒嗛殧绾?*/
.drawing-toolbar-divider {
    width: 1px;
    height: 28px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 2px;
    flex: 0 0 auto;
}

/* 鍝嶅簲寮?*/
@media (max-width: 768px) {
    .drawing-toggle-btn {
        bottom: 12px;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .drawing-toggle-btn.position-right {
        right: 12px;
    }

    .drawing-toggle-btn.position-left {
        left: 12px;
    }

    .drawing-toolbar {
        bottom: 12px;
        padding: 6px 8px 6px 4px;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: center;
        border-radius: 24px;
        max-width: calc(100vw - 24px);
    }

    .drawing-drag-handle {
        width: 24px;
        height: 36px;
        font-size: 12px;
    }

    .drawing-toolbar-btn,
    .drawing-color-trigger,
    .drawing-size-trigger {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .drawing-color-trigger .current-color {
        width: 14px;
        height: 14px;
    }

    .drawing-color-trigger::before {
        width: 16px;
        height: 16px;
    }

    .drawing-popup {
        padding: 10px;
    }

    .geometry-popup {
        min-width: 200px;
        grid-template-columns: repeat(2, minmax(72px, 1fr));
    }

    .color-popup-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .drawing-toggle-btn {
        bottom: 10px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .drawing-toggle-btn.position-right {
        right: 10px;
    }

    .drawing-toggle-btn.position-left {
        left: 10px;
    }

    .drawing-toolbar {
        padding: 5px 6px 5px 3px;
        gap: 3px;
        border-radius: 30px;
        max-width: calc(100vw - 20px);
    }

    .drawing-drag-handle {
        width: 20px;
        height: 32px;
        font-size: 10px;
    }

    .drawing-toolbar-btn,
    .drawing-color-trigger,
    .drawing-size-trigger {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .drawing-color-trigger .current-color {
        width: 12px;
        height: 12px;
    }

    .drawing-color-trigger::before {
        width: 14px;
        height: 14px;
    }

    .geometry-popup {
        min-width: 190px;
    }
}
