/* ==========================================
   知识锦囊 (Knowledge Capsule) - 专属页面样式
   ========================================== */

html, body {
    overflow-y: auto !important; /* 覆盖全局的 overflow: hidden，允许知识锦囊页面垂直滚动 */
    overflow-x: hidden;
    height: auto;
    min-height: 100%;
}

.notes-main {
    max-width: 1200px;
    margin: 80px auto 40px;
    padding: 0 20px;
    position: relative;
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: flex-start;
    gap: 40px;
}

.notes-sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 100px;
}

.notes-content-area {
    flex: 1;
    min-width: 0;
}

@media (max-width: 900px) {
    .notes-main {
        flex-direction: column;
        gap: 20px;
    }
    .notes-sidebar {
        width: 100%;
        position: static;
    }
}

/* 控制栏 */
.notes-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.mode-switch {
    display: flex;
    gap: 8px;
    background: rgba(10, 20, 40, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 4px;
}

.mode-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 9px;
    background: transparent;
    border: none;
    color: #8892b0;
    font-size: 0.85rem;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mode-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.04);
}

.mode-btn.active {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.25);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.08);
}

/* 学科筛选标签 */
.subject-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 7px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #8892b0;
    font-size: 0.78rem;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}

.filter-chip:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

.filter-chip.active {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.35);
    color: #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.1);
}

/* 统计 */
.notes-stats {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
    padding: 0 4px;
}

.stat-item {
    color: #8892b0;
    font-size: 0.8rem;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
}

.stat-item span {
    color: #ffd700;
    font-weight: 700;
    font-family: 'Orbitron', monospace;
}

/* ==========================================
   笔记列表
   ========================================== */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.note-card {
    background: rgba(10, 20, 40, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 3px solid var(--note-color, #8892b0);
    border-radius: 12px;
    padding: 18px 20px;
    transition: all 0.3s ease;
    position: relative;
}

.note-card:hover {
    background: rgba(10, 20, 40, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.note-subject-tag {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    font-weight: 500;
}

.note-date {
    color: #556177;
    font-size: 0.72rem;
    font-family: 'Orbitron', monospace;
}

.note-question {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.note-q-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.note-q-text {
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.6;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    word-break: break-word;
    white-space: pre-wrap;
}

.note-answer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 215, 0, 0.04);
    border: 1px solid rgba(255, 215, 0, 0.1);
    cursor: pointer;
    transition: all 0.25s;
    margin-bottom: 4px;
}

.note-answer-toggle:hover {
    background: rgba(255, 215, 0, 0.08);
    border-color: rgba(255, 215, 0, 0.2);
}

.toggle-icon { font-size: 0.9rem; }

.toggle-text {
    flex: 1;
    color: #ffd700;
    font-size: 0.8rem;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
}

.toggle-arrow {
    color: #ffd700;
    font-size: 0.65rem;
    transition: transform 0.3s;
}

.note-answer {
    padding: 14px 16px;
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    border-left: 2px solid rgba(255, 215, 0, 0.2);
}

.note-a-text {
    color: #b4c6ef;
    font-size: 0.88rem;
    line-height: 1.7;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    word-break: break-word;
    white-space: pre-wrap;
}

.note-actions {
    position: relative;
    /* top/right not needed anymore as it's flexed */
}

.note-delete-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: #556177;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    transition: all 0.2s;
}

.note-delete-btn:hover {
    background: rgba(255, 62, 62, 0.1);
    border-color: rgba(255, 62, 62, 0.3);
    color: #ff3e3e;
}

/* 空状态 */
.notes-empty, .flashcard-empty {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-title {
    color: #8892b0;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    margin-bottom: 8px;
}

.empty-desc {
    color: #556177;
    font-size: 0.85rem;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    line-height: 1.6;
}

/* ==========================================
   翻卡复习
   ========================================== */
.flashcard-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding-top: 10px;
}

.flashcard-progress {
    font-family: 'Orbitron', monospace;
    color: #ffd700;
    font-size: 0.9rem;
    letter-spacing: 2px;
}

.flashcard-container {
    perspective: 1000px;
    width: 100%;
    max-width: 600px;
    height: 350px;
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow-y: auto;
}

.flashcard-front {
    background: linear-gradient(135deg, rgba(10, 20, 40, 0.9) 0%, rgba(15, 25, 50, 0.9) 100%);
    border: 1px solid rgba(255, 215, 0, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.05);
}

.flashcard-back {
    background: linear-gradient(135deg, rgba(10, 25, 20, 0.92) 0%, rgba(8, 20, 35, 0.92) 100%);
    border: 1px solid rgba(0, 255, 170, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 255, 170, 0.05);
    transform: rotateY(180deg);
}

.flashcard-label {
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.flashcard-front .flashcard-label {
    color: #ffd700;
}

.flashcard-back .flashcard-label {
    color: #00ffaa;
}

.flashcard-content {
    flex: 1;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    color: #e2e8f0;
    word-break: break-word;
    white-space: pre-wrap;
}

.flashcard-hint {
    text-align: center;
    color: #556177;
    font-size: 0.75rem;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    margin-top: 12px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.flashcard-nav {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ==========================================
   新增笔记悬浮按钮
   ========================================== */
.notes-add-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 170, 0, 0.15) 100%);
    border: 1.5px solid rgba(255, 215, 0, 0.4);
    color: #ffd700;
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.15), 0 4px 15px rgba(0,0,0,0.4);
    transition: all 0.3s;
}

.notes-add-fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

/* 新增弹窗 */
.notes-add-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notes-add-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
}

