/* ========================================
   リセット＆ベーススタイル
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --header-bg: #1e293b;
    --text-color: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --hover-bg: #f1f5f9;
    --active-bg: #dbeafe;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --sidebar-width: 380px;
    --header-height: 100px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow-x: hidden;
}

/* ========================================
   ヘッダー
   ======================================== */
.header {
    background: linear-gradient(135deg, var(--header-bg) 0%, #334155 100%);
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    display: flex;
    align-items: center;
}

.header-content {
    max-width: 100%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
}

.logo-link {
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.logo-link:hover {
    transform: scale(1.05);
}

.site-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.header-text {
    flex: 1;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-title i {
    color: #60a5fa;
    font-size: 1.75rem;
}

.header-subtitle {
    font-size: 0.875rem;
    color: #cbd5e1;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.subtitle-text {
    color: #cbd5e1;
}

.mhlw-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: rgba(96, 165, 250, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 4px;
    color: #60a5fa;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: var(--transition);
}

.mhlw-link:hover {
    background: rgba(96, 165, 250, 0.25);
    border-color: #60a5fa;
    color: #93c5fd;
    transform: translateY(-1px);
}

.mhlw-link i {
    font-size: 0.7rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.full-text-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.full-text-btn:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.full-text-btn i {
    font-size: 1rem;
}

.provider-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.2);
    white-space: nowrap;
}

.provider-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.provider-link i {
    font-size: 0.875rem;
}

/* ========================================
   メインコンテナ
   ======================================== */
.container {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    position: relative;
}

/* ========================================
   サイドバー
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow: hidden;
    transition: var(--transition);
    z-index: 50;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: none;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background-color: var(--hover-bg);
    color: var(--text-color);
}

/* リサイズハンドル */
.resize-handle {
    width: 8px;
    background: var(--border-color);
    cursor: col-resize;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 49;
}

.resize-handle:hover {
    background: var(--primary-color);
}

.resize-handle.resizing {
    background: var(--primary-color);
}

.resize-handle-line {
    width: 2px;
    height: 60px;
    background: white;
    border-radius: 2px;
    pointer-events: none;
}

/* 目次ナビゲーション */
.toc-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.toc-loading {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.toc-loading i {
    font-size: 2rem;
    margin-bottom: 1rem;
    display: block;
}

/* 目次項目スタイル */
.toc-section {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #cbd5e1;
}

.toc-section-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: white;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    border: none;
    box-shadow: 0 2px 4px rgba(30, 58, 138, 0.3);
}

.toc-section-title:hover {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    box-shadow: 0 4px 8px rgba(30, 58, 138, 0.4);
    transform: translateY(-1px);
}

.toc-section-title i {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.toc-section-title.expanded i {
    transform: rotate(90deg);
}

.toc-subsection {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    display: none;
    padding-left: 1rem;
    border-left: 3px solid #3b82f6;
}

.toc-subsection.show {
    display: block;
}

.toc-subsection-title {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-color);
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 0.375rem;
    user-select: none;
    background: #f1f5f9;
    border-left: 3px solid #1e40af;
    margin-bottom: 0.25rem;
}

.toc-subsection-title:hover {
    background: #e0e7ff;
    color: #1e40af;
    border-left-color: #2563eb;
}

.toc-subsection-title i {
    font-size: 0.625rem;
    transition: transform 0.3s ease;
}

.toc-subsection-title.expanded i {
    transform: rotate(90deg);
}

.toc-items {
    margin-left: 1.5rem;
    margin-top: 0.25rem;
    display: none;
    padding-left: 1rem;
    border-left: 2px solid #94a3b8;
}

.toc-items.show {
    display: block;
}

.toc-item {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border-radius: 0.375rem;
    border-left: 3px solid transparent;
    margin-bottom: 0.125rem;
    position: relative;
    padding-left: 2rem;
}

.toc-item::before {
    content: '📄';
    position: absolute;
    left: 0.5rem;
    font-size: 0.875rem;
}

.toc-item:hover {
    background: #f1f5f9;
    color: #1e40af;
    border-left-color: #2563eb;
    transform: translateX(4px);
}

.toc-item.active {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
    border-left-color: #1e40af;
    box-shadow: 0 2px 4px rgba(30, 64, 175, 0.2);
}

/* ========================================
   メインコンテンツ
   ======================================== */
.main-content {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    position: relative;
    background: #ffffff;
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 45;
    gap: 0.5rem;
    align-items: center;
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.mobile-menu-btn i {
    margin-right: 0.5rem;
}

/* PDFビューア */
.pdf-viewer {
    background: white;
    min-height: 100vh;
    overflow: hidden;
}

/* ウェルカム画面 */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height));
    padding: 2rem;
}

