/* コンポーネント - ボックス、テーブル、コード、その他 */

/* 小さいテキスト */
.small {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
}

.small,
ol {
    margin-left: 0;
    margin-bottom: 1.2rem;
    padding-left: 0;
    list-style: none;
}

li {
    margin-bottom: 0.5rem;
    text-indent: 1em;
}

/* 導入文（Abstract） */
.lead {
    background-color: transparent;
    padding: 1rem 2rem;
    margin-bottom: 3rem;
    border: none;
    font-size: 0.95rem;
    font-style: italic;
    text-align: justify;
    width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.lead::before {
    content: "Abstract: ";
    font-weight: bold;
    font-style: normal;
}

/* ノートボックス */
.note {
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 1.5rem 0;
    text-indent: 1em;
}

.note::before {
    content: "[Note] ";
    font-weight: bold;
}

.note::after {
    content: none;
}

/* タイムラインボックス */
.timeline-box {
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 1.5rem 0;
    text-indent: 1em;
}

/* 実践的なボックス */
.practical-box {
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 1.5rem 0;
    text-indent: 1em;
}

/* テーブル（Academic Style） */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
}

th,
td {
    border: none;
    padding: 0.5rem 1rem;
    text-align: left;
    vertical-align: top;
}

th {
    background-color: transparent;
    font-weight: bold;
    border-bottom: 1px solid #000;
}

td {
    border-bottom: 1px solid #ccc;
}

tr:last-child td {
    border-bottom: none;
}

/* コードブロック */
pre {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

code {
    background-color: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
}

pre code {
    background: none;
    padding: 0;
}

/* シンタックスハイライト */
.keyword {
    color: #0066cc;
}

.string {
    color: #d14;
}

.comment {
    color: #998;
    font-style: italic;
}

/* 参考・免責文 */
.refs {
    background-color: transparent;
    border-top: 1px solid #000;
    padding: 1rem 0;
    margin-top: 4rem;
    font-size: 0.9rem;
}

/* UML図表用 */
.uml-wrap {
    margin: 2rem 0;
    text-align: center;
}

.uml-wrap img {
    max-width: 100%;
    height: auto;
}

/* 広告コンテナ */
.ad-container {
    margin: 1.5rem 0;
    text-align: center;
}

/* チャプター画像（挿絵） */
.chapter-image {
    text-align: center;
    margin: 2rem 0;
}

.chapter-image img {
    max-width: 100%;
    height: auto;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.chapter-image .image-caption {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.5rem;
    text-indent: 0;
}

/* ===========================================
   ブックマーク機能
   =========================================== */

.bookmark-btn {
    background: none;
    border: none;
    font-size: 1.2em;
    color: #999;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.bookmark-btn:hover {
    color: #f4a623;
    transform: scale(1.2);
}

.bookmark-btn.bookmarked {
    color: #f4a623;
}

/* トースト通知 */
.bookmark-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    background: #333;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
}

.bookmark-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ブックマーク一覧ページ */
.bookmark-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ccc;
}

.bookmark-page-header h1 {
    margin: 0;
}

.bookmark-clear-btn {
    background: none;
    border: 1px solid #ccc;
    color: #666;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.bookmark-clear-btn:hover {
    background: #f5f5f5;
    color: #c00;
    border-color: #c00;
}

.no-bookmarks {
    text-align: center;
    color: #666;
    padding: 3rem;
    line-height: 2;
}

.bookmark-group {
    margin-bottom: 2rem;
}

.bookmark-chapter {
    font-size: 1rem;
    color: #333;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #ddd;
}

.bookmark-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.bookmark-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
    text-indent: 0;
}

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

.bookmark-link {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: #111;
    padding: 0.25rem 0;
    border-bottom: none;
}

.bookmark-link:hover {
    color: #0066cc;
}

.bookmark-title {
    font-weight: 500;
}

.bookmark-date {
    font-size: 0.85em;
    color: #666;
}

.bookmark-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1.2em;
    line-height: 1;
    margin-left: 1rem;
    transition: color 0.2s;
}

.bookmark-remove:hover {
    color: #c00;
}

