/* ギャラリーレイアウト */
.gallery-layout {
    display: flex;
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* サイドバー（PC用） */
.gallery-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    flex-shrink: 0;
}

.sidebar-header h3 {
    color: #1a1a1a;
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #E5E7EB;
}

.tag-filter-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.filter-header {
    padding-bottom: 10px;
    border-bottom: 1px solid #E5E7EB;
}

.filter-header-mobile {
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 10px;
}

.tag-types-vertical {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.tag-type-section {
    border-bottom: 1px solid #E5E7EB;
    padding-bottom: 15px;
}

.tag-type-section:last-child {
    border-bottom: none;
}

.tag-type-title {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 12px;
}

.tag-type-title.collapsible {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.tag-type-title.collapsible:hover {
    background: #f8f9fa;
}

.collapse-icon {
    font-size: 10px;
    transition: transform 0.2s;
    display: inline-block;
    min-width: 12px;
}

.collapsible-content {
    max-height: none;
    overflow: visible;
    transition: max-height 0.3s ease-out;
}

.collapsible-content.collapsed {
    max-height: 0;
    overflow: hidden;
}

.collapsible-mobile {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapsible-content-mobile {
    max-height: 300px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.collapsible-content-mobile.collapsed {
    max-height: 0;
}

.tag-list-vertical {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    column-gap: 10px;
}

.tag-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.tag-checkbox-item:hover {
    background: #f8f9fa;
}

.tag-checkbox-item input[type="checkbox"] {
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

.tag-checkbox-item .tag-badge {
    font-size: 12px;
    padding: 4px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.filter-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    padding-top: 15px;
    border-top: 2px solid #E5E7EB;
    margin-top: 15px;
}

.filter-buttons .btn {
    margin: 0;
    padding: 8px 12px;
    font-size: 14px;
}

.btn-block {
    width: 80%;
    text-align: center;
}

/* ページタイトルエリア */
.page-title-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
}

.page-title-wrapper h1 {
    margin: 0;
}

/* 右上ナビゲーション */
.top-nav {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.top-nav-link {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.95);
    color: #043e80;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.top-nav-link:hover {
    background: #043e80;
    color: white;
    border-color: #043e80;
}

/* メインコンテンツエリア */
.gallery-main {
    flex: 1;
    min-width: 0;
}

/* ヘッダー */
.gallery-header {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* SP用タグフィルター（デフォルトは非表示） */
.mobile-tag-filter {
    display: none;
    margin-bottom: 15px;
}

.tag-filter-toggle {
    width: 100%;
    padding: 12px 15px;
    background: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.tag-filter-toggle:hover {
    background: #e9ecef;
    border-color: #00fff7;
}

.toggle-icon {
    font-size: 12px;
    transition: transform 0.3s;
}

.tag-filter-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    margin-top: -8px;
    padding: 0 15px;
}

.tag-filter-dropdown.open {
    max-height: 600px;
    overflow-y: auto;
    padding: 15px;
    border: 2px solid #ddd;
    border-top: none;
}

.tag-types-mobile {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tag-type-section-mobile h4 {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
}

.tag-list-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-checkbox-mobile {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.filter-buttons-mobile {
    display: flex;
    gap: 10px;
}

.filter-buttons-mobile .btn {
    flex: 1;
}

/* アクションボタン */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

/* ギャラリー全体のスタイル（後方互換性のため残す） */
.gallery-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* オーバーレイ（処理中表示） */
#overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
}

.overlay-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px 50px;
    border-radius: 10px;
    font-size: 20px;
    color: #333;
}

/* ボタンスタイル */
.btn {
    display: inline-block;
    padding: 10px 20px;
    margin: 5px;
    background: #f5b500;
    color: #043e80;
    text-decoration: none;
    border: 2px solid #043e80;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.btn:hover {
    background: #043e80;
    color: #f5b500;
}

.btn-primary {
    background: #00fff7;
    color: #043e80;
}

.btn-primary:hover {
    background: #043e80;
    color: #00fff7;
}

.btn-secondary {
    background: #6B7280;
    color: white;
}

.btn-secondary:hover {
    background: #374151;
}

.btn-danger {
    background: #EF4444;
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 14px;
}

.back-button {
    margin: 20px 0;
    text-align: center;
}

/* タグフィルター */
.tag-filter {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tag-filter h3 {
    color: #1a1a1a;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: bold;
}

.tag-types {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.tag-type-group {
    flex: 1;
    min-width: 200px;
}

.tag-type-group h4 {
    font-size: 16px;
    margin-bottom: 10px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-checkbox {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.tag-checkbox input[type="checkbox"] {
    margin-right: 5px;
}

.tag-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

a.tag-badge-link {
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: white;
}

a.tag-badge-link:hover {
    opacity: 0.8;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    color: white;
}

.filter-controls {
    margin-top: 15px;
    text-align: center;
}

.filter-controls label {
    margin: 0 10px;
    color: #f5b500;
}

/* 投稿グリッド */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin: 20px 0;
}

/* 埋め込みプレースホルダー（Lazy Load用） */
.embed-placeholder {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
}

.embed-placeholder p {
    color: #666;
    margin: 15px 0;
    font-size: 14px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #00fff7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ページネーション */
.pagination-wrapper {
    margin: 40px 0 20px;
    display: flex;
    justify-content: center;
}

.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 8px;
    align-items: center;
}

.page-item {
    margin: 0;
}

.page-link {
    display: block;
    padding: 8px 14px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    min-width: 40px;
    text-align: center;
}

.page-link:hover {
    background: #f8f9fa;
    border-color: #4CAF50;
    color: #4CAF50;
}

.page-item.active .page-link {
    background: #4CAF50;
    border-color: #4CAF50;
    color: white;
    cursor: default;
}

.page-item.active .page-link:hover {
    background: #4CAF50;
    border-color: #4CAF50;
    color: white;
}

.post-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
}

/* 超小さい編集ボタン */
.edit-btn-mini {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
    transition: all 0.2s;
    opacity: 0.7;
}

.edit-btn-mini:hover {
    opacity: 1;
    transform: scale(1.1);
    background: #00fff7;
}

.post-embed {
    padding: 15px;
    background: #f8f9fa;
}

.post-info {
    padding: 20px;
    background: white;
}

.post-info h3 {
    color: #1a1a1a;
    font-size: 20px;
    margin-bottom: 12px;
    font-weight: bold;
    line-height: 1.4;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 10px 0;
}

.no-posts {
    text-align: center;
    color: #f5b500;
    font-size: 18px;
    padding: 40px;
}

/* 投稿詳細 */
.post-detail {
    background: white;
    padding: 40px;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.post-detail h2 {
    color: #1a1a1a;
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: bold;
    line-height: 1.3;
}

.post-description {
    color: #333;
    margin: 20px 0;
    line-height: 1.8;
    font-size: 16px;
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #00fff7;
}

.post-embed-large {
    margin: 30px 0;
    text-align: center;
}

.post-meta {
    color: #666;
    font-size: 14px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #E5E7EB;
}

.post-meta p {
    margin: 8px 0;
}

/* フォーム */
.post-form-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    color: #1a1a1a;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 16px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group input[type="url"]:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #00fff7;
    box-shadow: 0 0 0 3px rgba(0, 255, 247, 0.1);
}

.form-group small {
    display: block;
    color: #666;
    font-size: 14px;
    margin-top: 8px;
}

.tag-selection {
    background: #f9fafb;
    padding: 15px;
    border-radius: 5px;
}

.tag-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

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

.preview-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #E5E7EB;
}

.preview-section h3 {
    color: #043e80;
    margin-bottom: 15px;
}

/* タグ管理 */
.tag-management {
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 10px;
    margin: 20px 0;
}

.management-section {
    margin-bottom: 40px;
}

.management-section h2 {
    color: #043e80;
    margin-bottom: 20px;
}

.form-container {
    background: #f9fafb;
    padding: 20px;
    border-radius: 5px;
    margin: 20px 0;
}

.form-container h3 {
    color: #043e80;
    margin-bottom: 15px;
}

.tag-types-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tag-type-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 5px;
}

.tag-type-badge {
    padding: 8px 15px;
    border-radius: 5px;
    color: white;
    font-weight: bold;
}

.tag-type-order {
    color: #6B7280;
    font-size: 14px;
}

.tag-type-actions {
    margin-left: auto;
    display: flex;
    gap: 5px;
}

.tags-list {
    margin-top: 20px;
}

.tag-group {
    margin-bottom: 20px;
}

.tag-group h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

.tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #f9fafb;
    padding: 5px 10px;
    border-radius: 5px;
}

.tag-actions {
    display: flex;
    gap: 3px;
}

/* X投稿フォールバック表示 */
.x-post-fallback {
    background: #f9fafb;
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    color: #6B7280;
}

.x-post-fallback p {
    margin-bottom: 15px;
    font-size: 16px;
}

/* X投稿の埋め込みカスタマイズ */
/* 埋め込み全体を見やすく表示 */
.twitter-tweet {
    max-width: 550px !important;
    margin: 20px auto !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    padding: 0 !important;
}

/* 埋め込みiframe */
.twitter-tweet iframe {
    margin: 0 auto !important;
    border-radius: 12px !important;
}

/* 画像が確実に表示されるように */
.twitter-tweet img,
.twitter-tweet video,
.twitter-tweet [data-tweet-img] {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
}

/* メディアコンテナは表示 */
.twitter-tweet .media,
.twitter-tweet [class*="media"] {
    display: block !important;
}

/* レスポンシブ対応 */
@media (max-width: 992px) {
    /* タブレット以下 */
    .gallery-layout {
        flex-direction: column;
    }

    .gallery-sidebar {
        display: none;
    }

    .mobile-tag-filter {
        display: block;
    }

    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    /* スマホ */
    .page-title-wrapper {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px 10px;
        gap: 10px;
    }

    .top-nav {
        flex-direction: row;
        gap: 8px;
        width: 100%;
        justify-content: flex-end;
    }

    .top-nav-link {
        font-size: 12px;
        padding: 5px 10px;
    }

    .gallery-layout {
        padding: 10px;
    }

    .gallery-header {
        padding: 15px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .posts-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .post-card {
        border-radius: 8px;
    }

    .tag-filter-dropdown.open {
        max-height: 500px;
    }

    h1 {
        font-size: 24px;
    }
}

@media (min-width: 993px) {
    /* PC */
    .gallery-sidebar {
        display: block;
    }

    .mobile-tag-filter {
        display: none !important;
    }
}
