/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

:root {
    --primary: #4a6fa5;
    --primary-light: #6d8cc3;
    --primary-dark: #3a5680;
    --primary-transparent: rgba(74, 111, 165, 0.1);
    --secondary: #f8f9fa;
    --text: #333333;
    --text-light: #666666;
    --text-lighter: #888888;
    --border: #e0e0e0;
    --border-light: #f0f0f0;
    --shadow: rgba(0, 0, 0, 0.05);
    --shadow-md: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --danger: #e74c3c;
    --danger-light: #fadbd8;
    --success: #2ecc71;
    --success-light: #d5f4e6;
    --warning: #f39c12;
    --warning-light: #fdebd0;
    --bg: #ffffff;
    --bg-secondary: #f5f7fa;
    --modal-overlay: rgba(0, 0, 0, 0.5);
}

body {
    background-color: var(--secondary);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部 */
header {
    background: var(--bg);
    padding: 1.2rem 2rem;
    box-shadow: 0 2px 15px var(--shadow);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-icon {
    font-size: 1.8rem;
    color: var(--primary);
}

.app-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.app-title p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* 按钮样式 */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

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

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

.btn-danger:hover {
    background-color: #c0392b;
}

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

.btn-success:hover {
    background-color: #27ae60;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 主容器 */
.container {
    display: flex;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    height: calc(100vh - 85px);
}

/* 侧边栏 - 笔记列表 */
.sidebar {
    width: 320px;
    background-color: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.2rem;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    color: var(--text);
}

.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    background-color: var(--secondary);
    transition: border-color 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-transparent);
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-lighter);
}

.notes-stats {
    font-size: 0.85rem;
    color: var(--text-light);
    text-align: right;
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.note-item {
    padding: 1.2rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background-color: var(--bg);
}

.note-item:hover {
    background-color: var(--secondary);
    border-color: var(--border);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--shadow);
}

.note-item.active {
    background-color: var(--primary-transparent);
    border-color: var(--primary);
}

.note-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-preview {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.8rem;
}

.note-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-lighter);
}

.note-date {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.empty-notes {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-lighter);
}

.empty-notes i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-notes p {
    font-size: 1rem;
}

/* 主编辑区 */
.editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    overflow: hidden;
}

.editor-header {
    padding: 1.2rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.editor-title {
    flex: 1;
    position: relative;
}

.note-title-input {
    border: none;
    font-size: 1.5rem;
    font-weight: 600;
    width: 100%;
    color: var(--text);
    background-color: transparent;
    padding: 0.2rem 0;
    padding-right: 4rem;
}

.note-title-input:focus {
    outline: none;
}

.note-title-input::placeholder {
    color: var(--text-lighter);
}

.char-count {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--text-light);
    background-color: var(--bg);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
}

.editor-controls {
    display: flex;
    gap: 0.8rem;
    flex-shrink: 0;
}

.editor-content {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    position: relative;
}

.note-content {
    flex: 1;
    width: 100%;
    border: none;
    font-size: 1rem;
    line-height: 1.7;
    resize: none;
    color: var(--text);
    background-color: transparent;
    font-family: inherit;
    padding: 0;
    margin-bottom: 2rem;
}

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

.note-content::placeholder {
    color: var(--text-lighter);
}

.content-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-light);
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--modal-overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--bg);
    border-radius: 8px;
    box-shadow: 0 10px 40px var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background-color: var(--secondary);
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.modal-tab {
    padding: 0.8rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 1rem;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-tab:hover {
    color: var(--text);
}

.modal-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.modal-body p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

.modal-body textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 1.5rem;
    background-color: var(--secondary);
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-transparent);
}

.file-upload {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

#fileName {
    font-size: 0.9rem;
    color: var(--text-light);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* 提示消息 */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px var(--shadow-lg);
    max-width: 350px;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.toast-success {
    background-color: var(--success);
}

.toast-error {
    background-color: var(--danger);
}

.toast-warning {
    background-color: var(--warning);
}

.toast-info {
    background-color: var(--primary);
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 40%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .notes-list {
        max-height: 300px;
    }
    
    .editor-header {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .editor-title {
        order: 1;
    }
    
    .editor-controls {
        order: 2;
        justify-content: flex-end;
    }
    
    .editor-content {
        padding: 1rem;
    }
    
    header {
        padding: 1rem;
    }
    
    .modal-content {
        max-width: 100%;
        max-height: 90vh;
    }
}

@media (max-width: 768px) {
    .header-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .btn {
        width: 100%;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-header {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .app-title h1 {
        font-size: 1.2rem;
    }
    
    .modal-tabs {
        flex-direction: column;
    }
    
    .modal-tab {
        text-align: left;
        border-bottom: 1px solid var(--border);
        border-left: 2px solid transparent;
    }
    
    .modal-tab.active {
        border-left-color: var(--primary);
        border-bottom-color: var(--border);
    }
}
