/* static/index.css */
/* トップページ (スレッド一覧) 用のスタイル */

/* --- グローバルなヘッダースタイル (index.html専用) --- */
header {
    background-color: #4a6572; /* Honneyのテーマカラー */
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
    font-size: 1.6em;
    display: flex;
    align-items: center;
}

/* ヘッダー内のユーザー情報エリア */
.user-info-header {
    display: flex;
    align-items: center; /* 要素を垂直方向中央に揃える */
    flex-wrap: wrap;     /* ★ 重要: 要素がコンテナ幅を超える場合に折り返すようにする */
    justify-content: flex-end; /* 右寄せにする場合 */
    gap: 8px; /* 各要素間の隙間 */
}

.user-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
}

.username-form {
    display: flex;       /* inputとbuttonを横並びにする */
    align-items: center;
    gap: 5px;
}

.username-form input[type="text"] {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
    max-width: 100px;
}

.username-form button {
    padding: 6px 10px;
    background-color: #5cb85c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    white-space: nowrap;
}
.username-form button:hover {
    background-color: #4cae4c;
}

.user-actions-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mypage-button,
.notification-button {
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 3px;
    color: white;
    display: inline-flex;
    align-items: center;
    font-size: 0.8em;
    white-space: nowrap;
}
.notification-button:hover,
.mypage-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: white;
}
.mypage-button {
    background-color: #5a6268;
    border-color: #5a6268;
}
.mypage-button:hover {
    background-color: #4e555b;
    border-color: #4e555b;
}

.notification-button .unread-badge {
    color: #ffdd57;
    font-weight: bold;
    margin-left: 4px;
}

/* --- カテゴリフィルター --- */
.category-filter-container {
    overflow-x: auto;
    white-space: nowrap;
    padding: 10px 0;
    margin-bottom: 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}
.category-filter-container::-webkit-scrollbar {
    height: 5px;
}
.category-filter-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 5px;
}
.category-filter-list {
    list-style: none;
    padding: 0 15px;
    margin: 0;
    display: inline-block;
}
.category-filter-item {
    display: inline-block;
    margin-right: 8px;
}
.category-filter-item:last-child {
    margin-right: 0;
}
.category-filter-item a {
    text-decoration: none;
    color: #555;
    padding: 8px 15px;
    border-radius: 20px;
    background-color: #e9ecef;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.95em;
    display: block;
}
.category-filter-item a:hover {
    background-color: #ced4da;
    color: #333;
}
.category-filter-item.active a {
    background-color: #4a6572;
    color: white;
    font-weight: bold;
}

/* --- インラインエラーメッセージ --- */
.error-message-inline {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    text-align: center;
}

/* --- 新規スレッド作成フォーム --- */
.new-topic {
    background-color: white;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}
.new-topic form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* ▼▼▼【変更点】input[type="text"] に textarea を追加 ▼▼▼ */
.new-topic input[type="text"],
.new-topic textarea {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1em;
    min-width: 200px;
    font-family: inherit; /* フォントを親要素から継承 */
    box-sizing: border-box; /* paddingを含めて幅を計算 */
}

/* ▼▼▼【新規追加】textarea 固有のスタイル ▼▼▼ */
.new-topic textarea {
    resize: vertical; /* 垂直方向のみリサイズ可能に */
    min-height: 58px; /* 2行分の高さを確保 */
    line-height: 1.5;
}

.new-topic input[type="text"]::placeholder,
.new-topic textarea::placeholder {
    color: #888;
}
#topicCategory {
    padding: 12px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.95em;
    background-color: white;
    min-width: 160px;
    cursor: pointer;
}
.new-topic .form-group-header-image {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
    color: #555;
    flex-basis: 100%;
    order: 3;
}
.new-topic .form-group-header-image input[type="file"] {
    border: 1px solid #ced4da;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.9em;
}
.new-topic button[type="submit"] {
    padding: 12px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    white-space: nowrap;
    transition: background-color 0.2s;
    order: 4;
}
.new-topic button[type="submit"]:hover {
    background-color: #0056b3;
}
.new-topic button[type="submit"]:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* --- スレッドタイル一覧 --- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.tile-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    overflow: hidden;
}
.tile-link:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.12);
}

.tile-header {
    color: white;
    width: 100%;
    aspect-ratio: 16 / 10;
    position: relative;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    display: flex;
    background-size: cover;
    background-position: center;
}

.tile-header-content {
    width: 100%;
    height: 100%;
    padding: 20px 8px 40px 8px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    z-index: 2;
}

