/* ==========================================================================
   assets/css/main.css - 全站統一風格藍本 (整合優化版)
   ========================================================================== */

/* --- 基礎環境設定 --- */
body {
    font-family: "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f4f7f6;
    color: #2d3748;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    box-sizing: border-box;
}

/* --- 內容容器 --- */
.container {
    width: 100%;
    max-width: 1100px; /* 列表頁最大寬度 */
    margin: 0 auto;
}

/* 針對新增/編輯等表單頁面的容器微調限制（選用，維持表單精緻感） */
.container-form {
    max-width: 850px;
}

/* --- 標題風格 --- */
h2, h3 {
    color: #1a202c;
    margin-bottom: 20px;
}
h2 {
    font-size: 1.5rem;
}

/* --- 統一卡片外觀 --- */
.card {
    background: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

/* --- 彈性網格排版 (Grid 系統) --- */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}
.full-width { grid-column: span 3; }
.half-width { grid-column: span 2; }

/* --- 彈性表單排版 (Flex 系統) --- */
.form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}
.form-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}
.form-item.full-width {
    flex: 1 1 100%;
}
.form-item strong {
    font-size: 0.85rem;
    color: #4a5568;
}

/* --- 表單基本標籤與提示 --- */
label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #2d3748;
    font-size: 14px;
}
.required-field::after {
    content: " *";
    color: #e74c3c;
}

/* --- 統一輸入框、下拉選單、文字框樣式 --- */
input[type="text"], 
input[type="number"], 
input[type="password"], 
input[type="date"],
select {
    width: 100%;
    height: 44px; /* 統一舒適高度 */
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 14px;
    background-color: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
    width: 100%;
    height: 80px; /* 統一文字框高度 */
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 14px;
    background-color: #fff;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* 輸入框聚焦 (Focus) 藍色風格 */
input:focus, select:focus, textarea:focus {
    border-color: #3182ce;
    box-shadow: 0 0 0 1px #3182ce;
}

/* 唯讀/禁用輸入框 */
.readonly-input, input[readonly] {
    background: #edf2f7 !important;
    color: #2b6cb0;
    font-weight: bold;
    cursor: not-allowed;
}

/* --- 單選與複選區塊樣式 --- */
.opt-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    background: #f8fafc;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e0;
    min-height: 40px;
    align-items: center;
    box-sizing: border-box;
}
.opt-group label {
    font-weight: normal;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 0;
    cursor: pointer;
    font-size: 13px;
}
.opt-group input[type="radio"], 
.opt-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* --- 動態新增分類區塊 --- */
.dynamic-input {
    display: none;
    margin-top: 10px;
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3182ce;
}

/* --- 按鈕操作列 --- */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    border-top: 1px solid #edf2f7;
    padding-top: 20px;
    margin-top: 10px;
    margin-bottom: 20px;
}

/* --- 統一按鈕基礎樣式 --- */
.btn-green, .btn-gray {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;            /* 精準設定標準高度 */
    padding: 0 24px;         /* 左右舒適內距 */
    min-width: 160px;        /* 確保文字與 Emoji 完美展開不擠壓 */
    border: none;
    box-sizing: border-box;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;     /* 絕不折行 */
    border-radius: 8px;
    gap: 8px;                /* 圖示與文字間的間距 */
    transition: all 0.2s ease;
}

/* 綠色確認按鈕 */
.btn-green { 
    background: #27ae60; 
    color: white; 
    box-shadow: 0 2px 4px rgba(39, 174, 96, 0.2);
}
.btn-green:hover { 
    background: #219150; 
    transform: translateY(-1px); /* 懸停微微浮起 */
    box-shadow: 0 4px 6px rgba(39, 174, 96, 0.3);
}

/* 灰色取消返回按鈕 */
.btn-gray { 
    background: #718096; 
    color: white; 
    box-shadow: 0 2px 4px rgba(113, 128, 150, 0.2);
}
.btn-gray:hover { 
    background: #4a5568; 
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(113, 128, 150, 0.3);
}

/* 按鈕點擊共同回饋 (下壓動效) */
.btn-green:active, .btn-gray:active {
    transform: translateY(0);
}

/* --- 錯誤提示方框 --- */
.error-box {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: bold;
}

/* --- 統一資料表格樣式 --- */
.main-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}
.main-table th, .main-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}
.main-table th {
    background-color: #f7fafc;
    color: #4a5568;
    font-weight: bold;
}
.main-table tr:hover {
    background-color: #f8fafc;
}