/*
 * Research Papers Manager — フロントエンドスタイル v1.3.0
 *
 * ショートコード: [rpm_papers per_page="10" layout="table" order="desc"]
 *
 * 主なクラス:
 *   .rpm-front-wrap          全体ラッパー（data-layout="table"|"card"）
 *   .rpm-search-form         検索フォーム
 *   .rpm-papers-table        テーブル（PC デフォルト）
 *   .rpm-cards-wrap          カードグリッド（モバイル常時・PC切替可）
 *   .rpm-doi-btn             DOI ピルボタン（テーブル・カード共通）
 *   .rpm-pagination          ページナビ
 */

/* ============================================================
   全体ラッパー
============================================================ */
.rpm-front-wrap {
    margin: 0 0 2.5em;
    font-size: 1rem;
    line-height: 1.6;
}

/* ============================================================
   検索フォーム
============================================================ */
.rpm-search-form {
    margin-bottom: 1.5em;
    padding: 1em 1.2em;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.rpm-search-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8em 1.2em;
    align-items: flex-end;
}

.rpm-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
}

.rpm-filter-group label {
    display: block;
    font-size: 0.8em;
    font-weight: 700;
    color: #495057;
    letter-spacing: 0.02em;
    line-height: 1.4;
    margin: 0;
    padding: 0;
}

.rpm-filter-group select,
.rpm-filter-group input[type="text"] {
    display: block;
    padding: 0 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9em;
    background-color: #fff;
    color: #212529;
    height: 36px;
    line-height: 36px;
    box-sizing: border-box;
    min-width: 140px;
    margin: 0;
    vertical-align: middle;
}

.rpm-filter-group select:focus,
.rpm-filter-group input[type="text"]:focus {
    outline: 2px solid #3e6a9e;
    outline-offset: 1px;
    border-color: #3e6a9e;
}

.rpm-btn-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-self: flex-end;
    gap: 8px;
    height: 36px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.rpm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    height: 36px;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s;
}

.rpm-btn-search {
    background-color: #3e6a9e;
    color: #fff;
    border-color: #3e6a9e;
}
.rpm-btn-search:hover,
.rpm-btn-search:focus {
    background-color: #2d5288;
    border-color: #2d5288;
    color: #fff;
}

.rpm-btn-reset {
    background-color: #fff;
    color: #6c757d;
    border-color: #ced4da;
}
.rpm-btn-reset:hover,
.rpm-btn-reset:focus {
    background-color: #f1f3f5;
    color: #495057;
}

