/*
 * ============================================================
 * app.css
 * ============================================================
 * メイン画面(index.html)の見た目を定義するCSSです。
 *
 * 画面構成:
 * ・左側: 地図 (#map)
 * ・右側: サイドバー (#side)
 * ・サイドバー内: 一覧タブ / 詳細タブ / 入力フォーム / メモ / 所有者情報
 *
 * CSSの読み方:
 * #xxx は id="xxx" の要素に効きます。
 * .xxx は class="xxx" の要素に効きます。
 * ============================================================
 */

html,
body {
	margin: 0;
	height: 100%;
	font-family: system-ui, sans-serif;
}

/* 地図とサイドバーを横並びにするための親レイアウトです。 */

#app {
	display: grid;
	grid-template-columns: 1fr 360px;
	height: 100%;
}

/* MapLibreの地図を表示する領域です。 */

#map {
	height: 100%;
}

/* 右側の一覧・詳細表示エリアです。 */

#side {
	border-left: 1px solid #ddd;
	padding: 8px;
	overflow-y: auto;
}

/* 一覧/詳細のタブボタンを横並びにします。 */

.tabs {
	display: flex;
	gap: 6px;
	margin-bottom: 8px;
}

.tabs button {
	flex: 1;
	padding: 6px;
	cursor: pointer;
	border: 1px solid #aaa;
	background: #f5f5f5;
}

.tabs button.active {
	background: #333;
	color: #fff;
}

/* 物件一覧の1行分です。クリックすると詳細を開きます。 */

.list-item {
	padding: 8px;
	border-bottom: 1px solid #ddd;
	cursor: pointer;
}

.list-item:hover {
	background: #eee;
}

.list-title {
	font-weight: 700;
	font-size: 14px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.list-sub {
	font-size: 12px;
	color: #555;
	margin-top: 2px;
}

/* 物件ステータスを丸いラベルとして表示します。 */

.status-chip {
	display: inline-block;
	padding: 3px 8px;
	border-radius: 999px;
	font-size: 12px;
	line-height: 1.4;
	font-weight: 700;
	border: 1px solid rgba(0, 0, 0, 0.06);
}

.status-未着手,
.status-手紙送付,
.status-手紙戻り {
	background: #fee2e2;
	color: #991b1b;
}

.status-進行中,
.status-見込み,
.status-クレーム {
	background: #dcfce7;
	color: #166534;
}

.status-契約中 {
	background: #dbeafe;
	color: #1e40af;
}

.status-成約済み {
	background: #e5e7eb;
	color: #374151;
}

/* 詳細フォームの項目名です。 */

.form label {
	display: block;
	margin-bottom: 2px;
	font-size: 12px;
	margin-top: 10px;
}

.form input,
.form select,
.form textarea {
	width: 100%;
	padding: 6px;
	box-sizing: border-box;
}

.form textarea {
	resize: vertical;
}

.form .row2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
}

.req {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 5px;
	font-size: 10px;
	font-weight: bold;
	color: #fff;
	background: #ff4d4f;
	border-radius: 999px;
}

.edit {
	color: #666;
	margin-left: 4px;
}

.field-hint {
	margin-top: 4px;
	font-size: 11px;
	color: #666;
}

