/* ============================================================
   情報共有ボード - スタイルシート
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
    background: #f5f6f8;
    color: #1a1a1a;
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- ログインページ ---- */
.login-container {
    max-width: 380px;
    margin: 0 auto;
    padding: 40px 32px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 32px);
}

.login-container h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #1a1a1a;
}

.login-description {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 28px;
}

.login-container input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    background: #fafafa;
}

.login-container input:focus {
    border-color: #5b7ff5;
    background: #fff;
}

.login-container button {
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    background: #5b7ff5;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.login-container button:hover {
    background: #4a6de0;
}

.login-container button:active {
    transform: scale(0.98);
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    border: 1px solid #fee2e2;
}

/* ---- ヘッダー ---- */
header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}

.header-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

header h1 {
    font-size: 1.15rem;
    font-weight: 700;
}

.post-count {
    font-size: 0.75rem;
    color: #5b7ff5;
    background: #eef2ff;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.logout-btn, .back-btn {
    color: #888;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 6px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.logout-btn:hover, .back-btn:hover {
    background: #f5f5f5;
    color: #555;
}

.flash-messages {
    margin-bottom: 12px;
}

.flash-error {
    background: #fff3f3;
    color: #d32f2f;
    border: 1px solid #ffcdd2;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.85rem;
}

/* ---- メインコンテンツ ---- */
main {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ---- 検索バー ---- */
.search-bar {
    margin-bottom: 16px;
}

.search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 0.9rem;
    outline: none;
    background: #fff;
    transition: border-color 0.2s;
    font-family: inherit;
}

.search-input:focus {
    border-color: #5b7ff5;
}

.search-btn {
    padding: 10px 20px;
    background: #5b7ff5;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.search-btn:hover {
    background: #4a6de0;
}

.search-clear {
    color: #888;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 6px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.search-clear:hover {
    background: #f5f5f5;
    color: #555;
}

/* ---- フィルターバー ---- */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 7px 18px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    background: #fff;
    color: #666;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #f8f8f8;
    border-color: #ccc;
}

.filter-btn.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