.tile-header .topic-title-text {
    font-size: 0.9em;
    line-height: 1.25;
    font-weight: bold;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center; /* ★ left から center に変更 */
}

.tile-header .tile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    box-sizing: border-box;
    z-index: 3;
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    justify-content: flex-start;
}

.tile-header .topic-badge {
    white-space: nowrap;
    line-height: 1.2;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    display: inline-flex;
    align-items: center;
    font-weight: bold;
    border: 1px solid rgba(0,0,0,0.2);
}

.tile-header .topic-badge.admin-badge,
.tile-header .topic-badge.category-badge {
    font-size: 0.75em;
    padding: 5px 12px;
    border-radius: 18px;
    text-shadow: none !important;
}

.tile-header .topic-badge.my-topic-badge {
    font-size: 0.75em;
    padding: 3px 8px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.75);
    color: #222;
    border-color: rgba(0,0,0,0.15);
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
}

.tile-header .topic-badge.admin-badge {
    background-color: #ffc107;
    color: white;
}
.tile-header .topic-badge.category-badge {
    background-color: rgba(0, 0, 0, 0.45);
    color: white;
}

.tile-body {
    padding: 0;
}

.tile-footer {
    background-color: #f8f9fa;
    padding: 10px 15px;
    color: #6c757d;
    font-size: 0.85em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.tile-footer-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-top: 20px;
}
.empty-state p {
    margin: 0;
    font-size: 1.1em;
}
.empty-state.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.tile-link.muted-content-hidden {
    display: none !important;
}

.like-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.like-button {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    color: #333;
    transition: background-color 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.like-button:hover {
    background-color: #e0e0e0;
}
.like-button.liked {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    cursor: default;
}
.like-button.liked:hover {
    background-color: #0056b3;
}
.like-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.like-count {
    font-size: 0.85em;
    color: #555;
    min-width: 10px;
    text-align: right;
}

@media (max-width: 768px) {
    header {
        padding: 8px 10px;
    }
    header h1 {
        font-size: 1.4em;
    }
    .user-info-header {
        gap: 6px;
        margin-top: 5px;
        width: 100%;
        justify-content: flex-end;
    }
    .username-form input[type="text"] {
        max-width: 90px;
        font-size: 0.85em;
    }
    .username-form button,
    .mypage-button,
    .notification-button {
        padding: 5px 8px;
        font-size: 0.75em;
    }

    .category-filter-list {
        padding: 0 8px;
    }
    .category-filter-item a {
        padding: 6px 10px;
        font-size: 0.85em;
    }

    .new-topic form {
        flex-direction: column;
        align-items: stretch;
    }

    /* ▼▼▼【変更点】レスポンシブ用のセレクタにも textarea を追加 ▼▼▼ */
    .new-topic input[type="text"],
    .new-topic textarea,
    #topicCategory,
    .new-topic .form-group-header-image,
    .new-topic button[type="submit"] {
        width: 100%;
        margin-bottom: 15px;
        box-sizing: border-box;
    }

    .new-topic .form-group-header-image {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }
    .new-topic .form-group-header-image label {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.9em;
    }
    .new-topic .form-group-header-image input[type="file"] {
        flex-grow: 1;
        min-width: 0;
        font-size: 0.85em;
    }

    /* ▼▼▼【変更点】レスポンシブ用のセレクタにも textarea を追加 ▼▼▼ */
    .new-topic input[type="text"],
    .new-topic textarea,
    #topicCategory {
         padding: 10px 12px;
         font-size: 1em;
    }
    .new-topic button[type="submit"] {
        margin-bottom: 0;
        padding: 12px 15px;
        font-size: 1em;
    }

    .tiles {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .tile-header-content {
        padding: 6px 6px 30px 6px;
    }

    .tile-header .topic-title-text {
        -webkit-line-clamp: 3;
        font-size: 0.8em;
        line-height: 1.2;
        text-align: center; /* ★ left から center に変更 */
    }

    .tile-header .tile-badges {
        gap: 4px;
        bottom: 4px;
        left: 6px;
        right: 6px;
    }

    .tile-header .topic-badge.admin-badge,
    .tile-header .topic-badge.category-badge {
        font-size: 0.7em;
        padding: 2px 6px;
        border-radius: 10px;
    }
    .tile-header .topic-badge.my-topic-badge {
        font-size: 0.6em;
        padding: 1px 4px;
        border-radius: 8px;
    }

    .tile-body {
        padding: 0;
    }
    .tile-footer {
        padding: 8px 10px;
        font-size: 0.8em;
    }
    .tile-footer-left {
        gap: 8px;
    }
}