/* ============================================================
   assets/css/style.css - 在庫管理システム メインCSS
   温かみのある女性向けデザイン / 年配の方にも見やすいUI
   ============================================================ */

/* --- CSS変数 --- */
:root {
    --primary:        #b85c7a;   /* ダスティローズ */
    --primary-dark:   #9a4062;
    --primary-light:  #fdf0f4;
    --primary-mid:    #e8a0b8;
    --secondary:      #8b7bb0;   /* ソフトラベンダー */
    --secondary-light:#f3f0fa;
    --success:        #5a8a6a;   /* セージグリーン */
    --success-light:  #edf6f0;
    --danger:         #c05450;   /* コーラルレッド */
    --danger-light:   #fdf0f0;
    --warning:        #c8844a;   /* ウォームアンバー */
    --warning-light:  #fdf5ed;
    --bg:             #faf6f8;   /* 温かみのある白 */
    --surface:        #ffffff;
    --border:         #e8d5db;   /* ローズボーダー */
    --border-light:   #f3e8ec;
    --text:           #2c2430;   /* 深いウォームブラック */
    --text-muted:     #8a7080;
    --nav-bg:         #5c2d48;   /* ディーププラム */
    --nav-active:     rgba(255,255,255,.2);
    --nav-text:       #fde8f0;
    --nav-section:    rgba(253,232,240,.45);
    --nav-width:      248px;
    --header-h:       60px;
    --radius-sm:      8px;
    --radius:         12px;
    --radius-lg:      16px;
    --radius-pill:    999px;
    --shadow-sm:      0 1px 4px rgba(184,92,122,.08);
    --shadow:         0 2px 10px rgba(184,92,122,.10), 0 1px 4px rgba(0,0,0,.05);
    --shadow-md:      0 4px 20px rgba(184,92,122,.14), 0 2px 8px rgba(0,0,0,.07);
    --transition:     .18s ease;
}

/* --- リセット --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic UI',
                 'Meiryo', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.75;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--primary-dark); }
img { max-width: 100%; }

/* --- サイトヘッダー --- */
.site-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: linear-gradient(135deg, var(--nav-bg) 0%, #7a3558 100%);
    color: #fff;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(92,45,72,.35);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1.25rem;
}
.header-left  { display: flex; align-items: center; gap: .75rem; }
.header-right { display: flex; align-items: center; gap: .75rem; }
.site-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .03em;
    text-decoration: none;
}
.site-title:hover { color: var(--primary-mid); text-decoration: none; }
.user-name { font-size: .85rem; color: var(--nav-text); opacity: .9; }
.btn-logout {
    font-size: .82rem;
    padding: .35rem .9rem;
    border: 1px solid rgba(255,255,255,.45);
    border-radius: var(--radius-pill);
    color: #fff;
    background: rgba(255,255,255,.12);
    cursor: pointer;
    transition: background var(--transition);
    text-decoration: none;
}
.btn-logout:hover { background: rgba(255,255,255,.25); text-decoration: none; color: #fff; }

/* メニューボタン */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,.12);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 7px;
}
.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

/* --- サイドナビ --- */
.side-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--nav-width);
    background: var(--nav-bg);
    overflow-y: auto;
    z-index: 99;
    padding: 1rem 0 2rem;
    box-shadow: 2px 0 12px rgba(92,45,72,.15);
}
.side-nav::-webkit-scrollbar { width: 4px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }
.side-nav ul { list-style: none; }
.side-nav li a {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1.25rem;
    color: var(--nav-text);
    font-size: .95rem;
    line-height: 1.4;
    transition: background var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.side-nav li a:hover {
    background: var(--nav-active);
    text-decoration: none;
    border-left-color: var(--primary-mid);
}
.side-nav li.active > a {
    background: var(--nav-active);
    border-left-color: var(--primary-mid);
    color: #fff;
    font-weight: 600;
}
.nav-section {
    padding: 1rem 1.25rem .35rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    color: var(--nav-section);
    text-transform: uppercase;
}

/* オーバーレイ */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(44,36,48,.5);
    z-index: 98;
}
.overlay.active { display: block; }

/* --- メインコンテンツ --- */
.main-content {
    margin-left: var(--nav-width);
    padding-top: calc(var(--header-h) + 1.75rem);
    padding-bottom: 3rem;
    min-height: 100vh;
    padding-left: 1.75rem;
    padding-right: 1.75rem;
}

