/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-light: #ffffff;
    --bg-gray: #f9fafb;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #1f2937;
        --bg-gray: #111827;
        --border-color: #374151;
        --text-primary: #f9fafb;
        --text-secondary: #9ca3af;
    }
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-gray);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* 工具栏 */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    height: 64px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

.logo i {
    font-size: 24px;
}

.notebook-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

#notebookId {
    width: 100px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-size: 14px;
    text-align: center;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background-color: var(--bg-light);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.btn:hover {
    background-color: #f3f4f6;
}

@media (prefers-color-scheme: dark) {
    .btn:hover {
        background-color: #374151;
    }
}

.btn-small {
    padding: 4px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    border: none;
    background: transparent;
    font-size: 16px;
}

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

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

/* 格式按钮 */
.format-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: var(--bg-gray);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.format-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.format-btn:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

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

.separator {
    width: 1px;
    height: 20px;
    background-color: var(--border-color);
    margin: 0 4px;
}

/* 状态指示器 */
.status-indicator {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 12px;
    color: var(--text-secondary);
}

#saveStatus {
    font-weight: 500;
}

#saveStatus.saving {
    color: var(--warning-color);
}

#saveStatus.saved {
    color: var(--success-color);
}

#saveStatus.error {
    color: var(--danger-color);
}

/* 主编辑区域 */
.editor-container {
    margin-top: 64px;
    height: calc(100vh - 124px);
    position: relative;
    background-color: var(--bg-light);
    overflow: auto;
    padding: 40px;
}

.editor-content {
    min-height: 100%;
    outline: none;
    line-height: 1.6;
    font-size: 16px;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.editor-content:focus {
    outline: none;
}

.editor-content p {
    margin-bottom: 16px;
}

.editor-content h1,
.editor-content h2,
.editor-content h3,
.editor-content h4,
.editor-content h5,
.editor-content h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.editor-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.editor-content a:hover {
    text-decoration: underline;
}

/* 文件卡片 */
.file-card {
    position: absolute;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-light);
    box-shadow: var(--shadow-md);
    cursor: move;
    transition: box-shadow 0.2s, transform 0.1s;
    z-index: 10;
    min-width: 200px;
    max-width: 300px;
    user-select: none;
}

.file-card:hover {
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.file-card.dragging {
    opacity: 0.8;
    transform: scale(1.02);
    z-index: 1000 !important;
}

.file-card.resizing {
    cursor: nwse-resize;
}

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-gray);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: grab;
}

.file-header:active {
    cursor: grabbing;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.file-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.file-size {
    font-size: 11px;
    color: var(--text-secondary);
}

.file-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.file-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.file-action-btn:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.file-preview {
    padding: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden;
}

.file-image {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 4px;
}

.file-audio,
.file-video {
    width: 100%;
    border-radius: 4px;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--primary-color) 50%);
    border-radius: 0 0 var(--radius-md) 0;
}

/* 拖放区域 */
.drop-overlay {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 48px;
    background-color: rgba(59, 130, 246, 0.1);
    border: 2px dashed var(--primary-color);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.drop-overlay.active {
    display: flex;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.2; }
}

.drop-message {
    text-align: center;
    background-color: var(--bg-light);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.drop-message i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.drop-message h3 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.drop-message p {
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.drop-hint {
    font-size: 14px;
    color: var(--primary-color);
    font-weight: 500;
}

/* 上传进度条 */
.upload-progress {
    position: fixed;
    bottom: 60px;
    right: 24px;
    width: 320px;
    background-color: var(--bg-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 1000;
    display: none;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.close-btn:hover {
    background-color: var(--bg-gray);
}

.progress-bar {
    height: 6px;
    background-color: var(--bg-gray);
    margin: 0 16px 8px;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    width: 0%;
    transition: width 0.3s;
    border-radius: 3px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    padding: 0 16px 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* 音频控制栏 */
.audio-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-light);
    border-top: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
}

.audio-info {
    flex: 1;
}

.audio-player {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 2;
}

.audio-btn {
    width: 36px;
    height: 36px;
    border: none;
    background-color: var(--bg-gray);
    color: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.audio-btn:hover {
    background-color: var(--border-color);
}

.audio-progress {
    flex: 1;
}

#audioSeek {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    background-color: var(--bg-gray);
    border-radius: 2px;
    outline: none;
}

#audioSeek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--primary-color);
    cursor: pointer;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        height: auto;
        padding: 12px;
    }
    
    .toolbar-left,
    .toolbar-center,
    .toolbar-right {
        width: 100%;
        justify-content: center;
        margin-bottom: 8px;
    }
    
    .editor-container {
        margin-top: 120px;
        height: calc(100vh - 180px);
        padding: 20px;
    }
    
    .audio-player {
        flex: 1;
    }
}

/* 光标样式 */
.cursor-text { cursor: text; }
.cursor-move { cursor: move; }
.cursor-grab { cursor: grab; }
.cursor-grabbing { cursor: grabbing; }
.cursor-resize { cursor: nwse-resize; }