/* ================================================================
   online_whiteboard.css — 在线白板工具
   ================================================================ */

/* -------- 辅助类 -------- */
.wb-hidden {
    display: none !important;
}

/* -------- 全屏模式 -------- */
.whiteboard-component.wb-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9998;
    background: #f8faff;
    margin: 0;
    padding: 0;
}

.whiteboard-component.wb-fullscreen .wb-outer {
    height: 100vh;
    border: none;
    border-radius: 0;
    margin-bottom: 0;
}

/* -------- Toast 提示 -------- */
.wb-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.wb-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
    cursor: pointer;
    max-width: 320px;
    word-break: break-word;
}

.wb-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.wb-toast.hide {
    opacity: 0;
    transform: translateX(40px);
}

.wb-toast-success { background: linear-gradient(135deg, #22c55e, #16a34a); }
.wb-toast-error   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.wb-toast-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.wb-toast-info    { background: linear-gradient(135deg, #3b82f6, #2563eb); }

/* -------- 外层容器 -------- */
.whiteboard-component {
    width: 100%;
}

.wb-outer {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 230px);
    min-height: 520px;
    border: 1.5px solid #dde6f5;
    border-radius: 16px;
    overflow: hidden;
    background: #f8faff;
    box-shadow: 0 4px 24px rgba(59, 130, 246, 0.10), 0 1px 4px rgba(0,0,0,0.04);
    margin-bottom: 20px;
}

/* -------- 顶部工具栏 -------- */
.wb-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: linear-gradient(to bottom, #ffffff, #f8faff);
    border-bottom: 1.5px solid #e2e8f0;
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 46px;
}

.wb-toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wb-toolbar-sep {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
    margin: 0 6px;
    flex-shrink: 0;
}

.wb-toolbar-label {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
}

.wb-tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.wb-tb-btn:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
    box-shadow: 0 2px 6px rgba(59,130,246,0.12);
    transform: translateY(-1px);
}

.wb-tb-btn:active:not(:disabled):not(.disabled) {
    transform: translateY(1px) !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.12) !important;
}

.wb-tb-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border-color: #2563eb;
}

.wb-tb-btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-color: #1d4ed8;
}

.wb-tb-btn-primary:active:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
    transform: translateY(1px) !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2) !important;
}

.wb-tb-btn-danger {
    background: #fff;
    color: #ef4444;
    border-color: #fecaca;
}

.wb-tb-btn-danger:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}

.wb-tb-btn.disabled,
.wb-tb-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}

/* -------- 背景按钮 -------- */
.wb-bg-group {
    flex-wrap: nowrap;
}

.wb-bg-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 9px;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    background: #f8faff;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    user-select: none;
}

.wb-bg-btn:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

.wb-bg-btn:active {
    transform: scale(0.94) !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1) !important;
}

.wb-bg-btn.active {
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border-color: #3b82f6;
    color: #1d4ed8;
    box-shadow: 0 1px 6px rgba(59, 130, 246, 0.2);
}

/* -------- 主体区域 -------- */
.wb-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* -------- 左侧工具面板 -------- */
.wb-tools-panel {
    width: 72px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px;
    background: linear-gradient(to bottom, #ffffff, #f8faff);
    border-right: 1.5px solid #e2e8f0;
    overflow-y: auto;
    gap: 4px;
}

.wb-tool-section-title {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
    margin-bottom: 2px;
    width: 100%;
    text-align: center;
}

.wb-tool-divider {
    width: 40px;
    height: 1px;
    background: #f1f5f9;
    margin: 4px 0;
}

.wb-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 52px;
    border: 1.5px solid transparent;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    gap: 2px;
}

.wb-tool-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    transform: scale(1.04);
}

.wb-tool-btn:active {
    transform: scale(0.95) !important;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.1) !important;
}

.wb-tool-btn.active {
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border-color: #3b82f6;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.25);
    transform: scale(1.04);
}