@media (max-width: 768px) {
    .bookmark-page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .bookmark-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* ===========================================
   学習反復履歴（Review Tracker）
   =========================================== */

/* ウィジェット（右下フローティング） */
.review-tracker-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 200px;
    background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 102, 204, 0.3);
    font-size: 13px;
    z-index: 9999;
    overflow: hidden;
    transition: all 0.3s ease;
}

.review-tracker-widget.collapsed {
    width: 130px;
}

.review-tracker-widget.collapsed .review-tracker-body {
    display: none;
}

.review-tracker-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    user-select: none;
}

.review-tracker-icon {
    font-size: 14px;
}

.review-tracker-title {
    flex: 1;
    font-weight: 600;
    font-size: 12px;
}

.review-tracker-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.review-tracker-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.review-tracker-body {
    padding: 12px;
    background: #fff;
    border-radius: 0 0 8px 8px;
}

.review-tracker-chapter {
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.review-tracker-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 12px;
}

.review-tracker-stat .stat-label {
    color: #666;
}

.review-tracker-stat .stat-value {
    color: #111;
    font-weight: 500;
}

.review-tracker-stat.next-review .stat-value {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.status-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.status-badge.overdue,
.next-review.overdue .status-badge {
    background: rgba(220, 53, 69, 0.15);
    color: #c00;
}

.status-badge.today,
.next-review.today .status-badge {
    background: rgba(255, 193, 7, 0.2);
    color: #997a00;
}

.status-badge.soon,
.next-review.soon .status-badge {
    background: rgba(0, 123, 255, 0.15);
    color: #0066cc;
}

.status-badge.ok,
.next-review.ok .status-badge {
    background: rgba(40, 167, 69, 0.15);
    color: #28a745;
}

.status-badge.not-started {
    background: rgba(108, 117, 125, 0.15);
    color: #6c757d;
}

.review-tracker-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.review-tracker-link {
    flex: 1;
    padding: 6px 8px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-size: 11px;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

.review-tracker-link:hover {
    background: #fff;
    color: #0066cc;
    border-color: #0066cc;
}

.review-tracker-clear {
    padding: 6px 8px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #666;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.review-tracker-clear:hover {
    background: rgba(220, 53, 69, 0.1);
    border-color: #c00;
    color: #c00;
}

/* 履歴一覧ページ */
.review-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ccc;
}

.review-history-header h1 {
    margin: 0;
}

.review-history-clear-btn {
    background: none;
    border: 1px solid #ccc;
    color: #666;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.review-history-clear-btn:hover {
    background: rgba(220, 53, 69, 0.1);
    border-color: #c00;
    color: #c00;
}

.review-chapter-group {
    margin-bottom: 2rem;
}

.review-chapter-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #0066cc;
}

.review-history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.review-history-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    transition: box-shadow 0.2s;
}

.review-history-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.review-history-card.overdue {
    border-left: 3px solid #c00;
}

.review-history-card.today {
    border-left: 3px solid #ffc107;
}

.review-history-card.soon {
    border-left: 3px solid #0066cc;
}

.review-history-card.ok {
    border-left: 3px solid #28a745;
}

.review-history-card.not-started {
    border-left: 3px solid #6c757d;
    opacity: 0.7;
}

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

.card-chapter {
    font-size: 0.85em;
    color: #666;
}

.card-status {
    font-size: 0.75em;
}

.card-title {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: #111;
    text-decoration: none;
    margin-bottom: 0.75rem;
    border-bottom: none;
}

.card-title:hover {
    color: #0066cc;
}

.card-stats {
    font-size: 0.85em;
}

.card-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
}

.card-stat .stat-label {
    color: #666;
}

.card-stat .stat-value {
    color: #111;
}

.not-started-text {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 1rem 0;
    margin: 0;
    text-indent: 0;
}

.card-clear {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #666;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s;
}

.card-clear:hover {
    background: rgba(220, 53, 69, 0.1);
    border-color: #c00;
    color: #c00;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .review-tracker-widget {
        bottom: 10px;
        right: 10px;
        width: 180px;
    }
    
    .review-tracker-widget.collapsed {
        width: 110px;
    }
    
    .review-history-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .review-history-grid {
        grid-template-columns: 1fr;
    }
}

/* 印刷時は非表示 */
@media print {
    .review-tracker-widget,
    .bookmark-btn {
        display: none !important;
    }
}
