/* 全局样式 */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

#app {
    height: 100vh;
    overflow: hidden;
}

/* 左侧面板样式 */
.left-panel {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    background: white;
}

.left-panel .nav-tabs {
    border-bottom: 1px solid #dee2e6;
    background: white;
}

.left-panel .nav-tabs .nav-link {
    color: #6c757d;
    border: none;
    font-size: 14px;
    padding: 12px 16px;
}

.left-panel .nav-tabs .nav-link.active {
    color: #0d6efd;
    background: #f8f9fa;
    border-bottom: 2px solid #0d6efd;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* 组件列表样式 */
.component-list {
    padding: 15px;
}

.component-category {
    color: #6c757d;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e9ecef;
}

.component-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.component-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s ease;
    text-align: center;
}

.component-item:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.15);
    transform: translateY(-1px);
}

.component-item:active {
    cursor: grabbing;
}

.component-item i {
    font-size: 20px;
    color: #6c757d;
    margin-bottom: 5px;
}

.component-item span {
    font-size: 12px;
    color: #495057;
    font-weight: 500;
}

/* 模板列表样式 */
.template-list {
    padding: 15px;
}

.template-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.template-item:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.15);
}

.template-item:hover .template-actions {
    opacity: 1;
    visibility: visible;
}

.template-item.active {
    border-color: #198754;
    background: #f8fff9;
    box-shadow: 0 2px 8px rgba(25, 135, 84, 0.2);
}

.template-item.active .template-actions {
    opacity: 1;
    visibility: visible;
}

.template-item img {
    height: 40px;
    width: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    background: #e9ecef;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.template-item img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 2px solid #0d6efd;
}

.template-thumbnail {
    position: relative;
}

.template-thumbnail::after {
    content: "🔍";
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.template-thumbnail:hover::after {
    opacity: 1;
}

.template-info h6 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #212529;
}

.template-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.template-info p {
    margin: 0;
    font-size: 12px;
    color: #6c757d;
}

/* 模板操作按钮样式 */
.template-actions {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-left: 10px;
    opacity: 0.4;
    visibility: visible;
    transition: all 0.2s ease;
    min-width: 34px;
    align-self: center;
}

.template-actions .btn {
    padding: 3px 5px;
    font-size: 10px;
    border-width: 1px;
    min-width: 28px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.template-actions .btn i {
    font-size: 10px;
    line-height: 1;
}

.template-save-btn {
    border-color: #198754;
    color: #198754;
    background-color: rgba(25, 135, 84, 0.05);
}

.template-save-btn:hover {
    background-color: #198754;
    border-color: #198754;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.3);
}

.template-delete-btn {
    border-color: #dc3545;
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.05);
}

.template-delete-btn:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* 模板项悬停和激活时显示按钮 */
.template-item:hover .template-actions,
.template-item.active .template-actions {
    opacity: 1;
}

/* 模板容器样式 */
.templates-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.template-properties-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.template-properties-panel .properties-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #dee2e6;
    background: white;
    gap: 10px;
}

.template-properties-panel .properties-header h6 {
    margin: 0;
    flex: 1;
    color: #495057;
}

.template-properties-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

/* 中间画布区样式 */
.center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 8px;
}