.wb-tool-icon {
    font-size: 20px;
    line-height: 1;
    display: block;
}

.wb-tool-btn[data-tool="text"] .wb-tool-icon {
    font-size: 18px;
    font-weight: 900;
    color: #334155;
    font-family: Georgia, serif;
}

.wb-tool-btn.active[data-tool="text"] .wb-tool-icon {
    color: #1d4ed8;
}

.wb-tool-label {
    font-size: 10px;
    color: #64748b;
    font-weight: 600;
    line-height: 1;
}

.wb-tool-btn.active .wb-tool-label {
    color: #1d4ed8;
}

/* -------- 画布区域 -------- */
.wb-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #edf2fb;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.06), inset 0 -2px 6px rgba(0,0,0,0.04);
}

.wb-canvas-wrap.cursor-crosshair {
    cursor: crosshair;
}

.wb-canvas-wrap.cursor-eraser {
    cursor: none; /* 使用自定义圆形游标，隐藏系统光标避免双游标 */
}

.wb-canvas-wrap.cursor-text {
    cursor: text;
}

#wbBgCanvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
}

#wbCanvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
}

/* -------- 文字输入覆盖层 -------- */
#wbTextInput {
    position: absolute;
    left: var(--wb-text-x, 0px);
    top: var(--wb-text-y, 0px);
    font-size: var(--wb-text-size, 20px);
    font-family: var(--wb-text-font, "Microsoft YaHei");
    color: var(--wb-text-color, #1a1a2e);
    opacity: var(--wb-text-opacity, 1);
    min-width: 120px;
    min-height: 36px;
    padding: 6px 10px;
    border: 2px dashed #3b82f6;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    resize: both;
    outline: none;
    line-height: 1.4;
    z-index: 10;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.2);
    backdrop-filter: blur(2px);
}

/* -------- 右侧属性面板 -------- */
.wb-props-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, #ffffff, #f8faff);
    border-left: 1.5px solid #e2e8f0;
    overflow-y: auto;
    padding: 10px 6px 10px 0;
}

.wb-props-section {
    padding: 10px 14px;
    border-bottom: 1px solid #eef2f8;
    transition: background 0.15s ease;
}

.wb-props-section:hover {
    background: rgba(239,246,255,0.5);
}

.wb-props-section:last-child {
    border-bottom: none;
}

