/* =============================
   社内ポータル 共通スタイル
   Fereple ブランドカラー適用
   ターコイズ: #04B3C4
   ネイビー:   #253B94
   ============================= */

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

body {
    font-family: Avenir, "Segoe UI", YuGothic, "Yu Gothic Medium", sans-serif;
    font-size: 14px;
    color: #1a2a3a;
    background: #f0f4f8;
    line-height: 1.6;
}

/* =============================
   ログインページ
   ============================= */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #253B94 0%, #04B3C4 100%);
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 16px;
}

.login-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 44px 40px;
    box-shadow: 0 8px 40px rgba(37,59,148,0.18);
    text-align: center;
}

.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-title {
    font-size: 22px;
    font-weight: 700;
    color: #253B94;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}
.login-subtitle { font-size: 13px; color: #94a3b8; margin-bottom: 28px; }

/* =============================
   フォーム共通
   ============================= */
.form-group { margin-bottom: 16px; text-align: left; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #253B94;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #1a2a3a;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #04B3C4;
    box-shadow: 0 0 0 3px rgba(4,179,196,0.12);
}

/* =============================
   ボタン
   ============================= */
.btn {
    display: inline-block;
    padding: 9px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid #e2e8f0;
    text-decoration: none;
    transition: all 0.15s;
    background: #fff;
    color: #475569;
}

.btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.btn-primary {
    background: #04B3C4;
    color: #fff;
    border-color: #04B3C4;
}
.btn-primary:hover {
    background: #039aab;
    border-color: #039aab;
}

.btn-block { display: block; width: 100%; text-align: center; margin-top: 8px; }

/* =============================
   アラート
   ============================= */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: left;
}

.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #e0f9fa; color: #0e7490; border: 1px solid #67e8f9; }

/* 共有先バッジ（投稿一覧・詳細） */
.badge-share {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 99px;
    background: #7490f8;
    color: #fff;
}

/* =============================
   レイアウト（ログイン後）
   ============================= */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: #253B94;
    color: #c7d2f0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 20px 16px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    letter-spacing: -0.01em;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.sidebar-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    padding: 12px 16px 4px;
    font-weight: 700;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    background: none;
    background-color: transparent;
    border: none;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: #fff;
    text-align: left;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus,
.sidebar-toggle:active {
    background: none;
    background-color: transparent;
    color: #fff;
}

.sidebar-toggle i {
    font-size: 13px;
    transition: transform 0.15s ease;
}

.sidebar-toggle[aria-expanded="false"] i {
    transform: rotate(-90deg);
}

.sidebar-group.collapsed {
    display: none;
}

.sidebar-item {
    display: block;
    padding: 8px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.12s, color 0.12s;
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    background: rgba(4,179,196,0.18);
    color: #fff;
    border-left-color: #04B3C4;
}

.sidebar-item.active {
    background: #04B3C4;
    color: #fff;
    border-left-color: #04B3C4;
}

.sidebar-footer {
    padding: 16px;
    padding-bottom: calc(44px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    line-height: 1.9;
}
.sidebar-footer a { display: inline-block; padding: 6px 2px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: #fff;
    border-bottom: 2px solid #04B3C4;
    padding: 0 24px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

/* show.php/edit.phpの「編集・削除」「公開する・下書き保存・キャンセル」を
   トップバーのすぐ下に固定表示する行。本文が長くても、上までスクロールし直さず
   操作できるようにする（該当ページのみ使用。他ページには影響しない）。
   トップバーと同じ白背景にして、行が増えただけに見えるよう継ぎ目をなくし、
   アクセントの下線はこの行の下端に移動させる（:has で該当ページのみ）。 */
.topbar:has(+ .topbar-actions) {
    border-bottom: none;
}
.topbar-actions {
    position: sticky;
    top: 52px;
    z-index: 49;
    background: #fff;
    border-bottom: 2px solid #04B3C4;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 700;
    color: #253B94;
    letter-spacing: -0.01em;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user {
    font-size: 12px;
    color: #64748b;
    background: #f0f4f8;
    padding: 4px 12px;
    border-radius: 99px;
}

.content { padding: 24px; flex: 1; max-width: 1280px; }
/* ページ種別ごとの最大幅（ここで一括調整できます） */
.content.content--form { max-width: 720px; }
.content.content--full { max-width: none !important; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.card {
    background: #fff;
    border: 0.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 20px 54px;
    box-shadow: 0 1px 4px rgba(37,59,148,0.04);
}

.card-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin-bottom: 6px;
}

.card-value { font-size: 26px; font-weight: 700; color: #04B3C4; }
.card-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }

/* ===== ベル通知 ===== */
.topbar-bell { position: relative; display: flex; align-items: center; margin-right: 4px; }
.topbar-bell button {
    background: none; border: none; cursor: pointer;
    font-size: 18px; padding: 6px 8px; border-radius: 8px;
    position: relative; color: #64748b; transition: background .15s, color .15s;
    line-height: 1;
}
.topbar-bell button:hover { background: #f1f5f9; color: #04B3C4; }
.bell-badge {
    position: absolute; top: 2px; right: 2px;
    background: #ef4444; color: #fff;
    font-size: 10px; font-weight: 700; line-height: 1;
    padding: 2px 4px; border-radius: 99px; min-width: 16px; text-align: center;
    pointer-events: none;
}
.bell-dropdown {
    position: absolute; top: calc(100% + 6px); right: -8px;
    width: 320px; background: #fff; border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12); border: 1px solid #e2e8f0;
    z-index: 9999;
}
.bell-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px 8px; border-bottom: 1px solid #f1f5f9;
    font-size: 13px; font-weight: 700; color: #1a2a3a;
}
.bell-mark-all {
    font-size: 11px; color: #04B3C4; background: none; border: none;
    cursor: pointer; font-weight: 600; padding: 2px 6px; border-radius: 4px;
}
.bell-mark-all:hover { background: #e0f7fa; }
.bell-list { max-height: 320px; overflow-y: auto; }
.bell-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 16px; border-bottom: 1px solid #f8fafc;
    text-decoration: none; color: inherit; transition: background .12s;
    cursor: pointer;
}
.bell-item:hover { background: #f8fafc; }
.bell-item.unread { background: #f0fbff; }
.bell-item.unread:hover { background: #e0f7fa; }
.bell-dot { width: 8px; height: 8px; border-radius: 50%; background: #04B3C4; flex-shrink: 0; margin-top: 5px; }
.bell-dot.read { background: transparent; }
.bell-item-title { font-size: 12px; font-weight: 600; color: #1a2a3a; line-height: 1.4; }
.bell-item-time { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.bell-empty { padding: 24px 16px; text-align: center; color: #94a3b8; font-size: 13px; }
.bell-all-link {
    display: block; text-align: center; padding: 10px;
    font-size: 12px; color: #04B3C4; font-weight: 600;
    border-top: 1px solid #f1f5f9; text-decoration: none;
    border-radius: 0 0 12px 12px;
}
.bell-all-link:hover { background: #f0fbff; }

/* ===== 検索バー ===== */
.topbar-search{margin-left:auto;margin-right:12px;}
.topbar-search form{display:flex;align-items:center;background:#f1f5f9;border-radius:8px;padding:0 10px;border:1px solid #e2e8f0;transition:border-color .15s;}
.topbar-search form:focus-within{border-color:#04B3C4;background:#fff;}
.topbar-search input{flex:1;width:330px;border:none;background:transparent;outline:none;font-size:13px;padding:7px 4px;color:#1a2a3a;}
.topbar-search input::placeholder{color:#94a3b8;}
.topbar-search button{background:none;border:none;cursor:pointer;color:#94a3b8;padding:0;font-size:14px;display:flex;align-items:center;}
.topbar-search button:hover{color:#04B3C4;}

/* ===== 検索結果 ===== */
.search-list{display:flex;flex-direction:column;gap:0;}
.search-row{display:flex;align-items:center;gap:12px;padding:13px 6px;border-bottom:1px solid #e8eef3;text-decoration:none;color:inherit;transition:background .12s;}
.search-row:first-child{border-top:1px solid #e8eef3;}
.search-row:hover{background:#f8fbfc;}
.search-badge{font-size:11px;font-weight:600;padding:2px 8px;border-radius:4px;white-space:nowrap;flex-shrink:0;}
.search-title{font-size:14px;font-weight:600;color:#1a2a3a;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.search-meta{font-size:11px;color:#94a3b8;white-space:nowrap;flex-shrink:0;}

/* ===== モバイル対応 ===== */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-right: 12px;
    flex-shrink: 0;
}
.hamburger span {
    display: block;
    height: 2px;
    background: #253B94;
    border-radius: 2px;
    transition: all .25s;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 768px) {
    .hamburger { display: flex; }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform .25s;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .sidebar.open { transform: translateX(0); }

    .main { width: 100%; }

    .topbar { padding: 0 14px; }
    .topbar-title { font-size: 14px; }
    .topbar-user { display: none; }

    .content { padding: 16px; }

    /* ダッシュボード */
    .dash-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .dash-card { padding: 14px 16px; }
    .dash-card-num { font-size: 30px; }

    /* 投稿一覧カード */
    .post-card-footer { flex-direction: column; align-items: flex-start; gap: 6px; }

    /* テーブル横スクロール */
    .content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* フォーム */
    .form-row { flex-direction: column; }

    /* 検索バー */
    .topbar-search form { max-width: 180px; }
    .topbar-search input { width: 130px; }
}

/* TOCサイドバー非表示（2026-08-22）：
   本文側に min-width:600px を確保する方針にしたため、目次を消すタイミングは
   モバイルレイアウト全体の切り替え(768px)より広めの900pxに単独で設定する。
   768〜900pxの間で本文600px+目次の最小幅がぶつかって横スクロールが出るのを防ぐ狙い。 */
@media (max-width: 900px) {
    .toc-sidebar { display: none; }
}

/* 本文＋目次の2カラムレイアウト（投稿・マニュアル・AI活用の詳細/編集/新規作成ページ共通）
   本文側は元々 style="flex:1;min-width:600px;" という直書きだったため、
   画面幅600px未満のスマホでは本文が画面幅を超えて横スクロールが発生していた（2026-08-23 修正）。
   目次サイドバーが消える900px以下では、本文側の最小幅制約も外して画面幅いっぱいに収める。 */
.wide-content-col { flex: 1; min-width: 600px; }
@media (max-width: 900px) {
    .wide-content-col { min-width: 0; width: 100%; }
}

@media (max-width: 480px) {
    .dash-grid { grid-template-columns: 1fr; }
    .topbar-search { display: none; }
}

/* スマホでのフォーム入力時の自動ズームを防止 */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
    /* topbar-titleは長いタイトルを省略表示 */
    .topbar-title { flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
}

/* サイドバー表示中、背後の本体がスクロールしないようロック */
body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ===== コメント機能 ===== */
.comment-section { margin-top: 32px; padding-top: 24px; border-top: 0.5px solid #e2e8f0; }
.comment-section-head { font-size: 14px; font-weight: 700; color: #1a2a3a; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.comment-count-badge { font-size: 11px; background: #f1f5f9; color: #64748b; padding: 1px 8px; border-radius: 99px; font-weight: 600; }
.comment-item { display: flex; gap: 10px; margin-bottom: 16px; }
.comment-avatar { width: 32px; height: 32px; border-radius: 50%; background: #e0f9fa; color: #0e7490; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.comment-body-wrap { flex: 1; min-width: 0; }
.comment-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.comment-name { font-size: 12px; font-weight: 700; color: #1a2a3a; }
.comment-time { font-size: 10px; color: #94a3b8; }
.comment-del-btn { font-size: 10px; color: #cbd5e1; background: none; border: none; cursor: pointer; margin-left: auto; display: flex; align-items: center; gap: 2px; padding: 0; }
.comment-del-btn:hover { color: #ef4444; }
.comment-text { font-size: 13px; color: #1a2a3a; line-height: 1.7; background: #f8fafc; border-radius: 0 10px 10px 10px; padding: 8px 12px; word-break: break-word; }
.comment-mention { color: #2563eb; font-weight: 600; }
.comment-form { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 0.5px solid #e2e8f0; }
.comment-input-wrap { flex: 1; position: relative; }
.comment-textarea { width: 100%; border: 0.5px solid #e2e8f0; border-radius: 10px; padding: 9px 12px; font-size: 13px; color: #1a2a3a; background: #fff; outline: none; resize: none; font-family: inherit; line-height: 1.6; transition: border-color .15s; }
.comment-textarea:focus { border-color: #04B3C4; }
.comment-hint { font-size: 10px; color: #94a3b8; margin-top: 4px; }
.comment-submit-btn { background: #04B3C4; color: #fff; border: none; border-radius: 10px; padding: 0 18px; font-size: 13px; font-weight: 600; cursor: pointer; align-self: flex-start; height: 38px; white-space: nowrap; transition: opacity .15s; }
.comment-submit-btn:hover { opacity: .85; }
.mention-dropdown { position: absolute; bottom: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 0.5px solid #e2e8f0; border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,.12); z-index: 100; min-width: 200px; max-height: 220px; overflow-y: auto; -webkit-overflow-scrolling: touch; display: none; }
.mention-dropdown.open { display: block; }
.mention-option { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 12px; color: #1a2a3a; cursor: pointer; }
.mention-option:hover, .mention-option.active { background: #f0fbff; }
.mention-avatar { width: 24px; height: 24px; border-radius: 50%; background: #e0f9fa; color: #0e7490; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pc-comment-count { font-size: 10px; color: #94a3b8; display: inline-flex; align-items: center; gap: 3px; }

/* ===== リアクション ===== */
.comment-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.reaction-add-btn {
    opacity: 0;
    transition: opacity .15s;
    background: none;
    border: 0.5px solid transparent;
    border-radius: 50%;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 13px; color: #94a3b8;
    padding: 0;
    flex-shrink: 0;
}
.reaction-add-btn { opacity: 1; }
.reaction-add-btn:hover { border-color: #e2e8f0; color: #04B3C4; background: #f0fbff; }
.reaction-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; min-height: 0; }
.reaction-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: #f8fafc; border: 0.5px solid #e2e8f0;
    border-radius: 99px; padding: 2px 8px 2px 6px;
    font-size: 11px; color: #64748b; cursor: pointer;
    transition: background .12s, border-color .12s;
    line-height: 1;
}
.reaction-chip i { font-size: 13px; }
.reaction-chip:hover { background: #e0f9fa; border-color: #04B3C4; }
.reaction-chip.reacted { background: #e0f9fa; border-color: #04B3C4; color: #0e7490; font-weight: 600; }
.reaction-picker {
    position: absolute;
    background: #fff;
    border: 0.5px solid #e2e8f0;
    border-radius: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,.13);
    display: none;
    gap: 2px;
    padding: 6px 8px;
    z-index: 300;
    align-items: center;
}
.reaction-picker.open { display: flex; }
.reaction-btn {
    display: flex; flex-direction: column; align-items: center;
    background: none; border: none; cursor: pointer;
    padding: 4px 7px; border-radius: 8px;
    font-size: 20px; color: #64748b;
    transition: background .12s, color .12s, transform .15s;
    gap: 2px; line-height: 1;
}
.reaction-btn span { font-size: 9px; color: #94a3b8; white-space: nowrap; }
.reaction-btn:hover { background: #f0fbff; color: #04B3C4; transform: scale(1.25); }
.reaction-btn.reacted { color: #04B3C4; }
@media (max-width: 640px) {
    .reaction-add-btn { opacity: 1; }
}

/* 投稿・マニュアル詳細ページ：SPビューのヘッダーボタン行 */
@media(max-width:600px){
    .post-show-header { flex-direction:column-reverse; }
    .post-show-actions { align-self:flex-end; }
    .post-show-actions .btn { font-size:12px; font-family:inherit; }
}
