/* ============================================
   LAYOUT.CSS - 2カラムレイアウト、サイドバー
   ============================================ */

/* 2カラムレイアウト（メインページ用） */
.two-column-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
}

.main-sidebar {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

/* サイドバープロフィールセクション（2段構造） */
.sidebar-profile-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px;
    margin: -16px -16px 12px -16px;
    background: #1C1C1C;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* 1段目: アイコン + 名前・自己紹介 */
.sidebar-profile-row1 {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
}

/* 2段目: フォローボタン + SNSボタン */
.sidebar-profile-row2 {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.sidebar-follow-button-wrapper {
    width: 67px;
    flex-shrink: 0;
}

.sidebar-follow-btn {
    width: 100%;
    height: 22px;
    padding: 0;
    font-size: 11px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #22c55e;
    color: white;
}

.sidebar-follow-btn:hover {
    background: #16a34a;
}

.sidebar-follow-btn.following {
    background: #ef4444;
    color: white;
}

.sidebar-follow-btn.following:hover {
    background: #dc2626;
}

.sidebar-profile-icon img {
    display: block;
    width: 67px;
    height: 67px;
    border-radius: 4px;
    object-fit: cover;
    border: none;
    flex-shrink: 0;
}

.sidebar-profile-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidebar-profile-name {
    font-size: 14px;
    font-weight: 600;
    color: white;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: underline;
    margin: 0;
}

/* ホバー時にユーザー名全文表示 */
.sidebar-profile-name:hover {
    white-space: normal;
    overflow: visible;
}

.sidebar-profile-bio {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
    white-space: pre-line;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* ホバー時に全文表示 */
.sidebar-profile-bio:hover {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

.sidebar-profile-follows {
    display: flex;
    gap: 10px;
    margin: 0;
    justify-content: center;
}

.sidebar-follow-link {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: white;
    transition: all 0.2s ease;
    font-size: 11px;
}

.sidebar-follow-link:hover {
    text-decoration: underline;
}

.sidebar-follow-link .follow-count {
    font-weight: 700;
}

.sidebar-follow-link .follow-label {
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-profile-links {
    display: flex;
    flex: 1;
    gap: 3px;
    margin: 0;
}

.sidebar-sns-link {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 22px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.sidebar-sns-link:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* SNS別の色 */
.sidebar-sns-youtube {
    background: #ff0000;
    border-color: #ff0000;
}

.sidebar-sns-youtube:hover {
    background: #cc0000;
    border-color: #cc0000;
}

.sidebar-sns-instagram {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    border-color: #dc2743;
}

.sidebar-sns-instagram:hover {
    background: linear-gradient(45deg, #d98429, #cc5c35, #c4233c, #b31f5b, #a8157a);
    border-color: #c4233c;
}

.sidebar-sns-homepage {
    background: #10b981;
    border-color: #10b981;
}

.sidebar-sns-homepage:hover {
    background: #059669;
    border-color: #059669;
}

/* サイドバーユーザーセクション（モバイル専用） */
.sidebar-user-section {
    display: none; /* PC表示では非表示 */
    background: #1C1C1C;
    border-radius: 0;
    padding: 16px;
    margin: 0 0 16px 0; /* 上マージンなし */
    flex-direction: column;
    gap: 12px;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 16px;
    font-weight: 500;
}

.sidebar-user-icon {
    font-size: 24px;
}

.sidebar-user-name {
    color: #fff;
}

.sidebar-user-number {
    color: #888;
    font-size: 14px;
    font-weight: 400;
}

.sidebar-logout-link {
    display: block;
    padding: 10px 16px;
    background: #333;
    color: #ccc;
    text-decoration: none;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.sidebar-logout-link:hover {
    background: #444;
    color: #fff;
}

.sidebar-login-link {
    display: block;
    padding: 12px 16px;
    background: #3b82f6;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s;
}

.sidebar-login-link:hover {
    background: #2563eb;
}

.sidebar-debug-badge {
    display: block;
    padding: 8px 16px;
    background: #f39c12;
    color: white;
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu-item {
    margin-bottom: 4px;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--card-radius);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar-menu-item a:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.sidebar-menu-item.active a {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.sidebar-menu-item .menu-icon {
    font-size: 20px;
}

.sidebar-menu-item .menu-text {
    font-size: 16px;
}

/* サイドバー未読バッジ */
.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 8px;
    background: var(--loss, #e53e3e);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
}

/* サイドバー区切り線 */
.sidebar-divider {
    height: 2px;
    background: var(--border);
    margin: 8px 12px;
    list-style: none;
}

/* グループヘッダー（実現損益など） */
.menu-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text) !important;
    font-size: 16px;
    font-weight: 500;
    background: transparent !important;
    box-shadow: none !important;
    text-decoration: none;
}

.menu-group-header:hover {
    background: var(--hover-bg) !important;
    color: var(--text) !important;
}

/* 開いているセクションのヘッダー：薄い青、角丸 */
.sidebar-menu-item.has-submenu.active > .menu-group-header {
    background: var(--primary) !important;
    color: white !important;
    border-radius: var(--card-radius);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.menu-group-header .menu-icon {
    font-size: 20px;
}

.menu-group-header .menu-text {
    font-size: 16px;
}

/* サブメニュー */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-submenu.open {
    max-height: 500px;
    padding-bottom: 8px;
}

.sidebar-submenu-item {
    margin: 2px 8px;
}

.sidebar-submenu-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: #1e293b !important;
    font-size: 14px;
    font-weight: 500;
    border-radius: 0;
    transition: all 0.2s ease;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

[data-theme="dark"] .sidebar-submenu-item a {
    color: #e2e8f0 !important;
}

.sidebar-submenu-item a .submenu-icon {
    font-size: 16px;
}

.sidebar-submenu-item a:hover {
    background: var(--hover-bg) !important;
}

/* アクティブなサブメニュー項目：少し濃い薄青背景 */
.sidebar-submenu-item.active a {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #1e40af !important;
    border-radius: var(--card-radius);
    box-shadow: none !important;
    border: none !important;
    font-weight: 600;
}

[data-theme="dark"] .sidebar-submenu-item.active a {
    background: rgba(59, 130, 246, 0.25) !important;
    color: #60a5fa !important;
}

/* プライバシーロックアイコン（非公開表示） */
.sidebar-submenu-item a > span:last-child {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.privacy-lock {
    font-size: 12px;
    opacity: 0.7;
}

/* has-submenuのスタイル調整 */
.sidebar-menu-item.has-submenu {
    margin-bottom: 8px;
    background: transparent;
    border-radius: var(--card-radius);
    overflow: hidden;
}

.sidebar-menu-item.has-submenu.active {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .sidebar-menu-item.has-submenu {
    background: transparent;
}

[data-theme="dark"] .sidebar-menu-item.has-submenu.active {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

/* ダークモード時の「自分のHOME」ボタン */
[data-theme="dark"] .sidebar-menu-item > a[style*="background: #f0f0f0"] {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

.main-content-area {
    min-width: 0;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .two-column-layout {
        flex-direction: column;
    }

    .main-sidebar {
        width: 100%;
        position: static;
        margin-bottom: 16px;
    }

    .sidebar-menu {
        display: flex;
        overflow-x: auto;
        gap: 4px;
    }

    .sidebar-menu-item {
        margin-bottom: 0;
        flex-shrink: 0;
    }
}

/* ============================================
   モバイル用ユーザープロフィールカード
   ============================================ */

/* PC時は非表示 */
.mobile-user-profile-card {
    display: none;
}

/* モバイル時のみ表示 */
@media (max-width: 768px) {
    .mobile-user-profile-card {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 12px 16px;
        margin: 10px 0 10px 0;
        background: #1C1C1C;
        border-radius: var(--card-radius);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    }

    .mobile-profile-row1 {
        display: flex;
        gap: 12px;
        align-items: flex-start;
    }

    .mobile-profile-icon img {
        display: block;
        width: 74px;
        height: 74px;
        border-radius: 6px;
        object-fit: cover;
        border: none;
        flex-shrink: 0;
    }

    .mobile-profile-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .mobile-profile-name {
        font-size: 15px;
        font-weight: 600;
        color: white;
        line-height: 1.4;
        text-decoration: underline;
    }

    .mobile-profile-bio {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.85);
        line-height: 1.4;
        white-space: pre-line;
        word-break: break-word;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-profile-follows {
        display: flex;
        gap: 12px;
        margin-top: 4px;
    }

    .mobile-follow-link {
        display: flex;
        align-items: center;
        gap: 3px;
        color: white;
        text-decoration: none;
        font-size: 11px;
    }

    .mobile-follow-link .follow-count {
        font-weight: 700;
    }

    .mobile-follow-link .follow-label {
        font-weight: 400;
        color: rgba(255, 255, 255, 0.7);
    }

    .mobile-profile-row2 {
        display: flex;
        gap: 3px;
        align-items: center;
    }

    .mobile-follow-button-wrapper {
        width: 74px;
        flex-shrink: 0;
    }

    .mobile-follow-btn {
        width: 100%;
        height: 22px;
        padding: 0;
        border-radius: 4px;
        border: none;
        font-size: 11px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        background: #22c55e;
        color: white;
    }

    .mobile-follow-btn:hover {
        background: #16a34a;
    }

    .mobile-follow-btn.following {
        background: #ef4444;
    }

    .mobile-follow-btn.following:hover {
        background: #dc2626;
    }

    .mobile-profile-links {
        display: flex;
        gap: 3px;
        flex: 1;
    }

    .mobile-sns-link {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 22px;
        border-radius: 4px;
        background: rgba(255, 255, 255, 0.2);
        color: white;
        transition: all 0.2s ease;
        border: 1px solid rgba(255, 255, 255, 0.3);
    }

    .mobile-sns-link:hover {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
    }

    .mobile-sns-link.sns-youtube {
        background: #ff0000;
        border-color: #ff0000;
    }

    .mobile-sns-link.sns-youtube:hover {
        background: #cc0000;
        border-color: #cc0000;
    }

    .mobile-sns-link.sns-instagram {
        background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
        border-color: #dc2743;
    }

    .mobile-sns-link.sns-instagram:hover {
        background: linear-gradient(45deg, #d98429, #cc5c35, #c4233c, #b31f5b, #a8157a);
        border-color: #c4233c;
    }

    .mobile-sns-link.sns-homepage {
        background: #10b981;
        border-color: #10b981;
    }

    .mobile-sns-link.sns-homepage:hover {
        background: #059669;
        border-color: #059669;
    }
}