/* ============================================================
   件数・レイアウト切替バー
============================================================ */
.rpm-result-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8em;
    gap: 8px;
}
.rpm-result-count { font-size: 0.88em; color: #6c757d; }

.rpm-layout-switch { display: flex; gap: 4px; }
.rpm-layout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    color: #6c757d;
    text-decoration: none;
    transition: all 0.15s;
}
.rpm-layout-btn:hover { background-color: #e9ecef; color: #495057; }
.rpm-layout-btn.is-active { background-color: #3e6a9e; border-color: #3e6a9e; color: #fff; }

/* ============================================================
   表示切替（data-layout 属性で制御）
   モバイルは @media で上書き
============================================================ */
.rpm-front-wrap[data-layout="table"] .rpm-cards-wrap { display: none; }
.rpm-front-wrap[data-layout="card"]  .rpm-table-wrap  { display: none; }

/* ============================================================
   DOI ピルボタン（テーブル・カード共通）
============================================================ */
.rpm-doi-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 9px;
    background-color: #3e6a9e;
    color: #fff !important;
    border-radius: 3px;
    font-size: 0.78em;
    font-weight: 700;
    text-decoration: none !important;
    white-space: nowrap;
    letter-spacing: 0.05em;
    transition: background-color 0.15s;
    vertical-align: middle;
}
.rpm-doi-btn:hover { background-color: #2d5288; }

/* ============================================================
   テーブルレイアウト（PC 向け）
============================================================ */
.rpm-table-wrap {
    overflow-x: auto;
    margin-bottom: 1.5em;
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
    border: 1px solid #d4dce8;
    box-shadow: 0 1px 5px rgba(62,106,158,0.08);
}

.rpm-papers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    min-width: 720px;
}

/* ヘッダー */
.rpm-papers-table thead tr {
    background: #3e6a9e;
    color: #fff;
}
.rpm-papers-table th {
    padding: 12px 14px;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
    border: none;
    border-right: 1px solid rgba(255,255,255,0.18);
    font-size: 0.86em;
    letter-spacing: 0.03em;
}
.rpm-papers-table th:last-child { border-right: none; }

/* セル */
.rpm-papers-table td {
    padding: 11px 14px;
    border: none;
    border-bottom: 1px solid #e8ecf1;
    vertical-align: top;
    color: #252c38;
    line-height: 1.68;
}
.rpm-papers-table tbody tr:last-child td { border-bottom: none; }

/* 縞模様 */
.rpm-papers-table tbody tr:nth-child(even) { background-color: #f5f8fc; }

/* ホバー: 行ハイライト＋左アクセント */
.rpm-papers-table tbody tr { transition: background-color 0.1s; }
.rpm-papers-table tbody tr:hover { background-color: #eaf0f8; }
.rpm-papers-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 #3e6a9e;
}

/* 列幅と個別スタイル */
.rpm-th-nendo, .rpm-td-nendo {
    width: 72px;
    text-align: center;
    white-space: nowrap;
    font-weight: 700;
    color: #3e6a9e;
}
.rpm-th-cat,    .rpm-td-cat    { width: 95px; }
.rpm-th-shiken, .rpm-td-shiken { width: 120px; }
.rpm-th-ronbun, .rpm-td-ronbun { /* 自動（最大幅を取る） */ font-weight: 500; }
.rpm-th-zasshi, .rpm-td-zasshi { width: 140px; }
.rpm-th-doi,    .rpm-td-doi    { width: 58px; text-align: center; vertical-align: middle; }
.rpm-th-author, .rpm-td-author { width: 95px; }

/* リンク */
.rpm-papers-table a { color: #3e6a9e; text-decoration: none; word-break: break-word; }
.rpm-papers-table a:hover { text-decoration: underline; }

/* ============================================================
   カードレイアウト
============================================================ */
.rpm-cards-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.2em;
    margin-bottom: 1.5em;
}

.rpm-card {
    padding: 1.1em 1.3em;
    background: #fff;
    border: 1px solid #d4dce8;
    border-radius: 8px;
    border-top: 3px solid #3e6a9e;
    box-shadow: 0 1px 4px rgba(62,106,158,0.07);
    transition: box-shadow 0.2s, transform 0.15s;
}
.rpm-card:hover {
    box-shadow: 0 4px 14px rgba(62,106,158,0.14);
    transform: translateY(-1px);
}

.rpm-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.7em;
}
.rpm-card-cat {
    display: inline-block;
    padding: 2px 10px;
    background-color: #3e6a9e;
    color: #fff;
    border-radius: 3px;
    font-size: 0.76em;
    font-weight: 700;
}
.rpm-card-nendo {
    font-size: 0.78em;
    color: #6c757d;
    margin-left: auto;
    white-space: nowrap;
    font-weight: 600;
}

.rpm-card-title {
    font-size: 0.93em;
    font-weight: 700;
    margin: 0 0 0.8em;
    line-height: 1.55;
    color: #1a2030;
}

.rpm-card-dl {
    margin: 0;
    font-size: 0.84em;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 5px 12px;
    align-items: baseline;
}
.rpm-card-dl dt {
    font-weight: 700;
    color: #5a6478;
    white-space: nowrap;
}
.rpm-card-dl dd {
    margin: 0;
    color: #343a40;
    word-break: break-word;
}
.rpm-card-dl a {
    color: #3e6a9e;
    text-decoration: none;
    word-break: break-all;
}
.rpm-card-dl a:hover { text-decoration: underline; }

/* ============================================================
   ページナビゲーション
============================================================ */
.rpm-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin: 2em 0 1em;
}
.rpm-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-decoration: none;
    color: #3e6a9e;
    font-size: 0.9em;
    font-weight: 500;
    background-color: #fff;
    transition: all 0.15s;
    box-sizing: border-box;
}
.rpm-page-btn:hover {
    background-color: #eaf0f8;
    border-color: #3e6a9e;
    color: #3e6a9e;
}
.rpm-page-btn.rpm-page-current {
    background-color: #3e6a9e;
    border-color: #3e6a9e;
    color: #fff;
    cursor: default;
    pointer-events: none;
}
.rpm-page-ellipsis {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 4px;
    color: #6c757d;
    font-size: 0.9em;
}
.rpm-page-prev, .rpm-page-next { padding: 0 14px; }

/* ============================================================
   レスポンシブ（〜767px）
   モバイルは常にカード表示・テーブル非表示
============================================================ */
@media (max-width: 767px) {

    /* フォーム縦積み */
    .rpm-search-inner  { flex-direction: column; align-items: stretch; }
    .rpm-filter-group  { width: 100%; }
    .rpm-filter-group select,
    .rpm-filter-group input[type="text"] { width: 100%; min-width: unset; }
    .rpm-btn-group     { flex-direction: row; align-items: center; height: auto; align-self: auto; }
    .rpm-btn           { flex: 1; }
    .rpm-result-bar    { flex-wrap: wrap; }

    /* テーブル非表示・カード強制表示 */
    .rpm-table-wrap    { display: none !important; }
    .rpm-cards-wrap    { display: grid !important; grid-template-columns: 1fr !important; }

    /* レイアウト切替ボタン不要 */
    .rpm-layout-switch { display: none; }

    /* カード全幅 */
    .rpm-card { border-radius: 8px; }

    /* ページネーション */
    .rpm-pagination    { gap: 3px; }
    .rpm-page-btn      { min-width: 32px; height: 32px; font-size: 0.85em; }
}
