/**
 * UI组件样式 - UI Components Styles
 * 版本：1.0.0
 * 用于新增UI组件的样式
 */

/* ==================== 学习进度仪表板 ==================== */

.progress-dashboard {
    position: sticky;
    top: 80px;
    margin: 2rem 0;
    padding: 2rem;
    z-index: 100;
    animation: slideDown 0.5s ease-out;
}

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

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

.dashboard-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.overall-progress {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(103, 58, 183, 0.05);
    border-radius: 12px;
}

.progress-circle {
    width: 120px;
    height: 120px;
}

.progress-circle svg {
    transform: rotate(-90deg);
}

.progress-circle .progress-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.progress-circle .progress-fill {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-circle .progress-text {
    transform: rotate(90deg);
    transform-origin: center;
    font-size: 1.5rem;
    font-weight: 700;
    fill: var(--primary-color);
}

.progress-stats {
    display: flex;
    gap: 2rem;
    flex: 1;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.category-progress {
    display: grid;
    gap: 1rem;
}

.progress-item {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.progress-bar-container {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.achievements {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.achievements h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.achievement-badge {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--gradient-success);
    color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    animation: achievementPop 0.5s ease-out;
}

@keyframes achievementPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.achievement-badge i {
    font-size: 2rem;
}

.achievement-info strong {
    display: block;
    font-size: 1.1rem;
}

.achievement-info small {
    opacity: 0.9;
}

/* 章节完成标记 */

.section-header-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.section-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.completed {
    opacity: 0.7;
    position: relative;
}

.completed::after {
    content: '✓ 已完成';
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--success-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.confetti-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    animation: confetti 1s ease-out;
    pointer-events: none;
    z-index: 1000;
}

@keyframes confetti {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 0;
    }
}

/* ==================== 书签面板 ==================== */

.bookmark-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.bookmark-panel.active {
    right: 0;
}

.bookmark-toggle {
    position: relative;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
}

.bookmark-toggle:hover {
    background: rgba(103, 58, 183, 0.1);
}

.bookmark-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

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

.panel-header h3 {
    margin: 0;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
}

.close-btn:hover {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger-color);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.bookmark-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    transition: all 0.3s;
}

.bookmark-item:hover {
    transform: translateX(-4px);
    box-shadow: var(--shadow-md);
}

.bookmark-info {
    flex: 1;
    min-width: 0;
}

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

.bookmark-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.bookmark-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.bookmark-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

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

.panel-footer {
    padding: 1rem;
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* 书签按钮 */

.bookmark-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
    margin-left: auto;
}

.bookmark-btn:hover {
    background: rgba(103, 58, 183, 0.1);
    color: var(--primary-color);
}

.bookmark-btn.bookmarked {
    color: var(--warning-color);
}

/* ==================== 笔记系统 ==================== */

.note-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
}

.note-btn:hover {
    background: rgba(255, 193, 7, 0.1);
    color: var(--warning-color);
}

.note-btn.has-note {
    color: var(--warning-color);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

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

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

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.note-editor textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    background: var(--bg-color);
    color: var(--text-color);
}

.note-editor textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.note-meta {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.note-meta small {
    color: var(--text-muted);
}

.modal-footer {
    padding: 1.5rem;
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ==================== 滚动进度指示器 ==================== */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: var(--gradient-primary);
    z-index: 9999;
    transition: width 0.1s linear;
}

/* ==================== 高亮目标 ==================== */

.highlight-target {
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0%, 100% {
        background: transparent;
    }
    50% {
        background: rgba(103, 58, 183, 0.2);
    }
}

/* ==================== 通知消息 ==================== */

.notification {
    position: fixed;
    top: 80px;
    right: -300px;
    width: 300px;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 10000;
    transition: right 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

.notification.show {
    right: 20px;
}

.notification i {
    font-size: 1.5rem;
}

.notification-success {
    border-left-color: var(--success-color);
}

.notification-success i {
    color: var(--success-color);
}

.notification-warning {
    border-left-color: var(--warning-color);
}

.notification-warning i {
    color: var(--warning-color);
}

.notification-info {
    border-left-color: var(--info-color);
}

.notification-info i {
    color: var(--info-color);
}

/* ==================== 主题菜单 ==================== */

.theme-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1000;
}

.theme-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-option {
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    text-align: left;
}

.theme-option:hover {
    background: var(--primary-color);
    color: white;
}

/* ==================== 响应式设计 ==================== */

@media (max-width: 768px) {
    .progress-dashboard {
        position: relative;
        top: 0;
    }

    .overall-progress {
        flex-direction: column;
        gap: 1rem;
    }

    .progress-stats {
        width: 100%;
    }

    .achievements-grid {
        grid-template-columns: 1fr;
    }

    .bookmark-panel {
        width: 100%;
        right: -100%;
    }

    .bookmark-panel.active {
        right: 0;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .notification {
        width: calc(100% - 40px);
        right: -100%;
    }

    .notification.show {
        right: 20px;
    }
}

/* ==================== 打印样式 ==================== */

@media print {
    .progress-dashboard,
    .bookmark-panel,
    .bookmark-btn,
    .note-btn,
    .section-checkbox,
    .scroll-progress,
    .notification {
        display: none !important;
    }
}

/* ==================== 深色模式 ==================== */

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .bookmark-panel,
[data-theme="dark"] .modal-content {
    background: rgba(30, 30, 30, 0.95);
}

[data-theme="dark"] .note-editor textarea {
    background: rgba(50, 50, 50, 0.8);
}
