/* ===== 基本 ===== */
body {
    /* Windows標準フォントの Meiryo を優先。
       Meiryoが無い環境 (Mac/iOS/Android/Linux) ではフォールバックで自然な日本語フォントを使う:
         - -apple-system / "Hiragino Sans"  → macOS / iOS
         - "Segoe UI"                       → Windows英字
         - "Yu Gothic"                      → Windows 8.1+ 標準和文
         - "Noto Sans JP" / sans-serif      → Linux / その他 */
    font-family: "Meiryo", -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
    margin: 0;
    background: #f4f5f7;
}

/* Bootstrap は input/select/button/textarea に独自の font-family を当てているため、
   body のフォントを継承させてアプリ全体のフォントを統一する。 */
input, select, button, textarea, optgroup {
    font-family: inherit;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 上部バー ===== */
.app-topbar {
    height: 52px;
    background: #212529;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.app-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    margin-left: 4px;
}
.app-brand:hover { color: #fff; text-decoration: none; }

/* ハンバーガーボタン (三点リーダー風) */
.btn-hamburger {
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 0;
    margin-right: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-hamburger:hover { background: rgba(255,255,255,0.1); }
.btn-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}
body.sidebar-open .btn-hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.sidebar-open .btn-hamburger span:nth-child(2) { opacity: 0; }
body.sidebar-open .btn-hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ===== サイドバー ===== */
.app-sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 240px;
    background: #fff;
    border-right: 1px solid #dee2e6;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
    overflow-y: auto;
}
body.sidebar-open .app-sidebar { transform: translateX(0); }

.sidebar-nav {
    padding: 8px 0;
}

.side-link {
    display: block;
    padding: 10px 16px 10px 20px;
    color: #333;
    text-decoration: none;
    border-left: 3px solid transparent;
    font-size: 14px;
    transition: background 0.15s, border-color 0.15s;
}
.side-link:hover {
    background: #f0f2f5;
    color: #333;
    text-decoration: none;
}
.side-link.active {
    background: #e7f1ff;
    color: #0d6efd;
    border-left-color: #0d6efd;
    font-weight: 600;
}
.side-link.side-admin.active {
    background: #fff3cd;
    color: #997404;
    border-left-color: #ffc107;
}

.side-separator {
    padding: 10px 16px 4px;
    margin-top: 6px;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* オーバーレイ (モバイルで背景クリック閉じ用) */
.sidebar-overlay {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 15;
    display: none;
}
body.sidebar-open .sidebar-overlay { display: block; }

/* 広い画面ではサイドバー開いている時、メインを左マージン分押し下げる */
@media (min-width: 992px) {
    body.sidebar-open .sidebar-overlay { display: none; }
    body.sidebar-open .app-main { margin-left: 240px; transition: margin-left 0.2s ease; }
}

/* ===== メインコンテンツ ===== */
.app-main {
    flex: 1;
    padding: 16px 20px;
    transition: margin-left 0.2s ease;
}

/* ===== 既存のログビュー/テーブル調整 ===== */
#logView {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: Consolas, monospace;
}
#logView div { white-space: pre-wrap; word-break: break-all; }
.table-sm input.form-control-sm { font-family: Consolas, monospace; font-size: 12px; }

/* ===== フッター ===== */
.app-footer {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 12px 20px;
    transition: margin-left 0.2s ease;
}
.app-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.app-footer-link {
    color: #6c757d;
    text-decoration: none;
    font-size: 0.875rem;
}
.app-footer-link:hover { color: #0d6efd; text-decoration: underline; }

/* サイドバーが開いている時はフッターも追従 (デスクトップのみ) */
@media (min-width: 992px) {
    body.sidebar-open .app-footer { margin-left: 240px; }
}