.actions {
	margin-top: 12px;
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.actions button {
	flex: 1;
	padding: 8px;
	cursor: pointer;
	min-width: 90px;
}

.btn-danger {
	background: #c0392b;
	color: #fff;
	border: none;
}

.btn-primary {
	background: #2980b9;
	color: #fff;
	border: none;
}

/* 営業メモ欄の見出し部分です。 */

.memo-head {
	margin-top: 10px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.memo-head .memo-title {
	font-size: 12px;
	font-weight: 700;
}

.memo-add {
	font-size: 11px;
	margin-top: 8px;
	padding: 2px 10px;
	cursor: pointer;
}

.memo-list {
	margin-top: 8px;
	display: grid;
	gap: 8px;
}

.memo-item {
	border: 1px solid #cfcfcf;
	background: #fff;
}

.memo-grid {
	display: grid;
	grid-template-columns: 40px minmax(116px, 1fr) 40px minmax(110px, 1fr) 28px;
	grid-template-rows: auto auto;
}

.memo-cell {
	border-right: 1px solid #cfcfcf;
	border-bottom: 1px solid #cfcfcf;
	padding: 3px;
	font-size: 12px;
	box-sizing: border-box;
	min-height: 30px;
	display: flex;
	align-items: center;
}

.memo-label {
	justify-content: center;
	background: #f4f4f4;
	font-weight: 700;
}

.memo-del {
	grid-column: 5;
	grid-row: 1 / span 2;
	border: 0;
	background: #e6e6e6;
	cursor: pointer;
	font-size: 16px;
	width: 100%;
	height: 100%;
}

.memo-date,
.memo-owner {
	width: 100%;
	height: 28px;
	font-size: 12px;
	box-sizing: border-box;
}

.memo-text {
	width: 100%;
	min-height: 48px;
	font-size: 12px;
	padding: 6px;
	box-sizing: border-box;
	border: 1px solid #cfcfcf;
	border-radius: 3px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.memo-fixed-text {
	width: 100%;
	font-size: 12px;
	line-height: 1.4;
}

/* 地図上に表示する独自ピンの見た目です。 */

.pin {
	width: 28px;
	height: 28px;
	border-radius: 8px;
	color: #fff;
	font-weight: 800;
	font-size: 12px;
	display: grid;
	place-items: center;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
	cursor: pointer;
	user-select: none;
	border: 2px solid #fff;
}

.readonly-display {
	background: #ffffff;
	color: #555;
	border: 1px solid #cfcfcf;
	outline: none;
	box-shadow: none;
	cursor: default;
}

/* =========================
   所有者情報
========================= */
.owner-head {
	margin-top: 10px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.owner-head .owner-title {
	font-size: 12px;
	font-weight: 700;
}

.owner-add {
	font-size: 11px;
	margin-top: 8px;
	padding: 2px 10px;
	cursor: pointer;
}

.owner-list {
	margin-top: 8px;
	display: grid;
	gap: 8px;
}

.owner-item {
	border: 1px solid #cfcfcf;
	background: #fff;
}

.owner-grid-v2 {
	display: grid;
	grid-template-columns: 44px minmax(95px, 1fr) 40px minmax(70px, 0.8fr) 28px;
	grid-template-rows: auto auto auto;
}

.owner-cell {
	border-right: 1px solid #cfcfcf;
	border-bottom: 1px solid #cfcfcf;
	padding: 3px;
	font-size: 12px;
	box-sizing: border-box;
	min-height: 30px;
	display: flex;
	align-items: center;
}

.owner-label {
	justify-content: center;
	background: #f4f4f4;
	font-weight: 700;
	flex-direction: column;
	gap: 2px;
	line-height: 1.1;
}

.owner-input-cell input {
	width: 100%;
	height: 28px;
	font-size: 12px;
	box-sizing: border-box;
}

.owner-wide {
	grid-column: 2 / span 3;
	border-right: 1px solid #cfcfcf;
}

.owner-postal-label {
	grid-column: 1;
	grid-row: 2;
}

.owner-postal-label + .owner-input-cell {
	grid-row: 2;
}

.owner-address-label {
	grid-column: 1;
	grid-row: 3;
}

.owner-address-label + .owner-input-cell {
	grid-row: 3;
}

.owner-del {
	grid-column: 5;
	grid-row: 1 / span 3;
	border: 0;
	background: #e6e6e6;
	cursor: pointer;
	font-size: 16px;
	width: 100%;
	height: 100%;
}

.owner-req {
	margin-left: 0;
	padding: 1px 5px;
	font-size: 9px;
	line-height: 1.1;
}

.owner-name,
.owner-share,
.owner-postal,
.owner-address {
	width: 100%;
	height: 28px;
	font-size: 12px;
	box-sizing: border-box;
}

.owner-address {
	height: 30px;
}

.side-header {
	margin-bottom: 14px;
}

#logoutButton {
	width: 100%;
	padding: 10px 12px;
	border: none;
	border-radius: 10px;
	background: #f3f4f6;
	color: #374151;
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
	border: 1px solid #d1d5db;
}

#logoutButton:hover {
	background: #e5e7eb;
}
