/* ============================================
   リセット & ベーススタイル
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', 'Noto Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    overflow-y: hidden;
}

/* ============================================
   アプリケーションコンテナ
   ============================================ */

.app-container {
    display: flex;
    flex-direction: column;
    padding-top: 56px; /* ヘッダーの高さ分 */
}

/* ============================================
   ヘッダー
   ============================================ */

.header {
    background-color: #fff;
    color: white;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    border-bottom: solid 1px #999;
}

.header-content {
    height: 55px;
    margin: 0 auto;
    padding: 0 1.56rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    flex: 1;
    display: inline-flex;
    align-items: center;
}

.logo img {
    height: auto;
    display: block;
}

.language-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.language-switcher label {
    font-size: 0.9rem;
    font-weight: 500;
}

.language-switcher select {
    width: 131px;
    height: 22px;
    padding: 0 0.5em;
    border: none;
    border-radius: 3px;
    background-color: white;
    color: #a7a7a7;
    cursor: pointer;
    font-size: 0.9rem;
    border: 1px solid #a7a7a7;
}

/* サイドバートグルボタン */
.sidebar-toggle {
    display: none;
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0 0 0 0.5rem;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    border: 1px solid #a7a7a7;
}

.sidebar-toggle::before {
    content: '☰';
    display: block;
    color: #a3803a;
}

/* ============================================
   メインコンテナ（サイドバー + メインコンテンツ）
   ============================================ */

.main-container {
    display: flex;
    flex: 1;
}

/* ============================================
   サイドバー（メニュー）
   ============================================ */

.sidebar {
    width: 280px;
    background-color: #ffffff;
    border-right: 1px solid #d3d3d3;
    box-shadow: 1px 0 2px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    height: calc(100vh - 56px); /* ヘッダーの高さ分を引く */
}

.sidebar-nav {
    padding: 1rem 0.8rem;
}

.sidebar-section {
    margin-bottom: 1rem;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #2c3e50;
    padding: 0 1rem 0.8rem;
    border-bottom: 2px solid #e2e8fb;
    margin-bottom: 0.8rem;
    letter-spacing: 0.5px;
}

/* ============================================
   メニュー（第一階層）
   ============================================ */

.menu-list {
    list-style: none;
}

.menu-item {
    margin: 0;
}

.menu-item:not(:last-child) {
    border-bottom: solid 1px #d3d3d3;
}

.menu-item>a,
.menu-item>button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 0.8rem;
    color: #2c3e50;
    text-decoration: none;
    background: none;
    border: none;
    text-align: center;
    width: 100%;
    cursor: pointer;
    font-size: 0.95rem;
    gap: 0.5rem;
}

.menu-item>a:hover,
.menu-item>button:hover {
    background-color: rgba(247, 244, 235, 0.9);
}

.menu-item.active>a,
.menu-item.active>button {
    background-color: #fcf7f7;
    color: white;
    font-weight: 600;
}

/* メニューアイコンコンテナ（左側） */
.menu-icon-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* メニューアイコン */
.menu-item .menu-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.menu-item.active>a .menu-icon,
.menu-item.active>button .menu-icon {
    border: none;
}

/* 矢印アイコンコンテナ（第二階層がある場合） */
.menu-arrow-container {
    display: flex;
    width: 20px;
    height: 50px;
    align-items: center;
    justify-content: right;
}

/* 矢印アイコン（第二階層がある場合） */
.menu-arrow {
    width: 8px;
    object-fit: contain;
    flex-shrink: 0;
    margin-right: 5px;
}

.menu-arrow.rotated-right {
    transform: rotate(90deg);
}

.menu-arrow.rotated-down {
    transform: rotate(-90deg);
}

/* ============================================
   サブメニュー（第二階層）
   ============================================ */

.submenu {
    list-style: none;
    background-color: #fcf7f7;
    max-height: 0;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 4%;
    justify-content: left;
}

.submenu.open {
    max-height: 500px;
    border-top: solid 1px #d3d3d3;
    padding: calc(0.8rem + 2px) 0.8rem;
}

.submenu-item {
    flex: 0 1 auto;
    width: 22%;
}

.submenu-item-text {
    width: 48%;
}

.submenu-item .menu-icon {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 3px;
    box-shadow: 0px 0px 3px 0px #00000040;
}

.submenu-item .menu-text {
    width: 100%;
    height: auto;
    padding: 0.5em 0;
    text-align: center;
    object-fit: contain;
    border-radius: 3px;
    box-shadow: 0px 0px 3px 0px #00000040;
    background-color: white;
    color: #616161;
}