/* --- ページヘッダー --- */
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--border);
}
.page-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}

/* --- フッター --- */
.site-footer {
    margin-left: var(--nav-width);
    padding: 1.5rem 1.75rem;
    border-top: 1px solid var(--border);
    font-size: .82rem;
    color: var(--text-muted);
}

/* --- カード --- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-light);
}
.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--border-light);
}

/* --- ボタン --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); box-shadow: var(--shadow-sm); }
.btn:active { filter: brightness(.95); }

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-warning  { background: var(--warning);  color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.btn-sm  { padding: .32rem .85rem; font-size: .8rem; border-radius: var(--radius-pill); }
.btn-lg  { padding: .75rem 1.75rem; font-size: 1rem; border-radius: var(--radius); }
.w-100   { width: 100%; justify-content: center; }

/* --- フォーム --- */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: .93rem;
    margin-bottom: .45rem;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: .65rem .95rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(184,92,122,.18);
}
.form-control::placeholder { color: #c0aab2; }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a7080' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .95rem center;
    padding-right: 2.4rem;
}
textarea.form-control { min-height: 100px; resize: vertical; }
.form-hint { font-size: .82rem; color: var(--text-muted); margin-top: .3rem; }
.required { color: var(--danger); margin-left: .2rem; }
.form-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-size: .95rem;
}
.form-check input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}
.form-row    { display: flex; gap: 1rem; }
.form-row-2  > * { flex: 1; min-width: 0; }
.form-footer {
    display: flex;
    gap: .75rem;
    align-items: center;
    padding-top: .75rem;
    flex-wrap: wrap;
}

/* 商品検索ボックス（入庫/出庫用） */
.product-search-wrap { position: relative; margin-bottom: .5rem; }
.product-search-wrap .search-icon {
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.product-search-wrap input { padding-left: 2.5rem; }
.product-count-hint { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }

/* --- 検索フォーム --- */
.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}
.search-form .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }

/* --- アクションバー --- */
.action-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .9rem;
    flex-wrap: wrap;
}
.action-bar .spacer { flex: 1; }

