/* ============================================================
   千客万歳（SENKYAKUBANZAI） - 管理画面スタイル
   アクセントカラー: ゴールド系 #B8860B
   ============================================================ */

/* --- リセット & 基本設定 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --gold: #B8860B;
    --gold-light: #D4A843;
    --gold-dark: #8B6508;
    --gold-bg: #FBF7ED;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --red: #DC2626;
    --red-light: #FEE2E2;
    --green: #16A34A;
    --green-light: #DCFCE7;
    --blue: #2563EB;
    --blue-light: #DBEAFE;
    --sidebar-width: 240px;
    --header-height: 60px;
}

html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}
a { color: var(--gold-dark); text-decoration: none; }
a:hover { color: var(--gold); }

/* --- ログインページ --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gold-bg) 0%, var(--white) 100%);
}
.login-box {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
}
.login-box h1 {
    text-align: center;
    font-size: 1.6rem;
    color: var(--gold-dark);
    margin-bottom: 4px;
}
.login-box .subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.85rem;
    margin-bottom: 32px;
}
.login-box .brand {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

/* --- レイアウト --- */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* サイドバー */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-800);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}
.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--gray-700);
}
.sidebar-brand .brand-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold-light);
    letter-spacing: 1px;
}
.sidebar-brand .brand-sub {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-top: 2px;
}
.sidebar-nav {
    padding: 12px 0;
    list-style: none;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--gray-300);
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}
.sidebar-nav li a:hover {
    background: var(--gray-700);
    color: var(--white);
}
.sidebar-nav li a.active {
    background: var(--gold-dark);
    color: var(--white);
}
.sidebar-nav li a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-700);
    font-size: 0.8rem;
}
.sidebar-footer a {
    color: var(--gray-400);
}
.sidebar-footer a:hover {
    color: var(--red);
}

/* ヘッダー */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
}
.top-header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.top-header .page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gray-800);
}
.top-header .store-name {
    font-size: 0.85rem;
    color: var(--gray-500);
}
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--gray-600);
    padding: 4px 8px;
}

/* メインコンテンツ */
.main-content {
    padding: 28px;
    max-width: 1200px;
}

/* --- 共通コンポーネント --- */

/* ページ説明 */
.page-description {
    background: var(--gold-bg);
    border-left: 4px solid var(--gold);
    padding: 12px 16px;
    margin-bottom: 24px;
    font-size: 0.88rem;
    color: var(--gray-700);
    border-radius: 0 6px 6px 0;
}

/* カード */
.card {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
}
.card-body { padding: 20px; }

/* テーブル */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    background: var(--gray-50);
    text-align: left;
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table .col-actions { width: 140px; text-align: right; white-space: nowrap; }

/* ボタン */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--gold);
    color: var(--white);
}
.btn-primary:hover { background: var(--gold-dark); color: var(--white); }
.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger {
    background: var(--white);
    color: var(--red);
    border: 1px solid var(--red);
}
.btn-danger:hover { background: var(--red); color: var(--white); }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-icon {
    padding: 6px 10px;
    background: none;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 0.9rem;
}
.btn-icon:hover { background: var(--gray-100); }

/* フォーム */
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.form-group .hint {
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-top: 4px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--white);
}
.form-control:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(184,134,11,0.12);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* モーダル */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* アラート */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 18px;
    font-size: 0.88rem;
}
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #BBF7D0; }
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #FECACA; }
.alert-info { background: var(--blue-light); color: var(--blue); border: 1px solid #BFDBFE; }

/* バッジ */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-active { background: var(--green-light); color: var(--green); }
.badge-inactive { background: var(--gray-100); color: var(--gray-500); }

/* ドラッグ並べ替え */
.sortable-row { cursor: grab; }
.sortable-row:active { cursor: grabbing; }
.sortable-row.dragging {
    opacity: 0.5;
    background: var(--gold-bg);
}
.drag-handle {
    color: var(--gray-400);
    cursor: grab;
    font-size: 1rem;
    padding: 0 4px;
    user-select: none;
}

/* 写真アップロード */
.photo-upload {
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.photo-upload:hover { border-color: var(--gold); background: var(--gold-bg); }
.photo-upload input[type="file"] { display: none; }
.photo-upload .photo-label {
    font-size: 0.85rem;
    color: var(--gray-500);
}
.photo-preview {
    max-width: 200px;
    max-height: 150px;
    border-radius: 6px;
    margin-top: 10px;
    object-fit: cover;
}

/* 空状態 */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ダッシュボード統計 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stat-card .stat-label { font-size: 0.82rem; color: var(--gray-500); }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--gold-dark); margin-top: 4px; }

/* QRコード */
.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}
.qr-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}
.qr-card img { max-width: 120px; margin-bottom: 8px; }
.qr-card .table-label { font-weight: 600; font-size: 0.9rem; }

