@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    --color-primary:      #07569e;
    --color-primary-dark: #041e49;
    --color-primary-light:#d3e3fd;
    --color-sidebar-bg:   #f0f4f9;
    --color-active-bg:    #d3e3fd;
    --color-border:       #e0e0e0;
    --color-text:         #333;
    --color-muted:        #777;
    --radius:             8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Noto Sans JP", sans-serif;
    background-color: #fff;
    color: var(--color-text);
    font-size: 15px;
}

a { text-decoration: none; color: inherit; }
a:hover { opacity: 0.7; }

/* =====================
   レイアウト
===================== */
.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* =====================
   サイドバー（PC）
===================== */
.sidebar {
    width: 240px;
    background-color: var(--color-sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar.collapsed {
    width: 64px;
}

.sidebar-header {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.logo-text {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--color-primary);
    white-space: nowrap;
    margin-left: 4px;
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-user {
    display: none;
}

/* ナビ */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.nav-item-wrapper {
    display: flex;
    align-items: center;
    margin-right: 10px;
}
.sidebar-nav li a,
.sidebar-nav li .nav-user {
    display: flex;
    align-items: center;
    padding: 11px 20px;
    color: #444;
    border-radius: 0 24px 24px 0;
    height: 46px;
    flex: 1;
    font-size: 0.92em;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background-color: var(--color-active-bg);
    color: var(--color-primary-dark);
}
.sidebar-nav li .nav-user {
    font-size: 0.8em;
    color: var(--color-muted);
    cursor: default;
}

/* サブメニュー */
.submenu-toggle-btn {
    width: 36px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
}
.submenu-toggle-btn:hover {
    background-color: #dce3ea;
}
.sidebar-nav .sub-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
    position: relative;
}
.menu-item-has-submenu.open .sub-menu {
    display: block;
}
.sidebar-nav .sub-menu::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 16px;
    left: 31px;
    width: 1px;
    background-color: #cbd5e1;
}
.sidebar-nav .sub-menu li {
    position: relative;
}
.sidebar-nav .sub-menu li::before {
    content: "";
    position: absolute;
    top: 19px;
    left: 31px;
    width: 12px;
    height: 1px;
    background-color: #cbd5e1;
}
.sidebar-nav .sub-menu li a {
    padding-left: 52px;
    height: 38px;
    font-size: 0.88em;
    color: #555;
}
.sidebar-nav .sub-menu li a:hover,
.sidebar-nav .sub-menu li a.active {
    background-color: transparent;
    color: var(--color-primary);
    font-weight: 700;
}
.arrow-icon {
    font-style: normal;
    font-size: 0.75em;
    transition: transform 0.3s;
    display: inline-block;
    color: #888;
}
.menu-item-has-submenu.open .arrow-icon {
    transform: rotate(180deg);
}
.sidebar.collapsed .sub-menu,
.sidebar.collapsed .submenu-toggle-btn {
    display: none !important;
}

.icon {
    font-style: normal;
    font-size: 1.1em;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}
.nav-text {
    margin-left: 10px;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

/* =====================
   メインコンテンツ
===================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-width: 0;
    max-height: 100vh;
    overflow-y: auto;
    padding-bottom: 80px;
}
.main-header {
    padding: 20px 28px 10px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 100;
}
.header-title {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--color-primary);
}
.container {
    padding: 20px 28px;
}

/* =====================
   ハンバーガーボタン
===================== */
.menu-btn {
    background: none;
    border: none;
    font-size: 1.6em;
    cursor: pointer;
    color: #444;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}
.menu-btn:hover {
    background: #dce3ea;
}

/* =====================
   フォームパネル
===================== */
.form-panel {
    background: var(--color-sidebar-bg);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.form-panel-caution {
    background: rgba(255, 69, 0, 0.05);
    border-left: 4px solid #ff7043;
}
.form-panel-title {
    margin: 0 0 14px;
    font-size: 1em;
    font-weight: 700;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-group {
    margin-bottom: 14px;
}
.form-group:last-child {
    margin-bottom: 0;
}
.form-label {
    display: block;
    font-weight: 700;
    font-size: 0.88em;
    margin-bottom: 6px;
    color: #444;
}
.form-label .required {
    color: #e53935;
    margin-left: 4px;
}
.input-field,
input[type="text"],
input[type="tel"],
input[type="date"],
select,
textarea {
    font-family: "Noto Sans JP", sans-serif;
    font-size: 15px;
    padding: 10px 12px;
    border: 1px solid #bbb;
    border-radius: 5px;
    background: #fff;
    color: var(--color-text);
    width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}
input[type="text"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(7,86,158,0.12);
}
textarea {
    height: 80px;
    resize: vertical;
}
select {
    background-image: url("data:image/svg+xml;utf8,<svg fill='gray' height='18' viewBox='0 0 24 24' width='18' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* 横並び */
.input-row {
    display: flex;
    gap: 10px;
}
.input-row .input-field,
.input-row input,
.input-row select {
    flex: 1;
}
.input-row .input-zip {
    flex: 0 0 140px;
}
.input-row .btn-zip {
    flex: 0 0 auto;
    padding: 10px 14px;
    background: #eee;
    border: 1px solid #bbb;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.88em;
    white-space: nowrap;
    align-self: flex-end;
    height: 42px;
}
.input-row .btn-zip:hover {
    background: #ddd;
}

/* ラジオ・チェック */
.radio-group,
.check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 4px 0;
}
.radio-label,
.check-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.92em;
}
.radio-label input,
.check-label input {
    width: auto;
    accent-color: var(--color-primary);
    cursor: pointer;
    margin: 0;
}

/* 画像プレビュー */
.img-upload-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.img-preview {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #f5f5f5;
    display: block;
}
.img-preview.empty {
    display: none;
}

/* =====================
   ボタン
===================== */
.btn {
    background: var(--color-primary);
    color: #fff;
    padding: 14px 20px;
    border: none;
    cursor: pointer;
    width: 100%;
    font-size: 1em;
    font-weight: 700;
    border-radius: 6px;
    font-family: inherit;
}
.btn:hover { opacity: 0.8; }

.btn-secondary {
    background: #f1f3f4;
    color: #444;
    border: 1px solid #ccc;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-family: inherit;
}
.btn-secondary:hover { background: #e2e2e2; }

.btn-delete {
    background: #e57373;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
}
.btn-delete:hover { background: #ef5350; }

.btn-submit {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 700;
    font-family: inherit;
    white-space: nowrap;
}
.btn-submit:hover { opacity: 0.8; }

.btn-action-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.btn-action-row .btn {
    flex: 1;
}

/* =====================
   テーブル（一覧）
===================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.92em;
}
.data-table thead tr {
    background: #fafafa;
    border-bottom: 2px solid #ddd;
}
.data-table th,
.data-table td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.data-table tbody tr:hover {
    background: #f7faff;
    cursor: pointer;
}

/* =====================
   検索パネル
===================== */
.search-panel {
    background: #f4f6f9;
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid var(--color-border);
}
.search-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.search-group {
    flex: 1;
    min-width: 160px;
}
.search-label {
    display: block;
    font-size: 0.82em;
    font-weight: 700;
    margin-bottom: 5px;
    color: #444;
}

/* =====================
   アラート・バッジ
===================== */
.alert-info {
    padding: 12px 14px;
    margin-bottom: 16px;
    background-color: #e3f2fd;
    border-left: 4px solid var(--color-primary);
    border-radius: 4px;
    font-size: 0.9em;
}
.alert-error {
    background-color: #ffebee;
    border-left-color: #e53935;
}
.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    color: #fff;
    display: inline-block;
}
.badge-primary { background: var(--color-primary); }
.badge-danger  { background: #e53935; }
.badge-warning { background: #ff8c00; }
.badge-gray    { background: #999; }

/* =====================
   ページネーション
===================== */
.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 24px;
}
.pagination a,
.pagination span {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.88em;
    background: #fff;
    color: var(--color-primary);
}
.pagination .current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    font-weight: 700;
    pointer-events: none;
}
.pagination a:hover { background: #e3f2fd; }

/* =====================
   ユーティリティ
===================== */
.d-none  { display: none; }
.d-flex  { display: flex; }
.gap-10  { gap: 10px; }
.mb-10   { margin-bottom: 10px; }
.mb-20   { margin-bottom: 20px; }
.mt-10   { margin-top: 10px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-primary { color: var(--color-primary); }
.text-danger  { color: #e53935; }
.text-muted   { color: var(--color-muted); }
.text-sm { font-size: 0.85em; }
.fw-bold { font-weight: 700; }
.w-100   { width: 100%; }
.flex-1  { flex: 1; }

/* =====================
   SP（768px以下）
   ハンバーガーは右上
===================== */
@media screen and (max-width: 768px) {
    /* サイドバーをSPでは右上の60×60ボタン領域に */
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        width: 60px;
        height: 60px;
        z-index: 2000;
        background: transparent;
        overflow: visible;
    }
    .sidebar-header {
        width: 60px;
        height: 60px;
        padding: 0;
        justify-content: center;
        border-bottom: none;
    }
    .logo-text {
        display: none;
    }
    .sidebar-nav {
        display: none;
    }
    .sidebar-footer {
        display: none;
    }
    /* メニューオープン時：右からスライドイン */
    .sidebar.sp-open {
        right: 0;
        top: 0;
        width: 270px;
        height: 100%;
        background-color: var(--color-sidebar-bg);
        box-shadow: -4px 0 16px rgba(0,0,0,0.15);
        display: flex;
        flex-direction: column;
    }
    .sidebar.sp-open .sidebar-header {
        width: 100%;
        height: 56px;
        padding: 0 12px;
        justify-content: space-between;
        border-bottom: 1px solid var(--color-border);
    }
    .sidebar.sp-open .logo-text {
        display: block;
    }
    .sidebar.sp-open .sidebar-nav {
        display: block;
        flex: 1;
        overflow-y: auto;
    }
    .sidebar.sp-open .sidebar-footer {
        display: block;
    }
    /* メインコンテンツはSPで上部に余白 */
    .main-content {
        padding-top: 60px;
        max-height: 100vh;
    }
    .main-header {
        padding: 14px 16px 10px;
        top: 60px;
    }
    .container {
        padding: 16px;
    }
    .form-panel {
        padding: 14px;
    }
    /* テーブルSP対応 */
    .data-table thead {
        display: none;
    }
    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }
    .data-table tr {
        margin-bottom: 12px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    }
    .data-table td {
        padding: 6px 4px;
        border-bottom: 1px dashed #eee;
    }
    .data-table td:last-child {
        border-bottom: none;
    }
}

@media screen and (max-width: 480px) {
    .container { padding: 12px; }
}
