/**
 * Fan Portal コメントシステム スタイルシート
 * 
 * @package Fan_Portal
 * @since 3.6.0
 */

/* 記事本文後のコンテンツラッパー */
.fp-after-content-wrapper {
    margin-top: 50px;
}

/* コメントセクション全体 */
.fp-comments-section {
    margin: 40px 0;
    padding: 30px 0;
}

.fp-comments-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.fp-comments-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.fp-comment-count {
    font-size: 18px;
    color: #666;
    font-weight: normal;
}

/* キャラクター選択 */
.fp-character-select {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* 横スクロールを含める */
}

.fp-character-select p {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.fp-character-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    /* 最小幅を確保してスクロール可能にする */
    min-height: 50px;
}

/* スクロールバーのスタイル（デスクトップ） */
.fp-character-grid::-webkit-scrollbar {
    height: 6px;
}

.fp-character-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.fp-character-grid::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.fp-character-grid::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.fp-character-option {
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.fp-character-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.fp-character-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    transition: all 0.3s ease;
    min-width: fit-content; /* コンテンツに応じた最小幅 */
}

.fp-character-option input[type="radio"]:checked + .fp-character-box {
    border-color: #4CAF50;
    background: #f0f8f0;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.fp-character-box:hover {
    border-color: #999;
    background: #f9f9f9;
}

.fp-character-box .fp-name {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    white-space: nowrap;
    display: inline-block;
}

/* コメントフォーム */
.fp-comment-form-wrapper {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
}

.fp-comment-form {
    margin: 0;
}

.fp-comment-field {
    margin-bottom: 15px;
}

.fp-comment-field textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.fp-comment-field textarea:focus {
    outline: none;
    border-color: #4CAF50;
}

.fp-comment-meta {
    display: flex;
    justify-content: flex-end;
    margin-top: 5px;
}

.fp-char-count {
    font-size: 14px;
    color: #666;
}

.fp-comment-submit {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.fp-comment-submit:hover {
    background: #45a049;
}

.fp-comment-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* コメントリスト */
.fp-comments-list {
    margin-top: 30px;
}

.fp-comments-sort {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.fp-sort-button {
    background: #fff;
    border: 2px solid #e0e0e0;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fp-sort-button.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.fp-sort-button:hover:not(.active) {
    border-color: #999;
}

.fp-comment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* 個別コメント */
.fp-comment {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.fp-comment:hover {
    transform: translateY(-2px);
    border-color: #ccc;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-icon {
    font-size: 24px;
}

.user-name {
    font-weight: bold;
    color: #333;
}

.user-level {
    font-size: 12px;
    background: #e0e0e0;
    padding: 2px 8px;
    border-radius: 12px;
    color: #666;
}

.comment-time {
    margin-left: auto;
    font-size: 14px;
    color: #999;
}

.comment-body {
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    margin-bottom: 12px;
    word-wrap: break-word;
    position: relative;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* 長いコメントの折りたたみ */
.comment-body.collapsed {
    max-height: 100px;
}

.comment-body.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, rgba(249, 249, 249, 0.95));
    pointer-events: none;
}

.fp-read-more {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: #f0f0f0;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.fp-read-more:hover {
    background: #e0e0e0;
    color: #333;
}

.comment-actions {
    display: flex;
    gap: 15px;
}

.comment-actions button {
    background: none;
    border: 1px solid #e0e0e0;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.comment-actions button:hover {
    border-color: #999;
    background: #f5f5f5;
}

.like-btn.liked {
    background: #ffebee;
    border-color: #f44336;
    color: #f44336;
}

.report-btn {
    margin-left: auto;
}

/* 返信 */
.fp-comment-replies {
    margin-left: 40px;
    margin-top: 15px;
    list-style: none;
    padding: 0;
}

.fp-comment.reply {
    background: #f0f0f0;
    border-color: #d0d0d0;
}

/* 読み込みボタン */
.fp-load-more-wrapper {
    text-align: center;
    margin-top: 30px;
}

.fp-load-more-comments {
    background: #fff;
    border: 2px solid #4CAF50;
    color: #4CAF50;
    padding: 12px 40px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fp-load-more-comments:hover {
    background: #4CAF50;
    color: white;
}

/* コメントなし */
.fp-no-comments {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .fp-comments-title {
        font-size: 20px;
    }
    
    .fp-comment-count {
        font-size: 16px;
    }
    
    .fp-character-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .fp-comment-replies {
        margin-left: 20px;
    }
    
    .comment-header {
        flex-wrap: wrap;
    }
    
    .comment-time {
        width: 100%;
        margin-left: 0;
        margin-top: 5px;
        font-size: 12px;
    }
    
    .fp-load-more-comments {
        padding: 10px 30px;
        font-size: 14px;
    }
    
    /* コメントアクションボタンのサイズ調整 */
    .comment-actions button {
        padding: 4px 10px;
        font-size: 12px;
    }
}

/* スマートフォン対応 */
@media (max-width: 480px) {
    .fp-comments-title {
        font-size: 18px;
    }
    
    /* キャラクター選択をコンパクトに */
    .fp-character-select {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .fp-character-select p {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .fp-character-box {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    .fp-character-box .fp-name {
        font-size: 13px;
    }
    
    .fp-comment-replies {
        margin-left: 10px;
    }
    
    .comment-body {
        font-size: 14px;
    }
    
    /* アクションボタンを縦並びに */
    .comment-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .report-btn {
        width: 100%;
        margin-left: 0;
        margin-top: 5px;
    }
}

/* エラーメッセージ */
.fp-error-message {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* 成功メッセージ */
.fp-success-message {
    background: #efe;
    border: 1px solid #cfc;
    color: #3c3;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* ローディング */
.fp-loading {
    text-align: center;
    padding: 20px;
}

.fp-loading::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: fp-spin 1s linear infinite;
}

@keyframes fp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}