
/* テキスト省略ユーティリティ */
.crop-text-1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.crop-text-2 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

#logout-link {
    cursor: pointer;
}
/* サイドバーのスタイル */
.sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    width: 250px;
    height: calc(100vh - 52px);
    background-color: #2c3e50;
    color: white;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #34495e;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    display: none;
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: white;
    margin: 3px 0;
    transition: 0.3s;
}

.sidebar-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid #34495e;
}

.sidebar-action-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 8px;
    background: transparent;
    color: #bdc3c7;
    border: 1px solid #34495e;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sidebar-action-btn:hover {
    background-color: #34495e;
    color: #fff;
    border-color: #3498db;
}

.sidebar-nav {
    padding: 20px 0;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin: 0;
}

.sidebar-nav .nav-link {
    display: block;
    padding: 15px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: background-color 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background-color: #34495e;
    border-left-color: #3498db;
    color: white;
}

.sidebar-nav .nav-link.active {
    background-color: #3498db;
    border-left-color: #2980b9;
}

/* カテゴリ階層メニュー */
.nav-category {
    margin: 0;
}

.nav-category-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: none;
    color: #bdc3c7;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.nav-category-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ecf0f1;
}

.nav-category-toggle.open {
    color: #3498db;
}

.nav-chevron {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.nav-category-toggle.open .nav-chevron {
    transform: rotate(90deg);
}

.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-submenu.open {
    max-height: 2000px;
}

.nav-submenu .nav-link {
    padding: 10px 20px 10px 32px;
    font-size: 0.88rem;
}

/* サブカテゴリ（カテゴリ内グルーピング） */
.nav-subgroup {
    margin: 0;
    list-style: none;
}

.nav-subgroup-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 20px 8px 32px;
    background: none;
    border: none;
    color: #95a5a6;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.nav-subgroup-toggle:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: #bdc3c7;
}

.nav-subgroup-toggle.open {
    color: #3498db;
}

.nav-subgroup-toggle.open .nav-chevron {
    transform: rotate(90deg);
}

.nav-subgroup-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-subgroup-menu.open {
    max-height: 2000px;
}

.nav-subgroup-menu .nav-link {
    padding: 8px 20px 8px 46px;
    font-size: 0.84rem;
}

.nav-divider {
    height: 1px;
    background: #34495e;
    margin: 8px 16px;
}

/* メインコンテンツのスタイル */
.main-content {
    margin-left: 250px;
    min-height: 100vh;
    padding-top: 52px;
    transition: margin-left 0.3s ease;
}
.main-content.no-sidebar {
    margin-left: 0;
}

.content-wrapper {
    padding: 20px;
}

/* グローバルヘッダー（PC・スマホ共通） */
.mobile-header,
.global-header {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: #2c3e50;
    z-index: 2000;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.mobile-header-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
}

/* ヘッダー検索フォーム */
.header-search-form {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 800px;
}

.header-tag-box {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    min-height: 34px;
    background: #fff;
    border-radius: 999px;
    cursor: text;
    overflow: hidden;
}

.header-tag-box:focus-within {
    outline: 2px solid #86b7fe;
    outline-offset: 1px;
}

.header-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 8px;
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 999px;
    font-size: .78rem;
    white-space: nowrap;
    user-select: none;
}

.header-tag .tag-remove {
    cursor: pointer;
    font-size: .85rem;
    line-height: 1;
    color: #555;
    background: none;
    border: none;
    padding: 0;
}

.header-tag .tag-remove:hover { color: #000; }

.header-tag-input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 80px;
    font-size: .875rem;
    padding: 0;
    background: transparent;
}

.header-search-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: .85;
}
.header-search-btn:hover { opacity: 1; }

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}

@media (min-width: 769px) {
    .hamburger-btn {
        display: none;
    }
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

.hamburger-btn.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.is-open span:nth-child(2) { opacity: 0; }
.hamburger-btn.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        top: 0;
        z-index: 1000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding-top: 52px;
        /* z-index を設定しない。スタッキングコンテキストを作ると
           内部の Bootstrap モーダル (z-index:1055) が backdrop (body直下, z-index:1050) の
           裏に隠れてスマホでモーダルが表示されなくなる。
           サイドバー・オーバーレイは position:fixed + 高い z-index で既に上に描画される。 */
    }

    .sidebar-toggle {
        display: none;
    }

    .sidebar-header h3 {
        font-size: 1rem;
    }
}

/* オーバーレイ（モバイル用） */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.sidebar-overlay.show {
    display: block;
}

/* 既存のスタイル調整 */
.main_content {
    /* margin-top: 10px; */
}

/* ログインユーザー情報 */
.sidebar-user {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.15);
    margin-top: auto;
}

