/* assets/css/bbs.css - 掲示板用スタイル */

/* ========================================================================
   ページ背景は base.css の var(--bg) を使用（統一）
   ======================================================================== */

/* ========================================================================
   掲示板共通ラッパー（白背景カード）
   ======================================================================== */
.bbs-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ========================================================================
   掲示板ヘッダー
   ======================================================================== */
.bbs-header {
    margin-bottom: 24px;
    position: relative;
}

/* PCモード：新規スレッド作成ボタンを右上に配置 */
@media (min-width: 769px) {
    .bbs-header .btn-primary {
        position: absolute;
        top: 0;
        right: 0;
    }
}

.bbs-header h2 {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.bbs-description {
    color: var(--text-light);
    font-size: 14px;
}

/* ========================================================================
   ログイン案内
   ======================================================================== */
.bbs-login-notice {
    background: linear-gradient(135deg, #fef9c3 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
    text-align: center;
}

[data-theme="dark"] .bbs-login-notice {
    background: linear-gradient(135deg, #422006 0%, #78350f 100%);
    border-color: #92400e;
}

.bbs-login-notice a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

/* ========================================================================
   新規スレッド作成フォーム（グレー背景アイテム）
   ======================================================================== */
.bbs-new-thread {
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.bbs-new-thread h3 {
    font-size: 30px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.bbs-new-thread .form-group {
    margin-bottom: 16px;
}

.bbs-new-thread label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-light);
}

.bbs-new-thread input[type="text"],
.bbs-new-thread textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 20px;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.bbs-new-thread input[type="text"]:focus,
.bbs-new-thread textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.bbs-new-thread textarea {
    resize: vertical;
    min-height: 100px;
}

/* ========================================================================
   並び替えオプション（グレー背景）
   ======================================================================== */
.bbs-sort-options {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.bbs-sort-options>span {
    color: var(--text-light);
    font-weight: 500;
}

.sort-link {
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-light);
    transition: background-color 0.2s, color 0.2s;
}

.sort-link:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.sort-link.active {
    background: #6b7280;
    color: white;
    font-weight: 600;
}

[data-theme="dark"] .sort-link.active {
    background: #4b5563;
}

/* 一覧を見るボタン（右寄せ・目立つ色） */
.btn-view-all {
    margin-left: auto;
    padding: 6px 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white !important;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn-view-all:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .btn-view-all {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}


/* ========================================================================
   参加中のスレッドセクション
   ======================================================================== */
.bbs-my-threads {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px dashed var(--border);
}

.bbs-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.bbs-section-header h3 {
    margin-bottom: 0;
}

.my-thread-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mysort-toggle {
    display: flex;
    gap: 4px;
}

.mysort-btn {
    padding: 4px 10px;
    font-size: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
}

.mysort-btn:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.mysort-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-small {
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
    background: var(--card-bg);
    border: 1px solid var(--primary);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--primary);
    color: white;
}

/* ========================================================================
   スレッド一覧
   ======================================================================== */
.bbs-thread-list h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.thread-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.thread-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: background-color 0.2s, transform 0.1s;
}

.thread-item:hover {
    background: var(--hover-bg);
    transform: translateX(2px);
}

/* 固定スレッド */
.thread-item.thread-pinned {
    background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
    border-color: #facc15;
    position: relative;
}

[data-theme="dark"] .thread-item.thread-pinned {
    background: linear-gradient(135deg, #422006 0%, #713f12 100%);
    border-color: #a16207;
}

.thread-item.thread-pinned:hover {
    background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
}

[data-theme="dark"] .thread-item.thread-pinned:hover {
    background: linear-gradient(135deg, #713f12 0%, #854d0e 100%);
}

.thread-pinned-icon {
    margin-right: 6px;
    font-size: 14px;
}

/* 固定ボタン（管理者用） */
.btn-pin-thread {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s, transform 0.1s;
    flex-shrink: 0;
    margin-left: 12px;
}

.btn-pin-thread:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
}

.thread-info {
    flex: 1;
    min-width: 0;
}

.thread-title {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thread-title:hover {
    color: var(--primary);
}

.thread-meta {
    font-size: 12px;
    color: var(--text-light);
}

.thread-meta span {
    margin-right: 8px;
}

.thread-stats {
    text-align: center;
    min-width: 40px;
}

.post-count {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.post-label {
    font-size: 11px;
    color: var(--text-light);
}

/* クリッカブルスレッドリンク */
.thread-item-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.thread-item-link:hover .thread-item {
    background: var(--hover-bg);
    transform: translateX(2px);
}

.thread-item-link .thread-title {
    color: var(--text);
}

.thread-item-link:hover .thread-title {
    color: var(--primary);
}

/* ========================================================================
   参加ボタン
   ======================================================================== */
.btn-subscribe {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    border: 2px solid #dc2626;
    background: transparent;
    color: #dc2626;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: auto;
}

.btn-subscribe:hover {
    background: #dc2626;
    color: white;
}

.btn-subscribe.subscribed {
    background: #16a34a;
    border-color: #16a34a;
    color: white;
}

.btn-subscribe.subscribed:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* テキスト付き参加ボタン（個別スレッドページ用） */
.btn-subscribe.btn-subscribe-text {
    width: auto;
    height: auto;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 5px;
    gap: 4px;
}

/* ========================================================================
   ページネーション
   ======================================================================== */
.bbs-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding: 16px 0;
}

.btn-page {
    padding: 8px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-page:hover {
    background: var(--hover-bg);
}

.page-info {
    font-size: 14px;
    color: var(--text-light);
}

/* ========================================================================
   スレッド詳細ヘッダー
   ======================================================================== */
.thread-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.back-link:hover {
    text-decoration: underline;
}

.thread-title-heading {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.thread-header-meta {
    font-size: 14px;
    color: var(--text-light);
}

.thread-header-meta span {
    margin-right: 16px;
}

.thread-locked {
    color: #dc2626;
    font-weight: 600;
}

/* ========================================================================
   スレッドヘッダーとアクションボタン
   ======================================================================== */
.thread-header {
    position: relative;
}

.thread-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
}

/* PC時は右上に絶対配置 */
@media (min-width: 769px) {
    .thread-actions {
        position: absolute;
        top: 0;
        right: 0;
        margin-top: 0;
    }
}

/* ボタンの高さを揃える */
.thread-actions .btn-subscribe,
.thread-actions .btn-delete-thread {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
}

/* ========================================================================
   スレッド評価セクション
   ======================================================================== */
.thread-rating {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.rating-label {
    font-size: 14px;
    color: var(--text-light);
}

/* ========================================================================
   返信フォーム（グレー背景）
   ======================================================================== */
.bbs-reply-form {
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.bbs-reply-form h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.bbs-reply-form textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 20px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    resize: vertical;
    min-height: 100px;
    margin-bottom: 12px;
}

.bbs-reply-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.bbs-reply-form .btn-primary {
    display: block;
    margin-left: auto;
}

/* ========================================================================
   投稿一覧（5ch風・グレー背景アイテム）
   ======================================================================== */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.post-item {
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
}

/* 投稿アイテム横並びラッパー */
.post-item-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

/* 左側アイコン */
.post-icon {
    flex-shrink: 0;
}

.post-icon a {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 3px;
    overflow: hidden;
    text-decoration: none;
    transition: transform 0.2s;
}

.post-icon a:hover {
    transform: scale(1.1);
}

.post-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-icon-default {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

[data-theme="dark"] .post-icon-default {
    background: linear-gradient(135deg, #3730a3 0%, #4338ca 100%);
}

/* 右側メインコンテンツ */
.post-main {
    flex: 1;
    min-width: 0;
}

/* 名前リンク */
.post-author-link {
    color: #16a34a;
    font-weight: 600;
    font-size: 18px;
    text-decoration: none;
    transition: color 0.2s;
}

.post-author-link:hover {
    color: #15803d;
    text-decoration: underline;
}

.post-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 3px;
    font-size: 18px;
}

.post-number {
    font-weight: 700;
    font-size: 20px;
    color: var(--primary);
}

.post-author {
    color: #16a34a;
    font-weight: 600;
    font-size: 18px;
}

.post-user-number {
    color: var(--text-light);
    font-weight: 400;
    font-size: 14px;
    margin-left: 2px;
}

.post-date {
    color: var(--text-light);
    font-size: 18px;
}

.post-ip {
    color: #9ca3af;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.post-ip-clickable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.post-ip-clickable:hover {
    color: var(--primary);
}

/* 削除ボタン */
.btn-delete-post {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.btn-delete-post:hover {
    opacity: 1;
}

/* 投稿本文 */
.post-content {
    font-size: 20px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    padding: 3px 0;
    margin-left: 1em;
}

/* 投稿フッター（投票ボタン） */
.post-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

/* ========================================================================
   投票ボタン
   ======================================================================== */
.thread-votes {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.vote-good,
.vote-bad {
    font-size: 14px;
    color: var(--text-light);
}

.vote-good {
    color: #16a34a;
}

.vote-bad {
    color: #dc2626;
}

.btn-vote {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text);
    transition: all 0.2s;
}

.btn-vote-good {
    border-color: #16a34a;
    color: #16a34a;
}

.btn-vote-good:hover {
    background: #16a34a;
    color: white;
}

.btn-vote-bad {
    border-color: #dc2626;
    color: #dc2626;
}

.btn-vote-bad:hover {
    background: #dc2626;
    color: white;
}

/* ========================================================================
   スレッド終了通知
   ======================================================================== */
.bbs-thread-closed {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid #f87171;
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 24px;
    margin-bottom: 16px;
    text-align: center;
    color: #991b1b;
}

[data-theme="dark"] .bbs-thread-closed {
    background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
    border-color: #b91c1c;
    color: #fecaca;
}

/* ========================================================================
   空状態
   ======================================================================== */
.bbs-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

/* ========================================================================
   ボタン
   ======================================================================== */
.btn-primary {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ========================================================================
   スレッド削除ボタン
   ======================================================================== */
.btn-delete-thread {
    margin-left: auto;
    padding: 6px 12px;
    background: #fee2e2;
    border: 1px solid #f87171;
    border-radius: 6px;
    color: #dc2626;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-thread:hover {
    background: #dc2626;
    color: white;
}

[data-theme="dark"] .btn-delete-thread {
    background: #450a0a;
    border-color: #b91c1c;
}

[data-theme="dark"] .btn-delete-thread:hover {
    background: #b91c1c;
}

/* ========================================================================
   スレッド統計ラップ
   ======================================================================== */
.thread-stats-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.thread-locked-icon {
    margin-left: 6px;
}

/* ========================================================================
   レスポンシブ
   ======================================================================== */
@media (max-width: 768px) {
    .bbs-wrapper {
        padding: 12px;
        margin-top: 16px;
        border-radius: 8px;
    }

    .bbs-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .bbs-header h2 {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .bbs-description {
        font-size: 12px;
    }

    .bbs-header .btn-primary {
        width: 100%;
        text-align: center;
        padding: 10px 16px;
        font-size: 16px;
    }

    .thread-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 12px;
    }

    .thread-info {
        width: 100%;
    }

    .thread-title {
        font-size: 16px;
        white-space: normal;
        overflow: visible;
    }

    .thread-meta {
        font-size: 12px;
    }

    .thread-votes {
        display: inline-flex;
        margin-top: 4px;
    }

    /* 参加スレッドセクションのモバイル対応 */
    .bbs-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* モバイル時：「並び替え:」ラベルを非表示 */
    .bbs-sort-options > span {
        display: none;
    }

    /* モバイル時：参加中スレッドの並び替えオプションのみ薄いブルー背景 */
    .bbs-sort-options.mysort-options {
        background: rgba(59, 130, 246, 0.08);
        padding: 8px 12px;
        border-radius: 8px;
        justify-content: center;
    }

    /* モバイル時：スレッド一覧の並び替えオプションもセンター揃え */
    .bbs-sort-options {
        justify-content: center;
    }

    .my-thread-controls {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 4px;
    }

    .mysort-toggle {
        display: flex;
        gap: 4px;
    }

    .mysort-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .my-thread-controls .btn-small {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* モバイル時：スレッドアイテムをさらにコンパクトに */
    .thread-item {
        padding: 8px 10px;
    }

    .thread-title {
        font-size: 14px;
        margin-bottom: 1px;
    }

    .thread-meta {
        font-size: 11px;
    }

    .thread-meta span {
        margin-right: 6px;
    }

    .thread-list {
        gap: 3px;
    }

    .bbs-thread-list h3 {
        font-size: 16px;
        margin-bottom: 6px;
    }

    .thread-stats-wrap {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    .thread-stats {
        text-align: left;
        min-width: auto;
    }

    .post-count {
        font-size: 14px;
        display: inline;
    }

    .post-label {
        display: inline;
        margin-left: 4px;
    }

    .btn-pin-thread {
        margin-left: 0;
    }

    .thread-header-meta span {
        display: block;
        margin-right: 0;
        margin-bottom: 4px;
    }

    .post-header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 8px;
        font-size: 14px;
        margin-bottom: 6px;
    }

    .post-item {
        padding: 10px 12px;
    }

    .post-number {
        font-size: 15px;
    }

    .post-author {
        font-size: 14px;
    }

    .post-user-number {
        font-size: 12px;
    }

    .post-date {
        font-size: 12px;
    }

    .post-content {
        font-size: 15px;
        margin-left: 0;
        padding: 6px 0;
        line-height: 1.5;
    }

    .post-footer {
        padding-top: 6px;
    }

    .post-list {
        gap: 8px;
    }

    .post-ip {
        display: none;
    }

    .bbs-sort-options {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .sort-link {
        padding: 6px 10px;
        font-size: 12px;
    }

    .bbs-thread-list h3 {
        font-size: 16px;
    }

    .bbs-new-thread h3 {
        font-size: 18px;
    }

    .bbs-new-thread input[type="text"],
    .bbs-new-thread textarea {
        font-size: 16px;
    }

    .bbs-reply-form h3 {
        font-size: 16px;
    }

    .bbs-reply-form textarea {
        font-size: 16px;
    }

    .btn-primary {
        font-size: 16px;
        padding: 10px 20px;
    }

    .thread-title-heading {
        font-size: 20px;
    }

    .bbs-pagination {
        gap: 12px;
    }

    .btn-page {
        padding: 8px 12px;
        font-size: 14px;
    }

    .post-count {
        font-size: 20px;
    }

    .post-number {
        font-size: 16px;
    }
}