.welcome-content {
    text-align: center;
    max-width: 800px;
}

.welcome-icon {
    font-size: 5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.welcome-content h2 {
    font-size: 2rem;
    color: var(--text-color);
    margin-bottom: 1rem;
    font-weight: 700;
}

.welcome-content > p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    margin-bottom: 2.5rem;
}

.welcome-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.info-card {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.info-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.info-card i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    display: block;
}

.info-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.info-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.provider-info {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.provider-info p {
    font-size: 1rem;
    color: var(--text-secondary);
}

.provider-info a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.provider-info a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ビューアボタン */
.viewer-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.875rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.viewer-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.viewer-btn i {
    font-size: 0.75rem;
}

/* オーバーレイ */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    backdrop-filter: blur(2px);
}

.overlay.active {
    display: block;
}

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

/* タブレット */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 320px;
    }

    .header-title {
        font-size: 1.25rem;
    }

    .header-title i {
        font-size: 1.5rem;
    }

    .site-logo {
        height: 50px;
    }

    .mhlw-link {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    .full-text-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.75rem;
    }

    .full-text-btn i {
        font-size: 0.875rem;
    }

    .provider-link {
        padding: 0.5rem 0.875rem;
        font-size: 0.75rem;
    }

    .provider-link i {
        font-size: 0.75rem;
    }

    .main-content {
        padding: 0;
    }
}

/* モバイル */
@media (max-width: 768px) {
    :root {
        --header-height: 80px;
    }

    .header {
        padding: 1rem 1.5rem;
    }

    .header-content {
        gap: 1rem;
    }

    .header-left {
        gap: 0.75rem;
    }

    .site-logo {
        height: 40px;
    }

    .header-text {
        min-width: 0;
    }

    .header-title {
        font-size: 1rem;
    }

    .header-title i {
        font-size: 1.125rem;
    }

    .header-subtitle {
        font-size: 0.7rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.375rem;
    }

    .subtitle-text {
        font-size: 0.7rem;
    }

    .mhlw-link {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }

    .mhlw-link i {
        font-size: 0.6rem;
    }

    .header-right {
        flex-direction: column;
        gap: 0.5rem;
    }

    .full-text-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.75rem;
        width: 100%;
        justify-content: center;
    }

    .full-text-btn span {
        display: inline;
    }

    .provider-link {
        display: none; /* モバイルでは特設サイトリンクを非表示 */
    }

    .resize-handle {
        display: none; /* モバイルではリサイズハンドルを非表示 */
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 85%;
        max-width: 360px;
        height: 100vh;
        z-index: 50;
        box-shadow: var(--shadow-lg);
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-header {
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .main-content {
        padding: 0;
        width: 100%;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .viewer-btn {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }

    .viewer-btn span {
        display: none;
    }

    .welcome-screen {
        padding: 2rem 1rem;
        min-height: 400px;
    }

    .welcome-content h2 {
        font-size: 1.5rem;
    }

    .welcome-content > p {
        font-size: 1rem;
    }

    .welcome-icon {
        font-size: 3.5rem;
    }

    .welcome-info {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .info-card {
        padding: 1.25rem;
    }
}

/* 小画面モバイル */
@media (max-width: 480px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .header-title {
        font-size: 1rem;
    }

    .header-subtitle {
        font-size: 0.7rem;
    }

    .search-input {
        font-size: 0.8125rem;
    }

    .mobile-menu-btn {
        bottom: 1rem;
        right: 1rem;
        padding: 0.875rem 1.25rem;
        font-size: 0.9375rem;
    }
}

/* ========================================
   スクロールバーのカスタマイズ
   ======================================== */
.toc-nav::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
    width: 8px;
}

.toc-nav::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.toc-nav::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.toc-nav::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========================================
   アニメーション
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toc-section,
.toc-item {
    animation: fadeIn 0.3s ease;
}

/* ========================================
   印刷スタイル
   ======================================== */
@media print {
    .sidebar,
    .mobile-menu-btn,
    .overlay {
        display: none;
    }

    .main-content {
        padding: 0;
    }

    .pdf-viewer {
        box-shadow: none;
    }
}