.sidebar-username {
    display: block;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    width: 100%;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    color: rgba(255,255,255,0.8);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* 公開記事レイアウト（ログイン不要） */
.public-header {
    background: #2c3e50;
    color: #fff;
    padding: 12px 0;
    margin-bottom: 24px;
}
.public-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.public-header-title {
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}
.public-header-title:hover {
    color: #ecf0f1;
}
.public-main {
    min-height: 50vh;
}
.post-body {
    white-space: pre-wrap;
    word-break: break-word;
}

/* ツイート画像モーダル */
.tweet-media-thumb {
    cursor: pointer;
    display: block;
}
.tweet-media-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.tweet-media-modal.is-open {
    display: flex;
}
.tweet-media-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}
.tweet-media-modal-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 95vw;
    max-height: 95vh;
    z-index: 1;
}
.tweet-media-modal-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 85vh;
}
.tweet-media-modal-content img {
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    user-select: none;
    -webkit-user-drag: none;
}
.tweet-media-modal-prev,
.tweet-media-modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.tweet-media-modal-prev:hover,
.tweet-media-modal-next:hover {
    background: rgba(255,255,255,0.4);
}
.tweet-media-modal-prev {
    left: 12px;
}
.tweet-media-modal-next {
    right: 12px;
}
.tweet-media-modal-prev.is-hidden,
.tweet-media-modal-next.is-hidden {
    display: none;
}
.tweet-media-modal-counter {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.9);
    font-size: 14px;
}
.tweet-media-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}
.tweet-media-modal-close:hover {
    background: rgba(255,255,255,0.3);
}
.tweet-text a {
    word-break: break-all;
}

/* ===== 共通コンポーネント ===== */

/* スピナー */
.c-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    animation: c-spin 0.8s linear infinite;
}
@keyframes c-spin { to { transform: rotate(360deg); } }

/* バッジ */
.c-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.6;
}
.c-badge-success { background: #d1fae5; color: #065f46; }
.c-badge-danger  { background: #fee2e2; color: #991b1b; }
.c-badge-warning { background: #fef3c7; color: #92400e; }
.c-badge-info    { background: #dbeafe; color: #1e40af; }
.c-badge-gray    { background: #f3f4f6; color: #374151; }

/* ボタン */
.c-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.c-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.c-btn-primary { background: #6366f1; color: #fff; }
.c-btn-primary:hover:not(:disabled) { background: #4f46e5; }
.c-btn-danger  { background: #ef4444; color: #fff; }
.c-btn-danger:hover:not(:disabled) { background: #dc2626; }
.c-btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.c-btn-secondary:hover:not(:disabled) { background: #e5e7eb; }
.c-btn-sm { padding: 4px 12px; font-size: 0.8rem; }

/* カード */
.c-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    transition: box-shadow 0.2s, transform 0.15s;
}
.c-card-hover:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transform: translateY(-2px);
}

/* タブ */
.c-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}
.c-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-weight: 600;
    cursor: pointer;
    color: #6b7280;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}
.c-tab:hover { color: #374151; }
.c-tab.active { color: #6366f1; border-bottom-color: #6366f1; }

/* フォームコントロール */
.c-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}
.c-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* セクションタイトル */
.c-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 16px;
    padding-left: 12px;
    border-left: 4px solid #6366f1;
}

/* テキストユーティリティ */
.c-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.c-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.c-text-positive { color: #059669; font-weight: 600; }
.c-text-negative { color: #dc2626; font-weight: 600; }
.c-text-muted    { color: #6b7280; }
.c-text-sm       { font-size: 0.8rem; }

/* レイアウトユーティリティ */
.c-flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.c-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* グリッド */
.c-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
@media (max-width: 768px) {
    .c-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
}

/* モーダル */
.c-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
}
.c-modal-overlay.is-open { display: flex; }
.c-modal-content {
    position: relative;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

/* 空状態 */
.c-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 0.9rem;
}

/* プログレスバー */
.c-progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}
.c-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transition: width 0.3s;
}

/* Laravel ページネーション: デフォルト（Tailwind）ビューは SVG が巨大化するため pagination::bootstrap-5 と併用 */
.paginator-bootstrap nav .small.text-muted {
    display: none;
}
.paginator-bootstrap nav .d-none.flex-sm-fill.d-sm-flex.align-items-sm-center {
    justify-content: center !important;
}
.paginator-bootstrap .pagination {
    margin-bottom: 0;
    flex-wrap: wrap;
    justify-content: center;
}
.paginator-bootstrap .page-link {
    color: #374151;
    border-color: #e5e7eb;
}
.paginator-bootstrap .page-item.active .page-link {
    background: #1f2937;
    border-color: #1f2937;
    color: #fff;
}
.paginator-bootstrap .page-link:hover {
    color: #111827;
    background: #f3f4f6;
}
.paginator-bootstrap .page-item.disabled .page-link {
    color: #d1d5db;
}