/* --- カラム表示切替ボタン --- */
.col-toggle-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    align-items: center;
    padding: .65rem 1rem;
    background: var(--secondary-light);
    border-radius: var(--radius-sm);
    margin-bottom: .9rem;
    border: 1px solid #ddd6f0;
}
.col-toggle-bar > span {
    font-size: .8rem;
    font-weight: 700;
    color: var(--secondary);
    margin-right: .2rem;
    white-space: nowrap;
}
.col-toggle-btn {
    padding: .25rem .75rem;
    border-radius: var(--radius-pill);
    border: 1.5px solid #c4b8e0;
    background: #fff;
    color: var(--secondary);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.col-toggle-btn.on {
    background: var(--secondary);
    color: #fff;
    border-color: var(--secondary);
}

/* --- テーブル --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .93rem;
}
thead th {
    background: linear-gradient(180deg, #fdf0f4 0%, #f8e6ed 100%);
    color: var(--text);
    font-weight: 700;
    font-size: .85rem;
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--primary-mid);
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-light); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: #fdf8fa; }
tbody tr:hover { background: var(--primary-light); }
tbody td { padding: .7rem 1rem; vertical-align: middle; }

/* --- バッジ --- */
.badge {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: var(--radius-pill);
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.4;
}
.badge-in       { background: var(--success-light); color: var(--success); }
.badge-out      { background: var(--danger-light);  color: var(--danger); }
.badge-adjust   { background: var(--warning-light); color: var(--warning); }
.badge-transfer { background: var(--secondary-light); color: var(--secondary); }
.badge-active   { background: var(--success-light); color: var(--success); }
.badge-inactive { background: #f0f0f2; color: #888; }

/* --- 在庫数表示 --- */
.stock-num { font-size: 1.05rem; font-weight: 700; }

/* --- アラート --- */
.alert {
    padding: .9rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .93rem;
    border-left: 4px solid transparent;
    line-height: 1.65;
}
.alert-success { background: var(--success-light); border-color: var(--success); color: #2d6040; }
.alert-error   { background: var(--danger-light);  border-color: var(--danger);  color: #8c2820; }
.alert-warning { background: var(--warning-light); border-color: var(--warning); color: #7a4a1a; }
.alert-info    { background: var(--secondary-light); border-color: var(--secondary); color: #4a3878; }

/* --- フラッシュメッセージ --- */
.flash { margin-bottom: 1rem; }

/* --- ページネーション --- */
.pagination {
    display: flex;
    justify-content: center;
    gap: .4rem;
    padding: 1.25rem 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px;
    padding: 0 .75rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: all var(--transition);
}
.pagination a:hover { background: var(--primary-light); border-color: var(--primary-mid); text-decoration: none; }
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pagination .disabled { opacity: .4; cursor: default; }

/* --- ログイン画面 --- */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #fdf0f4 0%, #f3eef8 50%, #eef3f8 100%);
    padding: 2rem 1rem;
}
.login-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}
.login-box h1 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--nav-bg);
    margin-bottom: 1.75rem;
    letter-spacing: .02em;
}

/* --- ダッシュボード統計カード --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.35rem 1.25rem;
    border: 1px solid var(--border-light);
    border-top: 4px solid var(--primary);
}
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--text); letter-spacing: -.02em; }
.stat-label { font-size: .82rem; color: var(--text-muted); margin-top: .35rem; }

/* --- インライン数量コントロール --- */
.qty-control { display: flex; align-items: center; gap: .3rem; }
.qty-btn {
    width: 30px; height: 30px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.qty-btn:hover { transform: scale(1.12); }
.qty-btn.dec { color: var(--danger);  border-color: var(--danger); }
.qty-btn.dec:hover { background: var(--danger-light); }
.qty-btn.inc { color: var(--success); border-color: var(--success); }
.qty-btn.inc:hover { background: var(--success-light); }
.qty-input {
    width: 68px;
    padding: .3rem .4rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: .95rem;
    font-weight: 600;
}
.qty-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(184,92,122,.18); }
.qty-msg { font-size: .77rem; min-height: 1.1em; color: var(--success); margin-top: 2px; }

/* --- 商品サムネイル --- */
.product-thumb {
    width: 44px; height: 44px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: block;
}
.product-thumb-placeholder {
    font-size: 1.5rem;
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.product-thumb-lg {
    width: 100%; max-height: 220px;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    background: var(--bg);
}
.product-img-current { margin-bottom: .75rem; }
.product-img-current label {
    display: flex; align-items: center; gap: .5rem;
    font-size: .85rem; cursor: pointer;
    color: var(--danger); margin-top: .5rem;
}

/* 画像アップロードUI */
.img-upload-btns { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }

/* --- スキャンモーダル --- */
.scan-modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(44,36,48,.6); z-index: 200;
    align-items: center; justify-content: center; padding: 1rem;
}
.scan-modal-overlay.open { display: flex; }
.scan-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.scan-modal-title {
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700; font-size: 1.05rem; margin-bottom: 1.1rem;
}
.scan-modal-close {
    background: none; border: none; font-size: 1.1rem; cursor: pointer;
    color: var(--text-muted); padding: .25rem .5rem; border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.scan-modal-close:hover { background: var(--bg); color: var(--text); }
.scanner-area { width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; }

/* --- 在庫移動モーダル --- */
.transfer-modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(44,36,48,.6); z-index: 200;
    align-items: center; justify-content: center; padding: 1rem;
}
.transfer-modal-overlay.open { display: flex; }
.transfer-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    width: 100%; max-width: 440px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.transfer-modal h3 {
    font-size: 1.05rem; font-weight: 700; margin-bottom: 1.1rem;
    padding-bottom: .6rem; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}

/* --- CSV画面 --- */
.csv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.csv-card {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.5rem;
    border: 1px solid var(--border-light); border-top: 4px solid var(--primary);
}
.csv-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; }
.csv-card p  { font-size: .88rem; color: var(--text-muted); margin-bottom: 1rem; }

/* --- ユーティリティ --- */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.text-primary{ color: var(--primary); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.spacer { flex: 1; }

/* --- スマホ対応 --- */
@media (max-width: 768px) {
    .menu-toggle { display: flex; }
    .side-nav { transform: translateX(-100%); transition: transform .25s ease; z-index: 99; }
    .side-nav.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding-left: 1rem; padding-right: 1rem; padding-top: calc(var(--header-h) + 1.25rem); }
    .site-footer { margin-left: 0; }
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .page-header h1 { font-size: 1.25rem; }
    .btn-lg { width: 100%; justify-content: center; }
    .form-footer { flex-direction: column; }
    .form-footer .btn { width: 100%; justify-content: center; }
    .qty-input { width: 58px; }
}