.submenu-item.active .menu-icon,
.submenu-item.active .menu-text {
    border: solid 2px #ba9343;
}

.submenu-item a {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0.9rem;
}

.submenu-item a:hover {
    background-color: #f8f6e8;
}

.submenu-item.active a {
    font-weight: 600;
}

/* ============================================
   メニュー補助要素
   ============================================ */

.menu-toggle {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    text-align: center;
    line-height: 20px;
    font-size: 0.8rem;
}

.menu-item>a .menu-toggle,
.menu-item>button .menu-toggle {
    display: inline-block;
}

.submenu.open~a .menu-toggle,
.submenu.open~button .menu-toggle {
    transform: rotate(180deg);
}

/* ============================================
   PDFダウンロード
   ============================================ */

.pdf-download {
    width: 98%;
    margin: auto;
}

.pdf-download a {
    display: inline-block;
    padding: 0.8rem 1rem;
    background-color: #ba9343;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    box-shadow: 0px 2px 4px 0px #00000040;
}

.pdf-link-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.pdf-link-content i {
    font-size: 1.2rem;
}

.pdf-download a:hover:not(:disabled) {
    background-color: #a0782a;
}

.pdf-download a:disabled,
.pdf-download a.disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

/* ============================================
   メインコンテンツエリア
   ============================================ */

.main-content {
    flex: 1;
    overflow-y: auto;
    background-color: white;
    height: calc(100vh - 56px); /* ヘッダーの高さ分を引く */
}

.page-title {
    font-size: 2em;
    font-weight: bold;
    color: #222;
    margin-bottom: 1em;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4em;
}

.page-title-main {
    line-height: 1.1;
}

.page-title-sub {
    font-size: 0.8em;
    line-height: 1.2;
}

.content-area {
    max-width: 1000px;
    margin: 0 auto;
    padding: 80px 40px;
}

.content-area:has(.tutorial-detail) {
    max-width: 1400px;
}

.content-area:has(.embroidery-body) {
    max-width: none;
}

@media (max-width: 1600px) {
    .content-area:has(.tutorial-detail) {
        max-width: 1000px;
    }
}

@media (max-width: 1200px) {
    .content-area {
        padding: 60px 20px;
    }
}

@media (max-width: 480px) {
    .content-area {
        padding: 50px 10px;
    }
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #7f8c8d;
    font-size: 1.1rem;
}

/* ============================================
   ユーティリティクラス
   ============================================ */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

/* ============================================
   スクロールバーカスタマイズ（Webkit）
   ============================================ */

.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
    background: #ecf0f1;
}

.sidebar::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* ============================================
   スクロールトップボタン
   ============================================ */

.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #ba9343;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 50;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    background-color: #a0782a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.scroll-to-top:active {
    transform: scale(0.95);
}

/* ============================================
   レスポンシブデザイン
   ============================================ */

/* モバイル版共通（768px以下） */
@media (max-width: 768px) {
    .app-container {
        padding-top: 56px; /* ヘッダーの高さ分 */
    }

    /* サイドバートグルボタンを表示 */
    .sidebar-toggle {
        display: block;
    }

    /* サイドバーはデフォルトで右側外に配置、開く時にスライドイン */
    .sidebar {
        position: fixed;
        right: -80%;
        top: 56px; /* ヘッダーの高さ分 */
        width: 80%;
        height: calc(100% - 56px); /* ヘッダーの高さ分を引く */
        max-height: none;
        display: block;
        z-index: 20;
        overflow-y: auto;
        transition: right 0.3s ease;
    }

    /* オーバーレイ背景 */
    .main-container::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100dvh;
        background-color: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 15;
        pointer-events: auto;
    }

    .sidebar.open {
        right: 0;
    }

    .main-container.open::before {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .main-content {
        height: calc(100dvh - 56px); /* ヘッダーの高さ分を引く */
    }

    .header-content {
        gap: 1rem;
    }

    .header-content {
        height: 55px;
    }

    .language-switcher select {
        width: 131px;
        height: 32px;
        border-radius: 4px;
    }
}

/* スマートフォン版（480px以下）- 追加の調整 */
@media (max-width: 480px) {
    .header-content {
        padding: 0 0.75rem;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    .sidebar-title {
        font-size: 0.8rem;
        padding: 0 0.75rem 0.6rem;
    }

    .menu-item>a,
    .menu-item>button {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
    }

    .submenu-item a {
        font-size: 0.85rem;
    }

    .menu-item .menu-icon {
        width: 70px;
        height: 70px;
    }

    .submenu-item .menu-icon {
        width: 100%;
        height: 100%;
    }

    .scroll-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

}