/* ===== 重置和全局 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --bg: #f9fafb;
    --bg-white: #ffffff;
    --border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ===== 布局 ===== */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-left { display: flex; align-items: center; }
.logo { font-size: 20px; font-weight: 600; }

.header-nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: all 0.2s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary); color: white; }

.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
}

.hidden { display: none !important; }

/* ===== 按钮 ===== */
.btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

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

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

.btn-block { width: 100%; }

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
    background: var(--bg-white);
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input.error {
    border-color: var(--danger);
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

/* ===== 卡片 ===== */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.auth-card {
    max-width: 420px;
    margin: 60px auto;
}
.auth-card h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 24px;
}

/* ===== 笔记列表 ===== */
.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.notes-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.folder-filter {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-white);
    min-width: 150px;
}

.note-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.note-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}

.note-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.note-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.note-card-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.note-card-content {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.note-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.note-folder-tag {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 12px;
    color: var(--text-secondary);
}

/* ===== 笔记编辑器 ===== */
.editor-container {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.editor-title {
    width: 100%;
    border: none;
    font-size: 24px;
    font-weight: 600;
    padding: 0;
    margin-bottom: 16px;
}
.editor-title:focus { outline: none; }

.editor-content {
    width: 100%;
    border: none;
    min-height: 400px;
    font-size: 15px;
    line-height: 1.8;
    resize: vertical;
    padding: 0;
}
.editor-content:focus { outline: none; }

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ===== 文件夹 ===== */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.folder-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}
.folder-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}

.folder-card-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.folder-card-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.folder-card-count {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== 个人中心 ===== */
.profile-section {
    max-width: 600px;
    margin: 0 auto;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    cursor: pointer;
    margin-bottom: 16px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

.profile-info { flex: 1; }

.profile-info h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.profile-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.profile-menu {
    list-style: none;
}

.profile-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.profile-menu-item:hover { color: var(--primary); }

.profile-menu-item:last-child { border-bottom: none; }

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

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

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== 对话框 ===== */
.dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dialog-content {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 400px;
    width: 90%;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.page-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    cursor: pointer;
}
.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 20px;
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

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

/* ===== 验证码输入组 ===== */
.input-with-code {
    display: flex;
    gap: 8px;
}
.input-with-code .form-input { flex: 1; }
.input-with-code .btn { white-space: nowrap; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .header {
        padding: 0 12px;
    }
    .header-nav { gap: 4px; }
    .nav-link { padding: 6px 10px; font-size: 13px; }
    .main-content { padding: 16px; }
    .auth-card { margin: 30px auto; }
    .notes-header { flex-direction: column; gap: 12px; }
    .folder-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .profile-header { flex-direction: column; text-align: center; }
}
