@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@100;200;400;500;600;700&display=swap');

/* ========== CSS 變數定義 ========== */
:root {
    --color-txt: #3d3c3c;
    --primary-default: #f39386;
    --primary-tint: #f8c4bd;
    --primary-dark: #c85252;
    --secondary-light: #d2eaed;
    --gray-gray100: #8B8984;
    --gray-tint: #e7e7e7;
    --background: #F9F9F9;
    --maintitle: 30px;
    --subtitle: 20px;
}

/* ========== 全局重置 ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans TC', sans-serif;
}

body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--background);
    color: #222;
}

label:hover{
    color:var(--primary-default);
    cursor:pointer;
    transition:all 10ms linear;
}

/* ========== Header & Footer ========== */
header,
footer {
    width: 100%;
    height: 16px;
    background-color: var(--primary-tint);
    box-shadow: 0 0 4px 0px #1f1f1f24;
}

/* ========== 容器 ========== */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 36px auto;
    padding: 0 20px;
}

.header-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-container {
    background: url('../../../Logo_Main.png') no-repeat center;
    background-size: contain;
    width: 45%;
    height: 80px;
}

/* ========== 標題 ========== */
h3 {
    margin: 2% 0;
    color: var(--primary-dark);
    font-size: var(--maintitle);
    text-align: center;
    font-weight:600;
}

.subtitle {
    font-size: var(--subtitle);
    font-weight: 700;
    letter-spacing: 1.2px;
}

/* ========== 表單區塊 ========== */
.block {
    margin: auto;
    width: 100%;
    max-width: 1320px;
    height: fit-content;
    border-radius: 30px;
    background-color: #FFFFFF;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 4px 0px #1f1f1f24;
}

.top {
    width: 100%;
    padding: 28px 68px;
    background-color: var(--secondary-light);
    border-radius: 30px 30px 0 0;
}

.main {
    margin: 32px 68px 56px;
    color: var(--color-txt);
}

/* ========== 表單區段 ========== */
.form-section {
    margin-bottom: 32px;
    border: 1px solid var(--gray-tint);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.section-heading {
    padding: 14px 20px;
    background: var(--secondary-light);
    color: #306167;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}

.section-note {
    margin: 14px 20px 0;
    color: var(--gray-gray100);
    line-height: 1.7;
}

/* ========== 表單網格 ========== */
.form-grid {
    display: grid;
    gap: 20px 28px;
    padding: 20px;
}

.form-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.one-col {
    grid-template-columns: 1fr;
}

/* ========== 表單欄位 ========== */
.row {
    display: flex;
    align-items: center;
}

.row label{
    width:100%;
}

.row span {
    text-wrap: nowrap;
}

.field {
    min-width: 0;
}

.field.full {
    grid-column: 1 / -1;
}

.field.compact-field {
    margin-top: -12px;
}

.field-title, .field-label {
    display:inline-block;
    font-weight: 600;
}

.field-label{
    font-size: 16px;
    color:var(--color-txt);
}

.field-title {
    font-size: 18px;
    color: #3e8d97;
}

.note {
    margin-top: 15px;
    padding: 14px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 6px;
    font-size: 14px;
}

/* =========================
   土地表格
   ========================= */

.table-wrapper{
    width:100%;
    overflow-x:auto;
}

.land-table {
    width: 100%;
    min-width: 1170px;
    border-collapse: collapse;
    table-layout: fixed;
    color: #333;
}

.land-table th {
    background-color: var(--secondary-light);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5;
}

.land-table th, .land-table td {
    border: 1px solid #aaa;
    text-align: center;
    vertical-align: middle;
    padding: 4px;
}

/* ========== card卡片樣式 ========== */
.card {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card.is-collapsed .card-body{
    display:none;
}

.card.is-collapsed .card-header{
    border:none;
    margin-bottom:0;
    padding-bottom:0;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #007bff;
    margin-bottom: 12px;
    padding-bottom: 12px;
}

.card-header .remove-btn{
    max-width:85px;
}

.count-header{
    font-size:14px;
}

.count-title {
    font-size: 20px;
    font-weight: 600;
    color: #007bff;
}

/*新增、移除欄位按鈕樣式*/
.actions {
    display: flex;
    align-items: center;
    gap:0.5rem;
}

.toggle-btn {
    --btn-bg-color: #007bff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--btn-bg-color,#007bff);
    border-radius: 4px;
    background: #fff;
    color: var(--btn-bg-color,#007bff);
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    transition: transform 0.2s, background 0.2s;
}

.card.is-collapsed .toggle-btn {
    transform: rotate(-90deg);
}

.add-btn {
    --btn-bg-color: #28a745;
    --btn-hover-bg-color: #218838;
}

.remove-btn {
    --btn-bg-color: #dc3545;
    --btn-hover-bg-color: #c82333;
}

.collapse-btn {
    --btn-bg-color: #007bff;
    --btn-hover-bg-color: #0b56a7;
}

.add-btn, .remove-btn, .collapse-btn {
    padding: 5px 15px;
    border: none;
    border-radius: 4px;
    background-color: var(--btn-bg-color,transparent);
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

:is(.add-btn,.remove-btn,.collapse-btn):not(:disabled):hover {
    background-color: var(--btn-hover-bg-color);
}

:is(.add-btn,.remove-btn,.collapse-btn):disabled {
    --btn-border-color: #878787;
    --btn-bg-color: #5f5f5f14;
    border: 1px solid var(--btn-border-color);
    color: var(--btn-border-color);
}

/* ========== 輸入框樣式 ========== */
input:not([type="checkbox"],[type="radio"]),
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    height: 44px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--gray-tint, #E7E7E7);
    color: #111;
    outline: none;
    font-size: 14px;
    transition: all 0.2s;
}

input:not([type="checkbox"],[type="radio"]):focus,
textarea:focus,
select:focus {
    border-color: var(--primary-default, #f39386);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(243 147 134 / 0.31);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background: #f0f0f0;
}

textarea {
    height: auto;
    min-height: 80px;
    padding: 10px;
    resize: vertical;
}

/* ========== 地址輸入 ========== */
.address-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
}

.address-inputs .postal {
    width: 100px;
    flex-shrink: 0;
}

.address-inputs input:not(.postal) {
    flex: 1;
    min-width: 200px;
}

/* ========== 日期輸入 ========== */
.date-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.date-inputs input {
    width: 80px;
    text-align: center;
}

.date-inputs span {
    color: #666;
    font-size: 14px;
}

/* ========== Radio & Checkbox ========== */
input[type="radio"],
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    aspect-ratio:1;
    margin: 0;
    border: 2px solid #999;
    position: relative;
    cursor: pointer;
    transition: border-color 0.2s ease;
    flex-shrink: 0;
    margin-right:4px;
}
input[type="radio"] {
    border-radius: 50%;
}

input[type="checkbox"] {
    border-radius: 4px;
}

input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-default);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s ease;
}

input[type="radio"]:checked {
    border-color: var(--primary-default);
}

input[type="radio"]:checked::after {
    transform: translate(-50%, -50%) scale(1);
}

label:hover input[type="radio"] {
    border-color: var(--primary-default);
}

input[type="radio"]:focus-visible {
    outline: 2px solid var(--primary-default);
    outline-offset: 2px;
}

input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 9px;
    height: 16px;
    border: solid #fff;
    border-width: 0 3px 3px 0;
    transform: translate(-50%, -60%) rotate(45deg) scale(0);
    transition: transform 0.15s ease;
}

