/* MindStorm - 创意便利贴样式 */

:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --accent: #f093fb;
    --success: #4ECDC4;
    --warning: #FFD700;
    --danger: #FF6B6B;
    --dark: #2C3E50;
    --light: #ECF0F1;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    min-height: 100vh;
    color: var(--dark);
    overflow-x: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶部工具栏 */
.toolbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 2rem;
    color: var(--secondary);
}

.search-bar {
    flex: 1;
    max-width: 400px;
    margin: 0 30px;
    position: relative;
}

.search-bar i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.search-bar input {
    width: 100%;
    padding: 12px 45px;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    font-size: 16px;
    background: rgba(255, 255, 255, 0.8);
    transition: var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tools {
    display: flex;
    gap: 10px;
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: white;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #e55a5a;
    transform: translateY(-2px);
}

/* 拖拽覆盖层 - 覆盖整个画板区域，允许无限拖拽 */
.drag-overlay {
    position: absolute;
    top: 80px; /* 工具栏高度 */
    left: 0;
    width: 100vw;
    height: calc(100vh - 80px);
    z-index: 10; /* 在网格背景之上，便利贴之下 */
    pointer-events: auto;
    cursor: default;
}

/* 可移动的画板容器 */
.canvas-container {
    position: relative;
    flex: 1;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
    /* 容器需要足够大以覆盖所有可能的拖拽区域 */
    width: 100vw;
    height: calc(100vh - 80px);
    overflow: visible; /* 允许内容超出容器边界 */
}

/* 主画板区域 */
.canvas {
    position: absolute;
    top: 0;
    left: 0;
    /* 无限画布，不使用overflow */
    overflow: visible;
    /* 画布大小会通过JavaScript动态设置 */
    /* 添加一些内边距，让便利贴不会贴边 */
    padding: 100px;
}

/* 无限网格背景 */
.grid-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 50000px;
    height: 50000px;
    pointer-events: auto; /* 允许接收鼠标事件 */
    z-index: -1;
    /* 思维导图风格的无限网格背景 */
    background-image:
        /* 主要网格线 - 较粗 */
        linear-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.15) 1px, transparent 1px),
        /* 次要网格线 - 较细 */
        linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
        /* 最小网格线 - 最细 */
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 200px 200px, 200px 200px, 50px 50px, 50px 50px, 10px 10px, 10px 10px;
    background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
}

.canvas::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.canvas::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.canvas::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.canvas::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 便利贴样式 */
.note {
    position: absolute;
    background: var(--warning);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    cursor: move;
    user-select: none;
    transition: var(--transition);
    min-width: 200px;
    min-height: 150px;
    max-width: 400px;
    max-height: 500px;
    overflow: hidden;
    z-index: 100;
}

.note:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.note.dragging {
    opacity: 0.8;
    transform: rotate(5deg);
    z-index: 1000;
}

.note.selected {
    box-shadow: 0 0 0 3px var(--primary);
}

.note-header {
    padding: 12px 15px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.note-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--dark);
    flex: 1;
    margin-right: 10px;
}

.note-actions {
    display: flex;
    gap: 8px;
    opacity: 0.7;
}

.note:hover .note-actions {
    opacity: 1;
}

.note-action {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--dark);
    transition: var(--transition);
}

.note-action:hover {
    background: rgba(0, 0, 0, 0.1);
}

.note-content {
    padding: 15px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--dark);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    max-height: 300px;
}

.note-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nw-resize;
    background: linear-gradient(-45deg, transparent 0%, transparent 40%, rgba(0, 0, 0, 0.2) 40%, rgba(0, 0, 0, 0.2) 60%, transparent 60%);
}

.note-resize-handle:hover {
    background: linear-gradient(-45deg, transparent 0%, transparent 40%, rgba(0, 0, 0, 0.3) 40%, rgba(0, 0, 0, 0.3) 60%, transparent 60%);
}

/* 不同颜色主题的便利贴 */
.note[data-color="#FF6B6B"] { background: linear-gradient(135deg, #FF6B6B, #FF8E8E); }
.note[data-color="#4ECDC4"] { background: linear-gradient(135deg, #4ECDC4, #7EDDD8); }
.note[data-color="#45B7D1"] { background: linear-gradient(135deg, #45B7D1, #6DCFF6); }
.note[data-color="#96CEB4"] { background: linear-gradient(135deg, #96CEB4, #B8E6C9); }
.note[data-color="#FFEAA7"] { background: linear-gradient(135deg, #FFEAA7, #FFF3C4); }
.note[data-color="#DDA0DD"] { background: linear-gradient(135deg, #DDA0DD, #E6B8E6); }
.note[data-color="#98D8C8"] { background: linear-gradient(135deg, #98D8C8, #B8E6D8); }

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translate(-50%, -60%); opacity: 0; }
    to { transform: translate(-50%, -50%); opacity: 1; }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--dark);
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-btn:hover {
    background: #f0f0f0;
    color: var(--dark);
}

.modal-body {
    padding: 25px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

/* 颜色选择器 */
.color-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
}

.color-option:hover,
.color-option.selected {
    border-color: var(--dark);
    transform: scale(1.1);
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 右键菜单 */
.context-menu {
    display: none;
    position: absolute;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 1500;
    min-width: 150px;
    overflow: hidden;
}

.context-item {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    color: var(--dark);
}

.context-item:hover {
    background: #f8f9fa;
}

.context-item i {
    width: 16px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .search-bar {
        margin: 0;
        max-width: none;
    }

    .tools {
        width: 100%;
        justify-content: center;
    }

    .btn {
        flex: 1;
        justify-content: center;
    }

    .canvas {
        min-height: calc(100vh - 200px);
    }

    .modal-content {
        width: 95%;
        margin: 20px auto;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .note {
        min-width: 150px;
        min-height: 120px;
    }

    .note-title {
        font-size: 14px;
    }

    .note-content {
        font-size: 13px;
        padding: 10px;
    }

    .color-picker {
        gap: 8px;
    }

    .color-option {
        width: 35px;
        height: 35px;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 空状态 */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 1.1rem;
}
