/* ========================================
   ITプロジェクト入門 - コンポーネント
   アカデミックスタイル（数学入門と統一）
   ======================================== */

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

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

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

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

.bookmark-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

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

/* ブックマーク一覧ページ */
.no-bookmarks {
    text-align: center;
    color: #888;
    padding: 3rem 1rem;
    background: #f8f6f1;
    border-radius: 8px;
}

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

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

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

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

.bookmark-link {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: #333;
}

.bookmark-link:hover {
    color: #1a365d;
}

.bookmark-title {
    font-size: 0.95rem;
}

.bookmark-date {
    font-size: 0.8rem;
    color: #888;
}

.bookmark-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 0.5rem;
    margin-left: 0.5rem;
}

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

.bookmark-actions,
.review-actions {
    margin-top: 2rem;
    text-align: center;
}

.clear-all-btn {
    background: #dc2626;
    color: #fff;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.clear-all-btn:hover {
    background: #b91c1c;
}

/* ========================================
   学習履歴ウィジェット
   ======================================== */

.review-tracker-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 260px;
    background: #fff;
    border: 1px solid #d4c5a9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    font-size: 0.85rem;
}

.review-tracker-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f8f6f1;
    border-bottom: 1px solid #d4c5a9;
    border-radius: 8px 8px 0 0;
}

.review-tracker-icon {
    font-size: 1.1rem;
}

.review-tracker-title {
    flex: 1;
    font-weight: bold;
    color: #1a365d;
}

.review-tracker-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    padding: 0;
}

.review-tracker-body {
    padding: 1rem;
}

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

.review-tracker-chapter {
    font-weight: bold;
    color: #1a365d;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.review-tracker-stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #666;
}

.stat-value {
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-left: 0.5rem;
}

.status-badge.overdue { background: #fecaca; color: #dc2626; }
.status-badge.today { background: #fef3c7; color: #d97706; }
.status-badge.soon { background: #dbeafe; color: #2563eb; }
.status-badge.ok { background: #dcfce7; color: #16a34a; }
.status-badge.not-started { background: #f3f4f6; color: #6b7280; }

.review-tracker-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
}

.review-tracker-link {
    color: #1a365d;
    text-decoration: none;
    font-size: 0.8rem;
}

.review-tracker-link:hover {
    text-decoration: underline;
}

.review-tracker-clear {
    background: none;
    border: 1px solid #ddd;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #666;
}

.review-tracker-clear:hover {
    background: #f5f5f5;
}

/* ========================================
   学習履歴一覧ページ
   ======================================== */

.status-legend {
    background: #f8f6f1;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 2rem;
    font-size: 0.85rem;
    line-height: 2;
}

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

.review-chapter-group h3 {
    font-size: 1rem;
    color: #1a365d;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #d4c5a9;
}

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

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

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

.review-history-card.overdue { border-left: 4px solid #dc2626; }
.review-history-card.today { border-left: 4px solid #d97706; }
.review-history-card.soon { border-left: 4px solid #2563eb; }
.review-history-card.ok { border-left: 4px solid #16a34a; }
.review-history-card.not-started { border-left: 4px solid #9ca3af; opacity: 0.7; }

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

.card-title {
    display: block;
    font-weight: bold;
    color: #1a365d;
    text-decoration: none;
    margin-bottom: 0.75rem;
}

.card-title:hover {
    text-decoration: underline;
}

.card-stats {
    font-size: 0.8rem;
}

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

.card-clear {
    background: none;
    border: 1px solid #ddd;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    color: #666;
    margin-top: 0.5rem;
}

.card-clear:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ========================================
   章横断検索機能
   ======================================== */

.search-container {
    position: relative;
    padding: 0.5rem 0 1rem 0;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d4c5a9;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
    color: #333;
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: #1a365d;
    box-shadow: 0 0 0 2px rgba(26, 54, 93, 0.15);
}

.search-box input::placeholder {
    color: #999;
}

/* 検索結果ドロップダウン */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d4c5a9;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    transition: background 0.15s;
}

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

.search-result-item:hover,
.search-result-item.selected {
    background: #f8f6f1;
}

.search-result-title {
    font-weight: bold;
    color: #1a365d;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.search-result-title mark {
    background: #fef3c7;
    color: #1a365d;
    padding: 0 0.15rem;
    border-radius: 2px;
}

.search-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.search-result-chapter {
    color: #666;
}

.search-result-keywords {
    color: #888;
    font-style: italic;
}

.search-result-keywords::before {
    content: '— ';
}

.search-no-results {
    padding: 1.5rem 1rem;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

/* 検索結果スクロールバー */
.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ========================================
   音声プレイヤー
   ======================================== */

.audio-player {
    background: #f8f6f1;
    border: 1px solid #d4c5a9;
    border-radius: 6px;
    padding: 1rem 1.2rem;
    margin: 1.5rem 0;
}

.audio-player-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.audio-player-header span {
    font-size: 1.2rem;
}

.audio-player-label {
    font-size: 0.95rem;
    color: #333;
    margin: 0;
    font-weight: 500;
}

.audio-player audio {
    width: 100%;
    margin-bottom: 0.8rem;
}

.audio-speed-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #666;
}

.audio-speed-btn {
    padding: 0.3rem 0.7rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.audio-speed-btn:hover {
    background: #f0f0f0;
}

.audio-speed-btn.active {
    background: #1a365d;
    color: #fff;
    border-color: #1a365d;
}

/* ========================================
   PlantUML図
   ======================================== */

.diagram-container,
.uml-wrap {
    margin: 2rem 0;
    text-align: center;
}

.diagram-container img,
.uml-wrap img {
    max-width: 100%;
    height: auto;
    border: 1px solid #d4c5a9;
    border-radius: 4px;
    background: #fff;
}

.diagram-caption {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* ========================================
   レスポンシブ
   ======================================== */

@media (max-width: 900px) {
    .review-tracker-widget {
        width: 200px;
        bottom: 10px;
        right: 10px;
        font-size: 0.8rem;
    }
    
    .review-history-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .search-results-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 60vh;
        border-radius: 12px 12px 0 0;
    }
    
    .audio-speed-controls {
        flex-wrap: wrap;
    }
    
    .audio-speed-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* ========================================
   UML図ポップアップ
   ======================================== */

.uml-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.uml-popup-overlay.active {
    display: flex;
}

.uml-popup-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.uml-popup-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    background: #1a365d;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.uml-popup-close:hover {
    background: #2c5282;
}

.uml-popup-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
}

/* UML画像ホバー効果 */
.uml-wrap .uml-img,
.diagram-container img {
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s;
}

.uml-wrap .uml-img:hover,
.diagram-container img:hover {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 印刷時は非表示 */
@media print {
    .review-tracker-widget,
    .audio-player,
    .uml-popup-overlay {
        display: none !important;
    }
}
