/* ============================================
   components.css - 公共组件样式
   ============================================ */

/* === 按钮 === */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:active { box-shadow: var(--shadow-md); }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary-light);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

/* === 表单 === */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--card-bg);
    transition: border-color 0.2s;
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
}
.form-group textarea {
    resize: vertical;
    min-height: 80px;
}
.form-row {
    display: flex;
    gap: 12px;
}
.form-group.half {
    flex: 1;
}

/* === 弹窗 === */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1000;
}
.modal.active {
    display: block;
}
.modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.2s;
}
.modal-content {
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--content-max);
    background: var(--card-bg);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close {
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { transform: translate(-50%, 100%); }
    to { transform: translate(-50%, 0); }
}

/* === 页面顶部栏 === */
.page-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-back {
    font-size: 22px;
    color: var(--text-primary);
    width: 32px;
    cursor: pointer;
}
.topbar-title {
    font-size: 18px;
    font-weight: 700;
}
.topbar-add {
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* === 分页 === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 16px 0 24px;
}
.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination button.active {
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
}

/* === 开关 === */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
}
.switch input { display: none; }
.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #E0E0E0;
    border-radius: 30px;
    transition: 0.3s;
}
.switch-slider::before {
    content: '';
    position: absolute;
    height: 24px; width: 24px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-slider {
    background: var(--gradient-primary);
}
.switch input:checked + .switch-slider::before {
    transform: translateX(22px);
}

/* === 状态标签 === */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.tag-mastered {
    background: var(--success-light);
    color: #2A9D8F;
}
.tag-unmastered {
    background: var(--primary-bg);
    color: var(--primary);
}
.tag-difficulty-1 { background: #E8F5E9; color: #4CAF50; }
.tag-difficulty-2 { background: #FFF3E0; color: #FF9800; }
.tag-difficulty-3 { background: #FFEBEE; color: #F44336; }
