/**
 * 貸款媒合系統 — 前台與後台共用樣式
 *
 * 設計原則：
 *  - CSS 變數方便 Elementor 主題覆蓋
 *  - RWD 支援（手機優先）
 *  - class 命名採 BEM 規範（lm- 前綴）
 *
 * @package LoanMatching
 */

/* ════════════════════════════════════════════
   CSS 自訂變數（可被 Elementor Global Colors 覆蓋）
   ════════════════════════════════════════════ */
:root {
	--lm-primary:        #2563EB;   /* 主色：藍 */
	--lm-primary-dark:   #1D4ED8;
	--lm-success:        #16A34A;   /* 成功：綠 */
	--lm-warning:        #D97706;   /* 警告：橘 */
	--lm-danger:         #DC2626;   /* 危險：紅 */
	--lm-locked:         #7C3AED;   /* 鎖定：紫 */
	--lm-border:         #E5E7EB;
	--lm-bg-light:       #F9FAFB;
	--lm-text:           #1F2937;
	--lm-text-muted:     #6B7280;
	--lm-radius:         8px;
	--lm-shadow:         0 1px 3px rgba(0,0,0,.1);
	--lm-shadow-hover:   0 4px 12px rgba(0,0,0,.15);
	--lm-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ════════════════════════════════════════════
   頁面外層包裝（確保左右上下有足夠留白）
   ════════════════════════════════════════════ */
.lm-page-wrap {
	max-width: 860px;
	margin: 0 auto;
	padding: 36px 24px 48px;
	box-sizing: border-box;
}

/* ════════════════════════════════════════════
   頂列（問候語 + 登出按鈕）
   ════════════════════════════════════════════ */
.lm-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
	padding-bottom: 16px;
	border-bottom: 1px solid var(--lm-border);
}

.lm-topbar__greeting {
	font-size: .95rem;
	color: var(--lm-text-muted);
}

.lm-btn--logout {
	padding: 7px 16px;
	font-size: .875rem;
	font-weight: 600;
	border-radius: 6px;
	border: 1px solid #FECACA;
	background: #FEF2F2;
	color: var(--lm-danger);
	cursor: pointer;
	text-decoration: none;
	transition: background .2s, border-color .2s;
	line-height: 1;
}

.lm-btn--logout:hover {
	background: #FEE2E2;
	border-color: #FCA5A5;
	color: var(--lm-danger);
}

/* ════════════════════════════════════════════
   全域 Dashboard 容器
   ════════════════════════════════════════════ */
.lm-dashboard {
	font-family: var(--lm-font);
	color: var(--lm-text);
}

/* ════════════════════════════════════════════
   卡片元件
   ════════════════════════════════════════════ */
.lm-card {
	background: #fff;
	border: 1px solid var(--lm-border);
	border-radius: var(--lm-radius);
	box-shadow: var(--lm-shadow);
	overflow: hidden;
	margin-bottom: 24px;
	transition: box-shadow .2s ease;
}

.lm-card:hover {
	box-shadow: var(--lm-shadow-hover);
}

.lm-card__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 24px;
	background: var(--lm-bg-light);
	border-bottom: 1px solid var(--lm-border);
}

.lm-card__header h2 {
	margin: 0;
	font-size: 1.15rem;
	font-weight: 600;
	color: var(--lm-text);
}

.lm-card__body {
	padding: 24px;
}

.lm-card__image {
	text-align: center;
	margin-bottom: 16px;
}

.lm-business-image {
	max-width: 200px;
	max-height: 200px;
	border-radius: var(--lm-radius);
	object-fit: cover;
	border: 2px solid var(--lm-border);
}

/* ════════════════════════════════════════════
   資料表格
   ════════════════════════════════════════════ */
.lm-data-table {
	width: 100%;
	border-collapse: collapse;
	font-size: .95rem;
}

.lm-data-table th,
.lm-data-table td {
	padding: 10px 12px;
	border-bottom: 1px solid var(--lm-border);
	text-align: left;
	vertical-align: top;
}

.lm-data-table th {
	width: 30%;
	font-weight: 600;
	color: var(--lm-text-muted);
	white-space: nowrap;
}

.lm-data-table tr:last-child th,
.lm-data-table tr:last-child td {
	border-bottom: none;
}

/* ════════════════════════════════════════════
   Badge（狀態標籤）
   ════════════════════════════════════════════ */
.lm-badge {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: .8rem;
	font-weight: 600;
	line-height: 1.4;
}

.lm-badge--locked {
	background: #EDE9FE;
	color: var(--lm-locked);
}

.lm-badge--pending {
	background: #FEF3C7;
	color: var(--lm-warning);
}

.lm-badge--success {
	background: #D1FAE5;
	color: var(--lm-success);
}

/* ════════════════════════════════════════════
   通知訊息
   ════════════════════════════════════════════ */
.lm-notice {
	padding: 16px 20px;
	border-radius: var(--lm-radius);
	margin: 16px 0;
	border-left: 4px solid transparent;
}

.lm-notice p {
	margin: 0;
	line-height: 1.6;
}

.lm-notice--info {
	background: #EFF6FF;
	border-color: var(--lm-primary);
	color: #1E40AF;
}

