/* style.css (画像調整・レイアウト修正・リセット画面追加版) */

:root {
    --primary: #2563eb;    /* メイン青 */
    --primary-dark: #1e3a8a;
    --success: #10b981;    /* 緑 */
    --warning: #f59e0b;    /* 黄/オレンジ */
    --danger: #ef4444;     /* 赤 */
    --bg-color: #f1f5f9;   /* 背景グレー */
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-sub: #64748b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    padding-top: 100px; /* ★修正: 85px + 余白 で100pxくらい確保 */
    padding-bottom: 80px;
    -webkit-tap-highlight-color: transparent;
}

/* === ヘッダー（全幅表示） === */
/* === ヘッダー（全幅表示・固定） === */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 85px;
    background: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    
    /* 左右配置の設定 */
    display: flex;
    align-items: center;
    justify-content: space-between;
    
    z-index: 100;
    /* paddingは index.html の style属性で上書き制御しています */
    padding: 0 10px; 
    box-sizing: border-box;
}

/* === ヘッダーロゴ（左寄せ・特大ズーム・重複なし完全版） === */
/* === ヘッダーロゴ（中央揃え・アプリ風デザイン） === */
.header-logo {
    height: 100%;
    width: auto;
    
    /* 左右のアイコンと重ならないように幅を制限 */
    max-width: 50%; 
    
    object-fit: contain;
    
    /* ★ここが重要：絶対配置でド真ん中に固定する */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* === タブバー === */
.tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: var(--card-bg);
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}
.tab-button {
    flex: 1;
    border: none;
    background: none;
    font-size: 0.75rem;
    color: var(--text-sub);
    padding: 8px 0;
    cursor: pointer;
}
.tab-button.active {
    color: var(--primary);
    font-weight: bold;
}
.tab-icon {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 2px;
}