.toolbar .btn {
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.toolbar .btn:disabled,
.toolbar .btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.canvas-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* 可视化画布 */
.visual-canvas {
    height: 100%;
    overflow: auto;
    background: #f5f5f5;
    padding: 20px;
}

.canvas-content {
    min-height: calc(100vh - 120px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

/* 可编辑区域样式 */
[data-editp] {
    position: relative;
    min-height: 50px;
    outline: 2px dashed transparent;
    transition: outline 0.2s ease;
}

/* 空的section样式 */
section.container-fluid[data-editp]:empty {
    min-height: 400px;
    position: relative;
    outline: 2px dashed #dee2e6;
    background: #f8f9fa;
}

section.container-fluid[data-editp]:empty::before {
    content: '拖拽组件到这里开始构建页面';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #6c757d;
    font-size: 16px;
    pointer-events: none;
}

[data-editp]:hover {
    outline-color: #0d6efd;
}

[data-editp].drop-target {
    outline-color: #198754;
    background-color: rgba(25, 135, 84, 0.1);
}

[data-editp].selected {
    outline-color: #dc3545;
    outline-style: solid;
}

/* 代码编辑器 */
.code-canvas {
    height: 100%;
}

.code-editor {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    padding: 20px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    background: #1e1e1e;
    color: #d4d4d4;
    resize: none;
}

/* 右侧属性面板 */
.right-panel {
    width: 300px;
    background: #f8f9fa;
    border-left: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.properties-content {
    flex: 1;
    overflow-y: auto;
}

.no-selection {
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-selection i {
    font-size: 48px;
    color: #dee2e6;
}

/* 属性面板操作按钮 */
.property-action-buttons {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.property-action-buttons .btn {
    flex: 1;
    font-size: 12px;
    padding: 8px 12px;
    white-space: nowrap;
}

.property-action-buttons .btn i {
    font-size: 14px;
    margin-right: 4px;
}

/* 属性表单样式 */
.property-form {
    padding: 20px;
}

.property-group {
    margin-bottom: 20px;
}

.property-group h6 {
    color: #495057;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e9ecef;
}

.property-item {
    margin-bottom: 12px;
}

.property-item label {
    display: block;
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 4px;
    font-weight: 500;
}

.property-item input,
.property-item select,
.property-item textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.2s ease;
}

.property-item input:focus,
.property-item select:focus,
.property-item textarea:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

.property-item textarea {
    resize: vertical;
    min-height: 60px;
}

/* 颜色选择器 */
.color-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-preview {
    width: 30px;
    height: 30px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
}

/* 图片上传容器 */
.image-upload-container {
    margin-bottom: 8px;
}

.image-upload-container .btn {
    white-space: nowrap;
    font-size: 12px;
}

.image-upload-container .btn i {
    font-size: 13px;
    margin-right: 4px;
}

.image-upload-container .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 图标选择器样式 */
.icon-selector-item {
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.icon-selector-item:hover {
    border-color: #0d6efd;
    background: #e7f1ff;
    transform: scale(1.1);
}

.icon-selector-item.selected {
    border-color: #198754;
    background: #d1e7dd;
}

.icon-selector-item i {
    color: #6c757d;
    transition: color 0.2s ease;
}

.icon-selector-item:hover i,
.icon-selector-item.selected i {
    color: #212529;
}

/* 可编辑图标样式 */
[data-editp="icon"] {
    cursor: pointer;
    position: relative;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

[data-editp="icon"]:hover {
    background-color: rgba(13, 110, 253, 0.1);
    outline: 2px dashed #0d6efd;
}

[data-editp="icon"].selected {
    outline: 2px solid #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}

/* 拖拽状态 */
.dragging {
    opacity: 0.5;
}

.drag-over {
    background-color: rgba(13, 110, 253, 0.1);
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .left-panel {
        width: 240px;
    }

    .right-panel {
        width: 260px;
    }
}

@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    .left-panel,
    .right-panel {
        width: 100%;
        height: auto;
    }

    .center-panel {
        height: 50vh;
    }
}

/* 动画效果 */
.component-item,
.template-item {
    animation: fadeInUp 0.3s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 可编辑文本样式 */
.editable-text {
    cursor: text;
    padding: 2px 4px;
    border-radius: 2px;
    transition: background-color 0.2s ease;
}

.editable-text:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

.editable-text.editing {
    background-color: #fff;
    outline: 2px solid #0d6efd;
}

/* 可编辑图片样式 */
.editable-img {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.editable-img:hover {
    border-color: rgba(13, 110, 253, 0.3);
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.2);
}

.editable-img.selected {
    border-color: #0d6efd;
    box-shadow: 0 0 12px rgba(13, 110, 253, 0.4);
}

/* 组件高亮边框 */
.component-highlight {
    position: relative;
}

.component-highlight::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid #0d6efd;
    border-radius: 4px;
    pointer-events: none;
}

/* 控制按钮覆盖层 */
.control-buttons-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.control-buttons-overlay .control-btn {
    position: absolute;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    pointer-events: auto;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.control-buttons-overlay .control-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.control-buttons-overlay .control-btn.btn-row-remove {
    background: #dc3545;
}

.control-buttons-overlay .control-btn.btn-row-add {
    background: #198754;
}

.control-buttons-overlay .control-btn.btn-col-remove {
    background: #dc3545;
}

.control-buttons-overlay .control-btn.btn-col-add {
    background: #198754;
}

/* 工具提示 */
.tooltip {
    font-size: 12px;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 模板属性表单样式 - 左侧面板专用 */
.template-properties-form {
    flex: 1;
}

.template-properties-form .form-group {
    margin-bottom: 15px;
}

.template-properties-form .form-label {
    font-weight: 600;
    color: #495057;
    font-size: 13px;
    margin-bottom: 5px;
}

.template-properties-form .form-control {
    font-size: 13px;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.template-properties-form .form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.template-properties-form .form-control[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
}

.template-properties-form .thumbnail-preview {
    display: flex;
    align-items: center;
}

.template-properties-form .thumbnail-preview img {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    object-fit: cover;
}

.template-properties-form .btn {
    font-size: 13px;
    padding: 6px 12px;
}

.template-properties-form .text-muted {
    font-size: 11px;
}

.template-properties-form .alert {
    font-size: 13px;
    padding: 8px 12px;
}

/* 浮动工具栏样式 */
.floating-toolbar {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: #0d6efd;
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 1000;
    white-space: nowrap;
}

.floating-toolbar.show {
    display: flex;
    align-items: center;
    gap: 2px;
}

.floating-toolbar .toolbar-btn {
    background: none;
    border: none;
    color: white;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 32px;
    justify-content: center;
}

.floating-toolbar .toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.floating-toolbar .toolbar-btn i {
    font-size: 14px;
}

.floating-toolbar .element-type {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: white;
    font-weight: 500;
    margin-right: 4px;
    min-width: 50px;
    text-align: center;
}

.floating-toolbar .toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.3);
    margin: 0 4px;
}

/* 选中元素的样式调整 */
.selected {
    position: relative;
    outline: 2px solid #0d6efd !important;
    outline-offset: 2px;
}

.editable-img.img-selected {
    outline: 2px solid #0d6efd !important;
    outline-offset: 2px;
    box-shadow: 0 0 10px rgba(13, 110, 253, 0.3);
}

.editable-img:hover {
    cursor: pointer;
    opacity: 0.8;
}

/* 图片属性面板样式增强 */
.properties-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6 !important;
}

.properties-body {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.form-label.fw-bold {
    color: #495057;
    margin-bottom: 0.25rem;
}

.form-text {
    font-size: 0.75rem;
    color: #6c757d;
}

/* 滑块样式 */
.form-range {
    height: 0.5rem;
}

/* 按钮样式 */
.btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* 输入组样式 */
.input-group-sm .input-group-text {
    font-size: 0.75rem;
}

/* 徽章样式 */
.badge {
    font-size: 0.65rem;
    min-width: 35px;
}