.wb-props-title {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 8px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.wb-props-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.wb-props-row:last-child {
    margin-bottom: 0;
}

.wb-props-label {
    font-size: 12px;
    color: #475569;
    flex-shrink: 0;
}

/* -------- 颜色预览（由 CSS 自定义属性驱动） -------- */
#colorPreview {
    background-color: var(--wb-stroke-color, #1a1a2e);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18), inset 0 1px 3px rgba(255,255,255,0.2);
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

#colorPreview:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25), inset 0 1px 3px rgba(255,255,255,0.3);
}

/* -------- 色板预定义颜色（CSS 属性选择器，无需 JS 注入） -------- */
.wb-color-swatch[data-color="#1a1a2e"] { background-color: #1a1a2e; }
.wb-color-swatch[data-color="#ef4444"] { background-color: #ef4444; }
.wb-color-swatch[data-color="#f97316"] { background-color: #f97316; }
.wb-color-swatch[data-color="#eab308"] { background-color: #eab308; }
.wb-color-swatch[data-color="#22c55e"] { background-color: #22c55e; }
.wb-color-swatch[data-color="#3b82f6"] { background-color: #3b82f6; }
.wb-color-swatch[data-color="#8b5cf6"] { background-color: #8b5cf6; }
.wb-color-swatch[data-color="#ec4899"] { background-color: #ec4899; }
.wb-color-swatch[data-color="#ffffff"] { background-color: #ffffff; }
.wb-color-swatch[data-color="#64748b"] { background-color: #64748b; }


/* -------- 颜色区域 -------- */
.wb-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.wb-color-preview {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 2.5px solid rgba(255,255,255,0.9);
    outline: 1.5px solid #e2e8f0;
    flex-shrink: 0;
}

.wb-custom-color-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
}

.wb-custom-color-label input[type="color"] {
    width: 36px;
    height: 28px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    padding: 1px;
    cursor: pointer;
    background: none;
}

.wb-custom-color-hint {
    font-size: 10px;
    color: #94a3b8;
}

.wb-color-swatches {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    width: 95%;
    padding: 4px;
    margin: -4px;
}

.wb-color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.wb-color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wb-color-swatch.active {
    border-color: #1d4ed8;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
    transform: scale(1.1);
}

.wb-swatch-white {
    border-color: #e2e8f0 !important;
}

.wb-swatch-white.active {
    border-color: #1d4ed8 !important;
}

/* -------- 滑块 -------- */
.wb-slider {
    flex: 1;
    height: 5px;
    accent-color: #3b82f6;
    cursor: pointer;
    border-radius: 3px;
}

.wb-slider-val {
    font-size: 12px;
    color: #475569;
    font-weight: 600;
    min-width: 38px;
    text-align: right;
}

/* -------- 颜色输入 -------- */
.wb-color-input {
    width: 40px;
    height: 28px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    padding: 1px;
    cursor: pointer;
    background: none;
}

/* -------- 复选框 -------- */
.wb-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
    user-select: none;
}

.wb-checkbox {
    accent-color: #3b82f6;
    cursor: pointer;
}

/* -------- 数字输入 -------- */
.wb-num-input {
    width: 64px;
    padding: 4px 6px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #334155;
    background: #f8faff;
    outline: none;
    transition: border-color 0.18s ease;
}

.wb-num-input:focus {
    border-color: #3b82f6;
}

/* -------- 下拉选择 -------- */
.wb-select {
    flex: 1;
    padding: 4px 6px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #334155;
    background: #f8faff;
    outline: none;
    cursor: pointer;
    transition: border-color 0.18s ease;
}

.wb-select:focus {
    border-color: #3b82f6;
}

/* -------- 属性提示 -------- */
.wb-props-tip {
    font-size: 11px;
    color: #64748b;
    line-height: 1.6;
    padding: 6px 10px;
    background: linear-gradient(135deg, #f0f6ff, #f8faff);
    border-radius: 6px;
    border-left: 2.5px solid #3b82f6;
}

/* -------- 快捷键列表 -------- */
.wb-shortcuts-section {
    flex-grow: 1;
}

.wb-shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wb-shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #475569;
}

.wb-shortcut-item kbd {
    background: linear-gradient(to bottom, #f8faff, #f1f5f9);
    border: 1px solid #d1d9e6;
    border-bottom: 2px solid #c8d1de;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    font-family: monospace;
    color: #334155;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* -------- 状态栏 -------- */
.wb-status-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: linear-gradient(to bottom, #f8faff, #f0f4ff);
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}

.wb-status-item {
    white-space: nowrap;
}

.wb-status-item span {
    font-weight: 700;
    color: #334155;
}

.wb-status-sep {
    color: #cbd5e1;
}

/* -------- 帮助弹窗 -------- */
.wb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: wbFadeIn 0.22s ease;
}

@keyframes wbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.wb-modal {
    background: #fff;
    border-radius: 16px;
    width: 540px;
    max-width: 92vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28), 0 4px 16px rgba(0,0,0,0.10);
    overflow: hidden;
    animation: wbSlideIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255,255,255,0.8);
}

@keyframes wbSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.wb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(to right, #f8faff, #ffffff);
    border-bottom: 1.5px solid #eef2f8;
}

.wb-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e3a5f;
}

.wb-modal-close {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}

.wb-modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.wb-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    font-size: 13px;
    color: #475569;
    line-height: 1.6;
}

.wb-modal-body h4 {
    font-size: 12px;
    font-weight: 700;
    color: #1d4ed8;
    margin: 12px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-bottom: 4px;
    border-bottom: 1.5px solid #dbeafe;
}

.wb-modal-body h4:first-child {
    margin-top: 0;
}

.wb-modal-body ul {
    padding-left: 18px;
    margin: 0;
}

.wb-modal-body li {
    margin-bottom: 4px;
}

/* -------- 响应式 -------- */
@media (max-width: 1024px) {
    .wb-props-panel {
        width: 180px;
    }
}

@media (max-width: 768px) {
    .wb-outer {
        height: calc(100vh - 260px);
        min-height: 440px;
        border-radius: 8px;
    }

    .wb-toolbar {
        padding: 4px 8px;
        gap: 3px;
    }

    .wb-tb-btn {
        padding: 4px 7px;
        font-size: 11px;
    }

    .wb-bg-btn {
        padding: 3px 6px;
        font-size: 10px;
    }

    .wb-tools-panel {
        width: 56px;
        padding: 8px 4px;
    }

    .wb-tool-btn {
        width: 46px;
        height: 44px;
    }

    .wb-tool-icon {
        font-size: 17px;
    }

    .wb-tool-label {
        font-size: 9px;
    }

    .wb-props-panel {
        width: 160px;
    }

    .wb-toolbar-sep {
        display: none;
    }

    .wb-bg-group {
        display: none;
    }
}

@media (max-width: 640px) {
    .wb-main {
        flex-direction: column;
    }

    .wb-tools-panel {
        width: 100%;
        height: 56px;
        flex-direction: row;
        padding: 6px 10px;
        border-right: none;
        border-bottom: 1.5px solid #e2e8f0;
        overflow-x: auto;
        overflow-y: hidden;
        flex-shrink: 0;
    }

    .wb-tool-section-title,
    .wb-tool-divider {
        display: none;
    }

    .wb-tool-btn {
        width: 48px;
        height: 44px;
        flex-shrink: 0;
    }

    .wb-props-panel {
        width: 100%;
        height: 120px;
        flex-direction: row;
        border-left: none;
        border-top: 1.5px solid #e2e8f0;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0;
    }

    .wb-props-section {
        border-bottom: none;
        border-right: 1px solid #f1f5f9;
        flex-shrink: 0;
        min-width: 130px;
    }

    .wb-shortcuts-section {
        display: none;
    }

    .wb-status-bar {
        flex-wrap: wrap;
        gap: 4px;
    }
}

/* -------- 橡皮擦圆形游标（CSS 自定义属性驱动位置和大小） -------- */
.wb-eraser-cursor {
    position: absolute;
    left: var(--wb-eraser-x, 0px);
    top: var(--wb-eraser-y, 0px);
    width: var(--wb-eraser-size, 20px);
    height: var(--wb-eraser-size, 20px);
    border-radius: 50%;
    border: 2px solid rgba(60, 60, 60, 0.6);
    background: rgba(220, 220, 220, 0.08);
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 5;
    transition: width 0.06s ease, height 0.06s ease;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.5);
}

/* -------- 线条粗细实时预览 -------- */
.wb-stroke-preview {
    margin-top: 6px;
    height: 30px;
    background: linear-gradient(135deg, #f8faff, #f1f5f9);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
}

#wbStrokePreview {
    display: block;
    width: 100%;
    height: 30px;
}

/* -------- 自定义确认弹窗 -------- */
.wb-confirm-modal {
    max-width: 340px;
}

.wb-confirm-modal .wb-modal-header {
    background: linear-gradient(to right, #fff7ed, #fffbf5);
    border-bottom-color: #fde68a;
}

.wb-confirm-body {
    padding: 14px 20px 8px;
    font-size: 14px;
    color: #374151;
    line-height: 1.7;
}

.wb-confirm-body p {
    margin: 0;
}

.wb-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 20px 16px;
}