/* ---- カテゴリ色 ---- */
.cat-MRI1 { --cat-color: #5b7ff5; --cat-bg: #eef2ff; }
.cat-MRI2 { --cat-color: #10b981; --cat-bg: #ecfdf5; }
.cat-MRI3 { --cat-color: #f59e0b; --cat-bg: #fffbeb; }
.cat-その他 { --cat-color: #8b8b8b; --cat-bg: #f3f3f3; }

.filter-btn.cat-MRI1.active { background: #5b7ff5; border-color: #5b7ff5; color: #fff; }
.filter-btn.cat-MRI2.active { background: #10b981; border-color: #10b981; color: #fff; }
.filter-btn.cat-MRI3.active { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.filter-btn.cat-その他.active { background: #8b8b8b; border-color: #8b8b8b; color: #fff; }

/* ---- 投稿カード ---- */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.post-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    transition: box-shadow 0.2s;
}

.post-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.post-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cat-color);
    background: var(--cat-bg);
}

.post-user {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
}

.post-date {
    color: #bbb;
    font-size: 0.75rem;
}

.post-content {
    font-size: 0.92rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    color: #333;
}

.post-image {
    margin-top: 14px;
}

.post-image img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    object-fit: contain;
    background: #f8f8f8;
}

/* ---- 編集・削除ボタン ---- */
.post-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.action-btn {
    font-size: 0.78rem;
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    background: none;
}

.edit-btn {
    color: #5b7ff5;
    background: #eef2ff;
}

.edit-btn:hover {
    background: #dde5ff;
}

.delete-btn {
    color: #dc2626;
    background: #fef2f2;
}

.delete-btn:hover {
    background: #fee2e2;
}

.delete-form {
    display: inline;
}

/* ---- 編集ページ ---- */
.edit-container {
    background: #fff;
    border-radius: 14px;
    padding: 28px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
    margin-top: 20px;
}

.form-label:first-child {
    margin-top: 0;
}

.category-select {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cat-option {
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    color: #666;
    background: #fff;
    transition: all 0.2s;
}

.cat-option input {
    display: none;
}

.cat-option.selected,
.cat-option:has(input:checked) {
    border-color: var(--cat-color);
    color: var(--cat-color);
    background: var(--cat-bg);
}

.edit-container textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.7;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s;
    background: #fafafa;
}

.edit-container textarea:focus {
    border-color: #5b7ff5;
    background: #fff;
}

.edit-image {
    margin-top: 4px;
}

.edit-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    object-fit: contain;
}

.edit-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.cancel-btn {
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    text-decoration: none;
    color: #666;
    background: #f5f5f5;
    font-weight: 500;
    transition: background 0.2s;
}

.cancel-btn:hover {
    background: #e8e8e8;
}

.save-btn {
    padding: 10px 28px;
    border-radius: 10px;
    font-size: 0.9rem;
    background: #5b7ff5;
    color: #fff;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.save-btn:hover {
    background: #4a6de0;
}

.save-btn:active {
    transform: scale(0.98);
}

/* ---- 空の状態 ---- */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #bbb;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #999;
    margin-bottom: 6px;
}

.empty-hint {
    font-size: 0.85rem;
    color: #bbb;
}

/* ---- 添付ファイル ---- */
.post-attachments {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.attachment-player {
    max-width: 100%;
    border-radius: 10px;
    background: #f8f8f8;
}

video.attachment-player {
    max-height: 400px;
}

.attachment-file {
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.file-download-link {
    color: #5b7ff5;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    word-break: break-all;
}

.file-download-link:hover {
    text-decoration: underline;
}

.edit-attachments {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

/* ---- パスワードモーダル ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 6px;
}

.modal-desc {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 20px;
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    background: #fafafa;
    font-family: inherit;
}

.modal-input:focus {
    border-color: #5b7ff5;
    background: #fff;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-cancel-btn {
    flex: 1;
    padding: 11px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #666;
    transition: background 0.2s;
}

.modal-cancel-btn:hover {
    background: #f5f5f5;
}

.modal-submit-btn {
    flex: 1;
    padding: 11px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: #5b7ff5;
    color: #fff;
    transition: background 0.2s;
}

.modal-submit-btn:hover {
    background: #4a6de0;
}

.modal-submit-danger {
    background: #dc2626;
}

.modal-submit-danger:hover {
    background: #b91c1c;
}

/* ---- 編集画面: 添付ファイル削除 ---- */
.edit-attachment-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.edit-attachment-preview {
    flex: 1;
    min-width: 0;
}

.delete-attachment-label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #fef2f2;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 4px;
    transition: background 0.2s;
}

.delete-attachment-label:hover {
    background: #fee2e2;
}

.delete-attachment-label input[type="checkbox"] {
    accent-color: #dc2626;
}

.delete-attachment-text {
    font-size: 0.78rem;
    color: #dc2626;
    font-weight: 500;
}

/* ---- 編集画面: ファイルアップロード ---- */
.file-upload-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px dashed #e0e0e0;
    border-radius: 10px;
    font-size: 0.9rem;
    background: #fafafa;
    cursor: pointer;
    font-family: inherit;
}

.file-upload-input:hover {
    border-color: #5b7ff5;
    background: #f8faff;
}

.file-upload-hint {
    font-size: 0.78rem;
    color: #999;
    margin-top: 6px;
}

/* ---- スマホ対応 ---- */
@media (max-width: 600px) {
    .login-container {
        padding: 32px 24px;
    }

    header h1 {
        font-size: 1rem;
    }

    .post-card {
        padding: 16px;
    }

    .post-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .edit-container {
        padding: 20px 16px;
    }

    .edit-actions {
        flex-direction: column;
    }

    .cancel-btn, .save-btn {
        text-align: center;
    }

    .modal-card {
        padding: 24px 20px;
    }

    .edit-attachment-item {
        flex-direction: column;
        gap: 6px;
    }
}
