/* ============================================
   CP Community Platform - Stylesheet
   白背景・シンプル・信頼感・スマホファースト
   ============================================ */

/* --- リセット & ベース --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #1F4E79;
    --primary-light: #2F6FA8;
    --primary-pale: #E8F0F8;
    --accent: #E67E22;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --bg: #FFFFFF;
    --bg-light: #F8F9FA;
    --border: #E0E0E0;
    --border-light: #F0F0F0;
    --success: #27AE60;
    --danger: #C0392B;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --font: 'メイリオ', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-light);
    line-height: 1.7;
    min-height: 100vh;
    padding-bottom: 70px; /* モバイルナビ分 */
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    color: var(--primary-light);
}

img {
    max-width: 100%;
    height: auto;
}

/* --- ヘッダー --- */
.site-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-logo-icon-img {
    width: 28px;
    height: 28px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user-name {
    font-size: 0.85rem;
    color: var(--text-light);
}

.header-logout {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.header-logout:hover {
    background: var(--bg-light);
    color: var(--text);
}

/* --- デスクトップナビ --- */
.desktop-nav {
    display: none;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.desktop-nav-inner {
    display: flex;
    gap: 0;
}

.desktop-nav a {
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.desktop-nav a:hover,
.desktop-nav a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* --- モバイルナビ（下部タブ） --- */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: color 0.2s;
    gap: 0.2rem;
}

.mobile-nav a:hover,
.mobile-nav a.active {
    color: var(--primary);
}

.mobile-nav .nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

/* --- コンテナ --- */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* --- カード --- */
.card {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

/* --- アバター --- */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-pale);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* --- 投稿 --- */
.post-meta {
    display: flex;
    flex-direction: column;
}

.post-author {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text);
}

.post-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.post-content {
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

.post-image {
    margin-top: 0.75rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.post-image img {
    display: block;
    width: 100%;
    max-height: 400px;
    object-fit: cover;
}

.post-actions {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.post-action-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0;
    transition: color 0.2s;
}

.post-action-btn:hover {
    color: var(--primary);
}

.post-action-btn.liked {
    color: var(--danger);
}

.pinned-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    margin-left: 0.5rem;
}

/* --- コメント --- */
.comments-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.comment {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.comment-body {
    flex: 1;
    background: var(--bg-light);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.comment-author {
    font-weight: bold;
    font-size: 0.8rem;
}

.comment-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.comment-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.comment-form input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    font-family: var(--font);
    outline: none;
}

.comment-form input:focus {
    border-color: var(--primary);
}

.comment-form button {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
}

/* --- 投稿フォーム --- */
.post-form {
    margin-bottom: 1rem;
}

.post-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
    line-height: 1.7;
}

.post-form textarea:focus {
    border-color: var(--primary);
}

.post-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.post-form-actions label {
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* --- イベント --- */
.event-card {
    border-left: 4px solid var(--primary);
}

.event-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.event-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.event-info {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.event-participants {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.event-participants .avatars-stack {
    display: flex;
}

.event-participants .avatars-stack .avatar-sm {
    margin-left: -8px;
    border: 2px solid white;
}

.event-participants .avatars-stack .avatar-sm:first-child {
    margin-left: 0;
}

.event-join-btn {
    margin-top: 0.75rem;
}

/* --- カレンダー --- */
.calendar {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.calendar th {
    background: var(--primary-pale);
    color: var(--primary);
    padding: 0.5rem;
    font-size: 0.8rem;
    text-align: center;
}

.calendar td {
    border: 1px solid var(--border-light);
    padding: 0.25rem;
    vertical-align: top;
    height: 80px;
    width: 14.28%;
    font-size: 0.8rem;
}

.calendar .day-number {
    font-weight: bold;
    color: var(--text-light);
    margin-bottom: 0.2rem;
}

.calendar .today .day-number {
    color: white;
    background: var(--primary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar .has-event {
    background: var(--primary-pale);
}

.calendar .event-dot {
    display: block;
    font-size: 0.7rem;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.1rem 0.2rem;
    background: white;
    border-radius: 2px;
    margin-top: 0.1rem;
}

.calendar .other-month {
    color: var(--text-muted);
    background: var(--bg);
}

.calendar .sunday { color: var(--danger); }
.calendar .saturday { color: var(--primary); }

/* --- お知らせ --- */
.announcement-card {
    border-left: 4px solid var(--accent);
}

.announcement-card.pinned {
    border-left-color: var(--danger);
    background: #FFF9F0;
}

.announcement-title {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

/* --- ボタン --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-light);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary-pale);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* --- フォーム --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 0.3rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.1);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* --- フラッシュメッセージ --- */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash-success {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}

.flash-error {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

.flash-info {
    background: var(--primary-pale);
    color: var(--primary);
    border: 1px solid #BBDEFB;
}

/* --- 認証ページ --- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-light);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.auth-title {
    text-align: center;
    color: var(--primary);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- ページタイトル --- */
.page-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-pale);
}

/* --- セクション切り替え（タブ） --- */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font);
    transition: all 0.2s;
}

.tab:hover,
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* --- 空の状態 --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* --- ユーティリティ --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }

/* --- 未読バッジ --- */
.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 4px;
    margin-left: 4px;
    font-weight: bold;
}

.unread-badge-mobile {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(12px);
    background: var(--danger);
    color: white;
    font-size: 0.6rem;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    font-weight: bold;
}

/* --- レスポンシブ --- */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    .mobile-nav {
        display: none;
    }

    .desktop-nav {
        display: block;
    }

    .calendar td {
        height: 100px;
    }
}
