/* モダンサイドバーコンポーネント - 最適化版 */

/* =====================================
   設定変数
   ===================================== */
:root {
    /* サイズ設定 */
    --sidebar-width: 360px;
    --header-height: 64px;
    --sidebar-header-min-height: 120px;
    
    /* カラー設定 */
    --sidebar-bg: #ffffff;
    --sidebar-border: #e5e7eb;
    --sidebar-text: #000000;
    --sidebar-text-active: #4f46e5;
    --sidebar-hover-bg: #f9fafb;
    
    /* スペーシング */
    --sidebar-padding: 20px;
    --nav-item-gap: 6px;
    --nav-item-padding: 12px 14px;
    
    /* アニメーション */
    --transition-speed: 0.32s;
    --transition-quick: 0.25s;
}

/* =====================================
   メインコンテナ
   ===================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.08), 0 0 40px rgba(0, 0, 0, 0.04);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-110%);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    z-index: 100;
    overflow: hidden;
}

.sidebar--open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.12), 0 0 50px rgba(0, 0, 0, 0.06);
}

/* ヘッダーなしの場合 */
.sidebar.no-header {
    top: 0;
}

/* =====================================
   ヘッダー部分
   ===================================== */
.sidebar-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    padding: 18px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    min-height: var(--sidebar-header-min-height);
}

/* 装飾用の円 */
.sidebar-header::before,
.sidebar-header::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-header::before {
    width: 130px;
    height: 130px;
    top: -45px;
    right: -40px;
}

.sidebar-header::after {
    width: 90px;
    height: 90px;
    left: -30px;
    bottom: -35px;
}

/* 閉じるボタン */
.sidebar-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-quick) ease, transform var(--transition-quick) ease;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.06);
}

/* ロゴコンテナ */
.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.logo-box {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.logo-icon {
    width: 22px;
    height: 22px;
}

/* ブランド情報 */
.brand-info h2 {
    color: #ffffff;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0;
}

.brand-info p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    font-weight: 500;
    margin: 2px 0 0;
}

/* バージョン情報 */
.version-info {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    position: relative;
    z-index: 1;
}

.version-info p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
    font-weight: 500;
    margin: 0;
    letter-spacing: 0.08em;
}

/* =====================================
   ナビゲーション部分
   ===================================== */
.sidebar-nav {
    flex: 1;
    padding: var(--sidebar-padding);
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--sidebar-bg);
    min-height: 0;
    max-height: calc(100vh - var(--sidebar-header-min-height));
}

/* スクロールバー */
.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* ナビゲーションアイテム */
.nav-items {
    display: flex;
    flex-direction: column;
    gap: var(--nav-item-gap);
}

.nav-item {
    position: relative;
    border-radius: 16px;
    transition: all 0.3s ease;
}

/* ナビゲーションリンク */
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--nav-item-padding);
    text-decoration: none;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 13px;
    border-radius: 16px;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
}

/* ナビゲーションアイコン */
.nav-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.nav-icon {
    width: 18px;
    height: 18px;
}

.nav-item-text {
    flex: 1;
    letter-spacing: 0.01em;
    font-size: 13px;
}

.nav-indicator {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: transparent;
    transition: all 0.3s ease;
}

/* =====================================
   状態変化
   ===================================== */

/* ホバー状態 */
.nav-item:hover:not(.nav-item--disabled):not(.active) .nav-link {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text);
}

.nav-item:hover .nav-icon-wrapper {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

/* アクティブ状態 */
.nav-item.active .nav-link {
    background: linear-gradient(135deg, #eef2ff 0%, #fce7f3 50%, #dbeafe 100%);
    color: var(--sidebar-text-active);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 28px;
    background: linear-gradient(180deg, #4f46e5, #a855f7, #ec4899);
    border-radius: 0 4px 4px 0;
}

.nav-item.active .nav-icon-wrapper {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    color: white;
}

.nav-item.active .nav-indicator {
    background: #6366f1;
}

/* 無効状態 */
.nav-item--disabled {
    opacity: 1;
    pointer-events: none;
}

/* 外部リンク */
.nav-item--external .nav-link::after {
    content: "↗";
    margin-left: auto;
    font-size: 10px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.nav-item--external:hover .nav-link::after {
    opacity: 1;
}

/* 区切り線 */
.divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.1), rgba(148, 163, 184, 0.6), rgba(148, 163, 184, 0.1));
    margin: 3px 4px;
}

/* =====================================
   グラデーションバリエーション
   ===================================== */
.nav-items > .nav-item:nth-child(1).active .nav-icon-wrapper { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.nav-items > .nav-item:nth-child(2).active .nav-icon-wrapper { background: linear-gradient(135deg, #a855f7, #ec4899); }
.nav-items > .nav-item:nth-child(3).active .nav-icon-wrapper { background: linear-gradient(135deg, #10b981, #14b8a6); }
.nav-items > .nav-item:nth-child(4).active .nav-icon-wrapper { background: linear-gradient(135deg, #f97316, #ef4444); }
.nav-items > .nav-item:nth-child(5).active .nav-icon-wrapper { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.nav-items > .nav-item:nth-child(6).active .nav-icon-wrapper { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.nav-items > .nav-item:nth-child(7).active .nav-icon-wrapper { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.nav-items > .nav-item:nth-child(8).active .nav-icon-wrapper { background: linear-gradient(135deg, #8b5cf6, #a855f7); }
.nav-items > .nav-item:nth-child(9).active .nav-icon-wrapper { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.nav-items > .nav-item:nth-child(10).active .nav-icon-wrapper { background: linear-gradient(135deg, #14b8a6, #059669); }
.nav-items > .nav-item:last-child.active .nav-icon-wrapper { background: linear-gradient(135deg, #6b7280, #4b5563); }

/* =====================================
   オーバーレイ
   ===================================== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-quick) ease;
    z-index: 90;
}

.sidebar-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}

/* =====================================
   レスポンシブ対応
   ===================================== */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-105%);
    }
}

@media (min-width: 1024px) {
    .sidebar {
        position: fixed;
        transform: translateX(0) !important;
        z-index: 40;
    }
    .sidebar-close {
        display: none;
    }
    .sidebar-overlay {
        display: none !important;
    }
}

/* =====================================
   レイアウト調整
   ===================================== */
.page-with-header {
    padding-top: var(--header-height);
}

.dashboard-container,
.product-dashboard {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    position: relative;
    /* padding-top削除 - page-with-headerクラスで処理 */
}

.dashboard-container .main-content,
.product-dashboard .product-dashboard__stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f9fafb;
    overflow-x: hidden; /* 横スクロールを抑止 */
}

@media (min-width: 1024px) {
    .dashboard-container .main-content,
    .product-dashboard .product-dashboard__stage {
        margin-left: var(--sidebar-width);
    }
}

@media (max-width: 1023px) {
    .dashboard-container,
    .product-dashboard {
        flex-direction: column;
    }
    .dashboard-container .main-content,
    .product-dashboard .product-dashboard__stage {
        margin-left: 0;
    }
}
