/* AI便签 全局样式 */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
    --transition: all .2s ease;
}

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

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

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

/* 容器 */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 480px; margin: 0 auto; padding: 0 20px; }

/* 导航栏 */
.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,.9);
}
.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.navbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar-brand span { font-size: 24px; }
.navbar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    list-style: none;
}
.navbar-nav a {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 8px;
    transition: var(--transition);
}
.navbar-nav a:hover, .navbar-nav a.active {
    color: var(--primary);
    background: rgba(99,102,241,.08);
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: rgba(0,0,0,.04); color: var(--text); }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text);
    background: var(--card-bg);
    transition: var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { appearance: auto; }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* 卡片 */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-body { padding: 20px; }
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 便签卡片 */
.note-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}
.note-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.note-card .note-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    pointer-events: none;
}
.note-card .note-content-wrap { position: relative; z-index: 1; }
.note-card .note-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.note-card .note-text {
    font-size: 14px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}
.note-card .note-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}
.note-card .note-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.note-card .note-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(99,102,241,.1);
    color: var(--primary);
}
.note-card .note-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: var(--transition);
    z-index: 2;
}
.note-card:hover .note-actions { opacity: 1; }
.note-card .note-actions .btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.9);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}
.note-card .note-actions .btn-icon:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.note-card .pinned-badge {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--warning);
    color: #fff;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 0 0 8px 0;
    z-index: 2;
}

/* 便签网格 */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 20px 0;
}

/* 搜索栏 */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.search-bar .form-control { flex: 1; min-width: 200px; }

/* 颜色选择器 */
.color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}
.color-option:hover, .color-option.active {
    border-color: var(--primary);
    transform: scale(1.15);
}

/* 标签 */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    background: rgba(99,102,241,.1);
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
}
.tag:hover { background: rgba(99,102,241,.2); }
.tag.active { background: var(--primary); color: #fff; }
.tag .tag-remove {
    font-size: 14px;
    cursor: pointer;
    margin-left: 2px;
}

/* 弹窗/模态框 */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    transition: var(--transition);
}
.modal-close:hover { background: rgba(0,0,0,.05); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 侧边栏 */
.sidebar {
    width: 240px;
    min-height: calc(100vh - 60px);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    position: fixed;
    left: 0;
    top: 60px;
    overflow-y: auto;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition);
}
.sidebar-nav li a:hover, .sidebar-nav li a.active {
    color: var(--primary);
    background: rgba(99,102,241,.06);
    border-right: 3px solid var(--primary);
}
.main-content {
    margin-left: 240px;
    padding: 24px;
    min-height: calc(100vh - 60px);
}

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
}
table tr:hover { background: #f8fafc; }

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 20px 0;
}
.page-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
    transition: var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 提示/消息 */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: rgba(34,197,94,.1); color: #16a34a; border: 1px solid rgba(34,197,94,.2); }
.alert-danger { background: rgba(239,68,68,.1); color: #dc2626; border: 1px solid rgba(239,68,68,.2); }
.alert-warning { background: rgba(245,158,11,.1); color: #d97706; border: 1px solid rgba(245,158,11,.2); }
.alert-info { background: rgba(59,130,246,.1); color: #2563eb; border: 1px solid rgba(59,130,246,.2); }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    font-size: 14px;
    animation: slideIn .3s ease;
    min-width: 200px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; margin-bottom: 20px; }

/* VIP徽章 */
.vip-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
}

/* AI聊天面板 */
.ai-chat-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--card-bg);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0,0,0,.1);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right .3s ease;
}
.ai-chat-panel.active { right: 0; }
.ai-chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.ai-message {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
}
.ai-message.user { justify-content: flex-end; }
.ai-message .bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}
.ai-message.user .bubble {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-message.assistant .bubble {
    background: #f1f5f9;
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.ai-chat-input {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}
.ai-chat-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    outline: none;
    font-size: 14px;
}
.ai-chat-input input:focus { border-color: var(--primary); }

/* 个人中心 */
.profile-card {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 24px;
}
.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
}
.profile-info h2 { font-size: 20px; margin-bottom: 4px; }
.profile-info p { color: var(--text-secondary); font-size: 14px; }

/* 管理后台布局 */
.admin-layout .sidebar {
    background: #1e293b;
    border-right: none;
}
.admin-layout .sidebar-nav li a {
    color: #94a3b8;
}
.admin-layout .sidebar-nav li a:hover,
.admin-layout .sidebar-nav li a.active {
    color: #fff;
    background: rgba(255,255,255,.08);
    border-right-color: var(--primary);
}
.admin-stat-card {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--card-bg);
    border: 1px solid var(--border);
}
.admin-stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.admin-stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.admin-grid-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.admin-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* 响应式 */
@media (max-width: 768px) {
    .navbar-nav { display: none; }
    .sidebar {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 200;
        box-shadow: 4px 0 20px rgba(0,0,0,.15);
    }
    .sidebar.show { display: block; }
    /* 侧边栏遮罩 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,.3);
        z-index: 199;
    }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; padding: 16px; }
    .notes-grid { grid-template-columns: 1fr; }
    .search-bar { flex-direction: column; }
    .modal { width: 95%; max-height: 90vh; }
    .ai-chat-panel { width: 100%; right: -100%; }
    .profile-card { flex-direction: column; text-align: center; }
    .container { padding: 0 12px; }
    .btn { padding: 8px 16px; }
    table { font-size: 13px; }
    table th, table td { padding: 8px 10px; }
    .admin-stat-card .stat-value { font-size: 22px; }
    /* 后台两列布局移动端变单列 */
    .admin-grid-2col { grid-template-columns: 1fr; }
    .admin-grid-stats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    /* 移动端菜单按钮 */
    .mobile-menu-btn { display: block !important; }
    /* 移动端菜单展开 */
    .navbar-nav.show {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        padding: 12px 20px;
        gap: 4px;
        z-index: 150;
        animation: fadeIn .2s ease;
    }
    .navbar-nav.show li { width: 100%; }
    .navbar-nav.show a {
        display: block;
        padding: 10px 16px;
        border-radius: 8px;
    }
    /* 登录/注册卡片移动端适配 */
    .login-card, .register-card { padding: 32px 24px; }
    /* VIP套餐移动端单列 */
    .vip-plans { grid-template-columns: 1fr; }
}
.mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text); }

/* 中等屏幕响应式 */
@media (max-width: 1024px) and (min-width: 769px) {
    .notes-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* 动画 */
.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.slide-up { animation: slideUp .3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* 工具类 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.w-full { width: 100%; }