.lm-notice--success {
	background: #F0FDF4;
	border-color: var(--lm-success);
	color: #166534;
}

.lm-notice--warning {
	background: #FFFBEB;
	border-color: var(--lm-warning);
	color: #92400E;
}

.lm-notice--error {
	background: #FEF2F2;
	border-color: var(--lm-danger);
	color: #991B1B;
}

/* ════════════════════════════════════════════
   補充表單
   ════════════════════════════════════════════ */
.lm-supplement-form {
	background: #fff;
	border: 1px solid var(--lm-border);
	border-radius: var(--lm-radius);
	padding: 24px;
	margin-top: 24px;
}

.lm-supplement-form h3 {
	margin: 0 0 8px;
	font-size: 1.05rem;
	font-weight: 600;
}

.lm-form-notice {
	font-size: .875rem;
	margin-bottom: 20px;
	padding: 10px 14px;
	border-radius: 6px;
	/* 預設紅色（警告用） */
	color: var(--lm-danger);
	background: #FEF2F2;
	border-left: 3px solid var(--lm-danger);
}

/* 藍色提示（借款人可修改的說明）*/
.lm-form-notice--info {
	color: #1E40AF;
	background: #EFF6FF;
	border-left-color: var(--lm-primary);
}

/* ── 表單群組 ── */
.lm-form__group {
	margin-bottom: 18px;
}

.lm-form__group label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
	font-size: .9rem;
	color: var(--lm-text);
}

.lm-required {
	color: var(--lm-danger);
}

.lm-form__group input[type="text"],
.lm-form__group input[type="number"],
.lm-form__group input[type="tel"],
.lm-form__group select,
.lm-form__group textarea {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--lm-border);
	border-radius: 6px;
	font-size: .95rem;
	font-family: var(--lm-font);
	color: var(--lm-text);
	box-sizing: border-box;
	transition: border-color .2s;
}

.lm-form__group input:focus,
.lm-form__group select:focus,
.lm-form__group textarea:focus {
	outline: none;
	border-color: var(--lm-primary);
	box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.lm-form__group textarea {
	resize: vertical;
	min-height: 120px;
}

/* ── 表單區塊小標題 ── */
.lm-form__section-title {
	font-size: .875rem;
	font-weight: 700;
	color: var(--lm-text-muted);
	text-transform: uppercase;
	letter-spacing: .05em;
	margin: 24px 0 12px;
	padding-bottom: 6px;
	border-bottom: 1px solid var(--lm-border);
}

.lm-form__section-title:first-of-type {
	margin-top: 4px;
}

/* ── Select 樣式 ── */
.lm-select {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--lm-border);
	border-radius: 6px;
	font-size: .95rem;
	font-family: var(--lm-font);
	color: var(--lm-text);
	background-color: #fff;
	box-sizing: border-box;
	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='%236B7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 36px;
	cursor: pointer;
	transition: border-color .2s;
}

.lm-select:focus {
	outline: none;
	border-color: var(--lm-primary);
	box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── 圖片上傳區 ── */
.lm-media-upload-wrap {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.lm-upload-btn {
	align-self: flex-start;
}

.lm-image-preview img {
	max-width: 180px;
	max-height: 180px;
	border-radius: var(--lm-radius);
	border: 2px dashed var(--lm-border);
	object-fit: cover;
	display: block;
	margin-top: 4px;
}

/* ════════════════════════════════════════════
   按鈕
   ════════════════════════════════════════════ */
.lm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 22px;
	border-radius: 6px;
	font-size: .95rem;
	font-weight: 600;
	cursor: pointer;
	border: none;
	transition: background .2s, transform .1s;
	text-decoration: none;
	line-height: 1;
}

.lm-btn:active {
	transform: translateY(1px);
}

.lm-btn--primary {
	background: var(--lm-primary);
	color: #fff;
}

.lm-btn--primary:hover {
	background: var(--lm-primary-dark);
	color: #fff;
}

.lm-btn--secondary {
	background: var(--lm-bg-light);
	color: var(--lm-text);
	border: 1px solid var(--lm-border);
}

.lm-btn--secondary:hover {
	background: var(--lm-border);
}

.lm-btn:disabled {
	opacity: .6;
	cursor: not-allowed;
}

/* ════════════════════════════════════════════
   表單送出中 Loading 動畫
   ════════════════════════════════════════════ */
.lm-btn--loading::after {
	content: '';
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255,255,255,.5);
	border-top-color: #fff;
	border-radius: 50%;
	animation: lm-spin .6s linear infinite;
	margin-left: 8px;
}

@keyframes lm-spin {
	to { transform: rotate(360deg); }
}

/* ════════════════════════════════════════════
   後台管理頁面補充樣式
   ════════════════════════════════════════════ */
.lm-admin-wrap .form-table th {
	width: 220px;
}

.lm-admin-wrap h2 {
	border-bottom: 2px solid var(--lm-border);
	padding-bottom: 8px;
}

/* ════════════════════════════════════════════
   RWD：手機版
   ════════════════════════════════════════════ */
@media ( max-width: 600px ) {
	.lm-card__header {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.lm-data-table th {
		width: 40%;
		font-size: .85rem;
	}

	.lm-data-table th,
	.lm-data-table td {
		padding: 8px 6px;
	}
}