/* === コンテンツエリア === */
.tab-content {
    display: none;
    padding: 15px;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.2s ease;
}
.tab-content.active { display: block; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === アコーディオン === */
.accordion-header {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    color: var(--text-sub);
    border: 1px solid #e2e8f0;
}
.accordion-content {
    display: none;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.arrow { transition: transform 0.3s; }

/* === コックピット === */
.main-cockpit {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 15px;
    text-align: center;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: auto; 
}
.status-badge {
    background: #f1f5f9;
    color: var(--text-sub);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 10px;
    display: inline-block;
}
.info-display { margin-bottom: 15px; width: 100%; }
.company-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-main);
    margin: 0 0 5px 0;
    min-height: 1.4em;
}
.phone-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: 1px;
    margin: 0;
    font-family: monospace;
}
.big-call-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 0;
    width: 85%;
    max-width: 300px;
    font-size: 1.3rem;
    font-weight: bold;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
    transition: transform 0.1s, opacity 0.2s;
    cursor: pointer;
    margin-bottom: 10px;
}
.big-call-btn:active { transform: scale(0.96); }
.big-call-btn:disabled { background: #cbd5e1; box-shadow: none; cursor: not-allowed; }
.system-msg { font-size: 0.75rem; color: var(--text-sub); line-height: 1.4; }

/* === 設定画面 === */
.setting-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.setting-header {
    background: #f8fafc;
    padding: 12px 15px;
    border-bottom: 1px solid #e2e8f0;
}
.setting-header h3 { margin: 0; font-size: 1rem; color: var(--text-sub); }
.setting-body { padding: 0; }
.setting-item {
    border-bottom: 1px solid #f1f5f9;
    padding: 15px 20px;
}
.setting-item:last-child { border-bottom: none; }
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
.setting-label { font-weight: 600; color: var(--text-main); }
.styled-input {
    width: 60px;
    text-align: center;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1.1rem;
    background: #f8fafc;
}
.desc { font-size: 0.8rem; color: #94a3b8; margin: 0; }

/* === モーダル共通 === */
.modal {
    display: none; 
    position: fixed; 
    z-index: 200; 
    left: 0; top: 0; 
    width: 100%; height: 100%; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(3px);
}
.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}
@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-title {
    margin-top: 0;
    text-align: center;
    font-size: 1.1rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 10px;
    color: var(--primary-dark);
}
.close-button { float: right; font-size: 24px; cursor: pointer; color: #999; }

/* === 入力フォーム === */
/* === 入力フォーム === */
.customer-info-area {
    display: flex; flex-wrap: wrap; gap: 10px;
    background: #f8fafc; padding: 15px;
    border-radius: 8px; margin-bottom: 15px;
    border: 1px solid #e2e8f0;
}

.input-wrapper {
    position: relative;
    background: white; border: 1px solid #cbd5e1; border-radius: 6px;
    display: flex; align-items: center;
    /* ★追加: 重なり順の基準を作ります */
    z-index: 1;
}

.input-wrapper:focus-within { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 2px rgba(37,99,235,0.1); 
    /* ★追加: 入力中は親要素より手前に表示 */
    z-index: 2; 
}

.input-wrapper.full { width: 100%; }
.input-wrapper.half { width: calc(50% - 5px); }

.input-wrapper input, select.info-input {
    width: 100%; border: none; background: transparent;
    padding: 10px; font-size: 0.95rem; outline: none;
    padding-right: 2.5em;
    
    /* ★重要: ここが修正ポイントです！ */
    /* 入力欄を最前面に配置し、テキスト選択・入力を確実に許可します */
    position: relative;
    z-index: 10;
    -webkit-user-select: text;
    user-select: text;
}

select.info-input { padding-right: 5px; border: 1px solid #cbd5e1; border-radius: 6px; }

.unit-suffix {
    position: absolute; right: 10px; font-size: 0.8rem; color: #94a3b8; pointer-events: none;
    /* ★念のため追加: 単位の文字が入力の邪魔をしないようにする */
    z-index: 11;
}

.memo-history {
    background: #f1f5f9; padding: 10px; border-radius: 8px;
    max-height: 100px; overflow-y: auto; font-size: 0.8rem; margin-bottom: 10px;
    white-space: pre-wrap; border: 1px solid #e2e8f0;
}

.memo-area {
    width: 100%; height: 80px; padding: 10px;
    border: 1px solid #cbd5e1; border-radius: 8px;
    font-size: 0.95rem; box-sizing: border-box;
    margin-bottom: 15px; font-family: inherit;
    /* ★追加: テキストエリアも同様に入力許可 */
    -webkit-user-select: text;
    user-select: text;
    z-index: 10;
    position: relative;
}

/* === 結果ボタン === */
.result-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.res-btn {
    padding: 12px; border: none; border-radius: 8px;
    font-weight: bold; font-size: 0.9rem; cursor: pointer; color: white;
    transition: transform 0.1s;
}
.res-btn:active { transform: scale(0.98); opacity: 0.9; }
.res-btn.apo { background: var(--primary); grid-column: span 2; font-size: 1.1rem; padding: 15px; }
.res-btn.lead { background: var(--success); }
.res-btn.progress { background: var(--warning); color: #333; }
.res-btn.pending { background: #94a3b8; }
.res-btn.exclude { background: var(--danger); }

/* === リストテーブル === */
.header-actions {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
}
.header-actions h2 { margin: 0; font-size: 1.2rem; color: var(--text-main); }
.mini-btn {
    background: var(--text-sub); color: white; border: none;
    padding: 6px 12px; border-radius: 6px; font-size: 0.8rem; cursor: pointer;
}
.record-table { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
.record-table tr { 
    display: block; background: white; border-radius: 10px; padding: 15px; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); margin-bottom: 10px;
}
.record-table td { display: block; padding: 2px 0; border: none; font-size: 0.9rem; }
.memo-cell {
    background: #f8fafc; padding: 8px; border-radius: 6px; 
    font-size: 0.85rem; color: #475569; margin-top: 5px;
}
.action-btn-group { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.list-act-btn { padding: 8px 15px; border-radius: 6px; border: none; color: white; font-size: 0.85rem; cursor: pointer;}
.list-act-btn.call-mode { background: var(--success); }
.list-act-btn.edit-mode { background: var(--primary); }
.empty-msg { text-align: center; color: #94a3b8; padding: 30px; }
.scroll-list { padding-bottom: 20px; }

/* ★追加: リセット画面のチェックボックスデザイン */
.reset-option {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
.reset-option:active {
    background: #e2e8f0;
}
.reset-option input {
    transform: scale(1.5);
    margin-right: 15px;
    cursor: pointer;
}
.reset-option .lbl {
    font-weight: bold;
    color: #333;
    font-size: 1rem;
}
/* === アコーディオン装飾 (顧客情報用) === */
.info-accordion {
    margin-bottom: 15px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.info-accordion summary {
    padding: 12px 15px;
    font-weight: bold;
    color: #475569;
    background: #f1f5f9;
    cursor: pointer;
    list-style: none; /* デフォルトの矢印を消す */
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

/* Chrome/Safari用 矢印消し */
.info-accordion summary::-webkit-details-marker {
    display: none;
}

/* オリジナルの矢印 */
.info-accordion summary::after {
    content: '▼';
    font-size: 0.8em;
    color: #94a3b8;
    transition: transform 0.2s;
}

/* 開いている時の矢印回転 */
.info-accordion[open] summary::after {
    transform: rotate(180deg);
}

/* 中身のエリア調整 */
.info-accordion .customer-info-area {
    margin: 0;
    border: none;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 0;
}
/* style.css の末尾に追加 */

/* ダイナミックフォーム用 */
.dynamic-field-row {
    width: 100%;
    margin-bottom: 0px; /* input-wrapperのgapで調整 */
}

/* マッピングモーダル用 */
.mapping-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
}
.mapping-row td {
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.mapping-sample {
    font-size: 0.75rem;
    color: #64748b;
    display: block;
    margin-top: 2px;
}
/* ▼▼▼ 設定画面のアコーディオンデザイン ▼▼▼ */
details.setting-group {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

summary.setting-header {
    padding: 15px;
    background: #f8fafc;
    font-weight: bold;
    color: #334155;
    cursor: pointer;
    list-style: none; /* デフォルトの三角を消す */
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

summary.setting-header:hover {
    background: #f1f5f9;
}

/* 開閉時の矢印アイコン */
summary.setting-header::after {
    content: '▼';
    font-size: 0.7em;
    color: #94a3b8;
    transition: transform 0.3s;
}

details[open] summary.setting-header::after {
    transform: rotate(180deg);
}

/* 中身のコンテンツ */
.setting-content {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}
/* ▼▼▼ タブの仕切り線を追加 ▼▼▼ */
.tab-button:not(:last-child) {
    border-right: 1px solid #cbd5e1; /* 薄いグレーの縦線 */
}