.notes-add-panel {
    position: relative;
    width: 90%;
    max-width: 480px;
    background: linear-gradient(180deg, rgba(8, 14, 30, 0.97) 0%, rgba(4, 8, 20, 0.98) 100%);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 215, 0, 0.05);
    overflow: hidden;
}

.notes-add-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffd700;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
}

.notes-add-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 70vh;
    overflow-y: auto;
}

.add-subject-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.add-subject-chip {
    padding: 8px 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #8892b0;
    cursor: pointer;
    text-align: center;
    font-size: 0.78rem;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    transition: all 0.25s;
    user-select: none;
}

.add-subject-chip:hover {
    background: rgba(255, 255, 255, 0.06);
}

.add-subject-chip.selected {
    border-color: var(--chip-color, #ffd700);
    background: color-mix(in srgb, var(--chip-color, #ffd700) 10%, transparent);
    color: var(--chip-color, #ffd700);
    box-shadow: 0 0 10px color-mix(in srgb, var(--chip-color, #ffd700) 15%, transparent);
}

/* ==========================================
   知识锦囊表单通用样式 (Form Styles)
   ========================================== */
.kc-field-label {
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    color: #8892b0;
    font-size: 0.78rem;
    font-weight: 500;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.kc-textarea {
    width: 100%;
    min-height: 100px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 14px 16px;
    color: #e2e8f0;
    font-size: 0.9rem;
    font-family: 'Noto Sans SC', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.3s, box-shadow 0.3s;
    outline: none;
    box-sizing: border-box;
}

.kc-textarea:focus {
    border-color: rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.08), inset 0 0 10px rgba(255, 215, 0, 0.03);
}

.kc-textarea::placeholder {
    color: rgba(136, 146, 176, 0.5);
}

.kc-save-btn {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 170, 0, 0.1) 100%);
    border: 1px solid rgba(255, 215, 0, 0.35);
    color: #ffd700;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Noto Sans SC', system-ui, sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.kc-save-btn:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.25) 0%, rgba(255, 170, 0, 0.18) 100%);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
    transform: translateY(-1px);
}

.kc-save-btn:active {
    transform: translateY(0);
}

.kc-save-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================
   响应式
   ========================================== */
@media (max-width: 600px) {
    .notes-main {
        margin-top: 70px;
        padding: 0 12px;
    }

    .flashcard-container {
        height: 280px;
    }

    .flashcard-front, .flashcard-back {
        padding: 20px;
    }

    .subject-filter {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .subject-filter::-webkit-scrollbar {
        display: none;
    }

    .mode-switch {
        flex-shrink: 0;
    }
}