/* トグルスイッチ */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: transform 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--gold); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* --- ブランディング: テーマセレクター --- */
.theme-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.theme-option:hover { border-color: var(--gold-light); background: var(--gray-50); }
.theme-option.selected { border-color: var(--gold); background: var(--gold-bg); }
.theme-option input[type="radio"] { display: none; }
.theme-swatch {
    width: 48px;
    height: 32px;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid var(--gray-200);
}
.theme-swatch-kuro  { background: linear-gradient(135deg, #0a0a0a, #1a1a2e); }
.theme-swatch-shiro { background: linear-gradient(135deg, #f8f6f0, #ffffff); }
.theme-swatch-sumi  { background: linear-gradient(135deg, #1e1e24, #2c2c34); }
.theme-swatch-nami  { background: linear-gradient(135deg, #0c1929, #142640); }
.theme-swatch-ki    { background: linear-gradient(135deg, #1a1408, #2a2010); }
.theme-info { display: flex; flex-direction: column; gap: 2px; }
.theme-info strong { font-size: 0.9rem; color: var(--gray-800); }
.theme-info span { font-size: 0.78rem; color: var(--gray-500); }

/* --- ブランディング: アクセントカラー --- */
.accent-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.accent-preset {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    cursor: pointer;
    background: var(--white);
    transition: border-color .2s;
}
.accent-preset:hover { border-color: var(--gray-400); }
.accent-preset.selected { border-color: var(--gold); background: var(--gold-bg); }
.accent-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--preset-color);
    flex-shrink: 0;
}
.accent-label { font-size: 0.78rem; color: var(--gray-600); }

/* --- ブランディング: ライブプレビュー --- */
.brand-preview {
    min-height: 480px;
    font-family: -apple-system, sans-serif;
    font-size: 12px;
    overflow: hidden;
    position: relative;
    transition: background .3s, color .3s;

    --pv-accent: #c8a96e;
    --pv-accent-l: #dab98e;
    --pv-accent-d: #a8894e;
    --pv-accent-g: rgba(200,169,110,0.15);
}
/* テーマ別プレビュー背景 */
.brand-preview[data-theme="kuro"]  { background: #0a0a0a; color: #e8e8e8; }
.brand-preview[data-theme="shiro"] { background: #f8f6f0; color: #2a2a2a; }
.brand-preview[data-theme="sumi"]  { background: #1e1e24; color: #d8d8d8; }
.brand-preview[data-theme="nami"]  { background: #0c1929; color: #d0dae8; }
.brand-preview[data-theme="ki"]    { background: #1a1408; color: #e0d8c8; }

.bp-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
    border-bottom: 1px solid rgba(128,128,128,0.2);
}
.bp-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--pv-accent-g);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.bp-logo img { width: 100%; height: 100%; object-fit: cover; }
.bp-logo span { font-size: 14px; font-weight: 700; color: var(--pv-accent); }
.bp-store-name { font-size: 13px; font-weight: 600; flex: 1; }
.bp-lang {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    border: 1px solid var(--pv-accent);
    color: var(--pv-accent);
}

.bp-hero {
    height: 80px;
    margin: 8px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(128,128,128,0.3), rgba(128,128,128,0.1));
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px;
}
.bp-hero-badge {
    font-size: 8px;
    font-weight: 700;
    color: var(--pv-accent);
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.bp-hero-title { font-size: 14px; font-weight: 600; }

.bp-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(128,128,128,0.2);
}
.bp-tab {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    cursor: default;
    opacity: 0.5;
}
.bp-tab.active {
    background: var(--pv-accent-g);
    color: var(--pv-accent);
    opacity: 1;
    font-weight: 600;
}

.bp-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
}
.bp-card {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(128,128,128,0.15);
}
.bp-card-img {
    height: 60px;
    background: linear-gradient(135deg, rgba(128,128,128,0.2), rgba(128,128,128,0.05));
}
.bp-card-info { padding: 6px 8px; }
.bp-card-name { font-size: 10px; font-weight: 600; }
.bp-card-price { font-size: 12px; font-weight: 700; color: var(--pv-accent); margin-top: 2px; }

.bp-cart-bar {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    background: var(--pv-accent);
    color: #fff;
    text-align: center;
    padding: 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

/* --- キャンペーン: グラデーションプレビュー --- */
.gradient-preview {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 4px;
}
.gradient-g1 { background: linear-gradient(135deg, #B8860B, #DAA520); }
.gradient-g2 { background: linear-gradient(135deg, #C0392B, #E74C3C); }
.gradient-g3 { background: linear-gradient(135deg, #2563EB, #3B82F6); }
.gradient-g4 { background: linear-gradient(135deg, #16A34A, #22C55E); }

/* --- レスポンシブ --- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .hamburger { display: block; }
    .main-content { padding: 16px; }
    .modal { max-width: 95%; margin: 0 10px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    /* 2カラムレイアウトをモバイルでは1カラムに */
    [style*="grid-template-columns: 300px"],
    [style*="grid-template-columns:300px"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns: 1fr 340px"],
    [style*="grid-template-columns:1fr 340px"] { grid-template-columns: 1fr !important; }
    .accent-presets { grid-template-columns: repeat(2, 1fr); }
}