input[type="checkbox"]:checked {
    border-color: var(--primary-default);
    background-color: var(--primary-default);
}

input[type="checkbox"]:checked::after {
    transform: translate(-50%, -60%) rotate(45deg) scale(1);
}

label:hover input[type="checkbox"] {
    border-color: var(--primary-default);
}

input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--primary-default);
    outline-offset: 2px;
}

.choice-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}


/* ========== 按鈕樣式 ========== */
button,
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

button:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-default);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: #138496;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.section-desc {
    margin: 30px 0 16px;
    color: #222;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.8;
}

/* ========== 下載區域 ========== */
.download-area {
    display: flex;
    width: 100%;
    margin-top: 20px;
    align-items: center;
    justify-content: center;
}

.download-area #download {
    display: block;
    width: 159px;
    height: 45px;
    margin: 0;
    border: 0;
    border-radius: 4px;
    background-color: var(--primary-default);
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    letter-spacing: 2px;
}

    .download-area #download:hover {
        filter: brightness(0.95);
    }

/* ========== 表格樣式 ========== */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: white;
}

.doc-table th,
.doc-table td {
    border: 1px solid #333;
    padding: 10px;
    text-align: left;
}

.doc-table th {
    background-color: #e9ecef;
    font-weight: bold;
}

.doc-table tbody tr:hover {
    background-color: #f8f9fa;
}

.doc-col-no {
    width: 60px;
    text-align: center;
}

.doc-col-name {
    width: auto;
}

.doc-col-count {
    width: 100px;
    text-align: center;
}

.doc-count {
    width: 60px;
    text-align: center;
    padding: 5px;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

/* ========== 警示訊息 ========== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 16px 0;
    border-left: 4px solid;
}

.alert-info {
    background: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.alert-danger {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.alert-success {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

/* 即時檢核紅字提示與錯誤外框樣式 */
.field-error-msg {
    display: block;
    color: #dc3545;
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.4;
}

input.is-invalid {
    border-color: #dc3545 !important;
    background-color: #fff8f8 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15) !important;
}

/* ========== 工具類別 ========== */
.is-hidden {
    display: none !important;
}

.is-active {
    display: block !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

/* ========== 響應式設計 ========== */
@media (max-width: 900px) {
    .main {
        margin: 24px 24px 40px;
    }

    .form-grid.two-col {
        grid-template-columns: 1fr;
    }

    .address-inputs,
    .date-inputs {
        flex-wrap: wrap;
    }
}

@media (max-width: 520px) {
    .container {
        padding: 0 10px;
    }

    .main {
        margin: 18px 14px 30px;
    }

    .form-grid {
        padding: 14px;
        gap: 14px;
    }

    .date-inputs {
        display:grid;
        grid-template-columns:repeat(3,1fr);
    }

    .date-inputs input{
        width:100%;
    }

    button, .btn {
        width: 100%;
        justify-content: center;
    }

    .actions{
        display:grid;
        grid-template-columns:repeat(2,1fr);
    }
    .add-btn,.collapse-btn,.remove-btn{
        width:100%;
    }
}
