/* === 全体レイアウト === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'メイリオ', sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

.header {
    background: linear-gradient(135deg, #1a5276, #2980b9);
    color: #fff;
    padding: 24px 32px;
    text-align: center;
}

.header h1 {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.header .subtitle {
    font-size: 0.95rem;
    opacity: 0.85;
}

.header-links {
    margin-top: 10px;
    text-align: right;
}
.header-link {
    color: #fff;
    background: rgba(255,255,255,0.15);
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    margin-left: 8px;
}
.header-link:hover {
    background: rgba(255,255,255,0.28);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* === 検索フォーム === */
.search-section {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    flex: 1;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.form-group select,
.form-group input {
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

.btn-group {
    flex-direction: row;
    gap: 8px;
    min-width: auto;
}

button {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

#searchBtn {
    background: #2980b9;
    color: #fff;
}

#searchBtn:hover {
    background: #1a6da0;
}

.btn-secondary {
    background: #95a5a6;
    color: #fff;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-pdf {
    background: #e74c3c;
    color: #fff;
}

.btn-pdf:hover {
    background: #c0392b;
}

/* === 検索結果テーブル === */
.result-section {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.result-section h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: #1a5276;
}

.result-section h2 span {
    font-size: 0.9rem;
    color: #666;
    font-weight: normal;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.result-table th {
    background: #2c3e50;
    color: #fff;
    padding: 10px 8px;
    text-align: left;
    white-space: nowrap;
}

.result-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e0e0e0;
}

.result-table tr:hover {
    background: #eaf2f8;
}

.result-table .btn-detail {
    background: #27ae60;
    color: #fff;
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 4px;
    white-space: nowrap;
}

.result-table .btn-detail:hover {
    background: #1e8449;
}

/* === シラバス詳細表示 === */
.detail-section {
    margin-bottom: 20px;
}

.detail-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.syllabus-detail {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* シラバス書式テーブル */
.syllabus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    margin-bottom: 20px;
}

.syllabus-table th,
.syllabus-table td {
    border: 1px solid #333;
    padding: 6px 8px;
    vertical-align: top;
}

.syllabus-table th {
    background: #d6eaf8;
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
    width: 120px;
}

.syllabus-table .section-header {
    background: #2c3e50;
    color: #fff;
    text-align: center;
    font-size: 0.95rem;
    padding: 8px;
}

.syllabus-table .sub-header {
    background: #eaf2f8;
    font-weight: 600;
    text-align: center;
}

.syllabus-table .goal-check,
.syllabus-table .eval-check {
    text-align: center;
    width: 30px;
}

.syllabus-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 20px;
    color: #1a5276;
}

/* === レスポンシブ === */
@media (max-width: 768px) {
    .header {
        padding: 16px;
    }
    .header h1 {
        font-size: 1.3rem;
    }
    .container {
        padding: 10px;
    }
    .search-section {
        padding: 16px;
    }
    .search-form {
        flex-direction: column;
        gap: 10px;
    }
    .form-group {
        min-width: 100%;
    }
    .form-group select,
    .form-group input {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .btn-group {
        flex-direction: row;
        justify-content: center;
    }

    /* 検索結果：テーブルをカード形式に */
    .result-section {
        padding: 12px;
    }
    .result-table thead {
        display: none;
    }
    .result-table,
    .result-table tbody,
    .result-table tr,
    .result-table td {
        display: block;
        width: 100%;
    }
    .result-table tr {
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }
    .result-table tr:hover {
        background: #f8fbfe;
    }
    .result-table td {
        padding: 3px 8px;
        border-bottom: none;
        text-align: left;
        font-size: 0.85rem;
    }
    .result-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #1a5276;
        margin-right: 8px;
        display: inline-block;
        min-width: 5em;
    }
    .result-table td:last-child {
        padding-top: 8px;
        text-align: right;
    }
    .result-table td:last-child::before {
        display: none;
    }
    .result-table .btn-detail {
        width: 100%;
        padding: 10px;
        font-size: 0.9rem;
    }

    /* 詳細表示 */
    .detail-actions {
        flex-wrap: wrap;
    }
    .detail-actions button {
        flex: 1;
        min-width: 120px;
        font-size: 0.85rem;
        padding: 10px 12px;
    }
    .syllabus-detail {
        padding: 10px;
    }
    .syllabus-table {
        font-size: 0.78rem;
    }
    .syllabus-table th {
        width: 80px;
        font-size: 0.75rem;
        padding: 4px;
    }
    .syllabus-table td {
        padding: 4px;
        word-break: break-word;
    }
    .syllabus-title {
        font-size: 1.1rem;
    }
}

/* === ローディング === */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #ccc;
    border-top-color: #2980b9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === PDF出力用ページブレーク制御 === */
.syllabus-table {
    page-break-inside: auto;
}

.syllabus-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
}

.syllabus-table .section-header {
    page-break-after: avoid;
}

/* PDF生成中の追加スタイル */
.pdf-rendering .syllabus-table {
    font-size: 0.82rem;
}

.pdf-rendering .syllabus-title {
    page-break-after: avoid;
}

/* === 印刷用スタイル === */
@media print {
    .header, .search-section, .result-section, .detail-actions {
        display: none !important;
    }
    .detail-section {
        display: block !important;
    }
    .syllabus-detail {
        box-shadow: none;
        padding: 0;
    }
    body {
        background: #fff;
    }
    .syllabus-table {
        page-break-inside: auto;
    }
    .syllabus-table tr {
        page-break-inside: avoid;
    }
    .syllabus-table .section-header {
        page-break-after: avoid;
    }
}
