/* CSS 基本卡片與輸入組件樣式 */

/* 只讓最外層的 .bazi-card 保留金黃色邊框 */
.bazi-card {
    border: 2px solid #d4af37 !important;
    border-radius: 12px !important;
    padding: 15px !important;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    box-sizing: border-box !important;
    max-width: 1200px;
    margin: 10px auto;
    font-family: "PingFang TC", "Microsoft JhengHei", sans-serif;
    position: relative;
}

/* 確保裡面的小區域不要多出黃色外框 */
#bazi-result-area,
.bazi-result-box {
    border: none !important;
    box-shadow: none !important;
    background-color: transparent !important;
    padding: 0 !important;
}

.bazi-copyright { position: absolute; top: 10px; right: 15px; font-size: 13px; color: #b8860b; font-weight: bold; }
.bazi-input { text-align: center; margin-bottom: 15px; border-bottom: 2px solid #f4f1ea; padding-bottom: 20px; padding-top: 15px; box-sizing: border-box; }

.dual-calendar-container { display: flex; flex-direction: column; gap: 15px; width: 100%; max-width: 600px; margin: 0 auto 15px auto; }
.calendar-section-box { background: #fdfaf2; border: 1px solid #e8dfc4; border-radius: 12px; padding: 15px; text-align: left; box-sizing: border-box; }
.calendar-section-box.solar-box { border-left: 5px solid #d4af37; }
.calendar-section-box.lunar-box { border-left: 5px solid #8b572a; }
.section-title { font-size: 17px; font-weight: bold; color: #5d4037; margin-bottom: 8px; display: inline-block; vertical-align: middle; }

.ios-switch-wrapper { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 5px; }
.ios-switch { position: relative; display: inline-block; width: 54px; height: 30px; vertical-align: middle; flex-shrink: 0; }
.ios-switch input { opacity: 0; width: 0; height: 0; }
.ios-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #e5e5ea; transition: .3s; border-radius: 34px; }
.ios-slider:before { position: absolute; content: ""; height: 24px; width: 24px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 3px 8px rgba(0,0,0,0.15); }
.ios-switch input:checked + .ios-slider { background-color: #34c759; }
.ios-switch input:checked + .ios-slider:before { transform: translateX(24px); }
.lunar-fold-content { display: none; margin-top: 15px; border-top: 1px dashed #e8dfc4; padding-top: 15px; }

#birth-time, .bazi-input input[type="number"], .bazi-input input[type="time"], #zi-hour-mode {
    height: 46px !important; line-height: 42px !important; border: 2px solid #d4af37 !important;
    border-radius: 8px !important; font-size: 17px !important; font-weight: bold !important;
    background: #fff !important; color: #332200 !important; box-sizing: border-box !important;
    padding: 0 8px !important; margin: 0 !important; -webkit-appearance: none;
}
#birth-time { width: 100% !important; display: block !important; }
.zi-hour-wrapper { width: 100%; max-width: 600px; margin: 0 auto 15px auto; text-align: left; }
#zi-hour-mode { width: 100% !important; cursor: pointer !important; background: #fffaf0 !important; }
.lunar-grid-row { display: grid !important; grid-template-columns: 1.1fr 1fr 1fr 1.4fr !important; gap: 6px !important; width: 100% !important; box-sizing: border-box; }
.input-col { position: relative; display: flex; flex-direction: column; width: 100% !important; box-sizing: border-box; }
.bazi-input input[type="number"].text-center { text-align: center !important; padding-left: 20px !important; padding-right: 2px !important; width: 100% !important; }
.bazi-input input[type="time"] { padding-left: 5px !important; width: 100% !important; font-size: 16px !important; }
.unit-tag { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); font-size: 13px; color: #999; font-weight: bold; pointer-events: none; z-index: 5; }
.leap-mini-box { margin-top: 12px; padding-top: 8px; border-top: 1px dashed #e8dfc4; display: flex; align-items: center; }
.leap-checkbox-label { display: flex; align-items: center; cursor: pointer; font-size: 15px; color: #ae8100; font-weight: bold; }
.leap-checkbox-label input { margin-right: 8px; transform: scale(1.2); cursor: pointer; }

.control-switch-container { display: flex; flex-direction: column; gap: 12px; max-width: 600px; margin: 15px auto; }
.ios-row-box { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; background: #fffdf9; border: 1px solid #e8dfc4; border-radius: 12px; box-sizing: border-box; }
.switch-info-text { font-weight: bold; color: #5d4037; font-size: 16px; }
.solar-section { max-width: 600px; margin: -5px auto 15px auto; padding: 15px; border: 2px solid #f4f1ea; border-radius: 12px; background-color: #fdfaf2; text-align: left; box-sizing: border-box; }
.solar-content-box { padding: 12px; background: #fdfdfd; border: 1px solid #f0f0f0; border-radius: 6px; min-height: 40px; }

.btn-group { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 10px; }
.gender-btn { width: 65px; height: 65px; border-radius: 50%; border: 2px solid #ccc; font-size: 18px; font-weight: bold; cursor: pointer; background: #fff; }
.submit-btn { width: 95px; height: 95px; border-radius: 50%; background: linear-gradient(145deg, #ffd700, #d4af37); color: #5d4037; border: 3px solid #b8860b; font-size: 18px; font-weight: bold; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.gender-btn.active[data-gender="1"] { background: #0056b3; color: #fff; border-color: #004085; }
.gender-btn.active[data-gender="0"] { background: #d63638; color: #fff; border-color: #b52a2c; }

/* ==========================================
   八字排盤 - 柱位基本樣式與 5 層結構
   ========================================== */
.matrix-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
}

.bazi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    min-width: 0;
}

.bazi-grid-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    min-width: 0;
}

.bazi-cell {
    background-color: transparent;
    border: 1px solid #cbccb8;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    text-align: center;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* 1. 第一行 (節氣/年齡資訊) 保持透明底 */
.bazi-cell > div:first-child,
.bazi-cell .cell-row-1 {
    background-color: transparent !important;
    border-bottom: 1px solid #e0e0e0;
    padding: 2px 0;
}

/* 2. 第二行 (時柱、日柱... 標題列) 置中 + 淺灰背景 */
.bazi-cell > div:nth-child(2),
.bazi-cell .cell-row-2 {
    background-color: #f4f5f7 !important;
    border-bottom: 1px solid #cbccb8;
    padding: 4px 0;
    font-weight: bold;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 28px;
}

/* 柱內 5 層固定高度與字體優化 */
.cell-row-1 { height: 32px; line-height: 32px; font-size: 15px; font-weight: bold; color: #4a5568; background: transparent; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: center; }
.cell-row-2 { height: 30px; line-height: 30px; font-size: 15px; font-weight: bold; color: #2d3748; border-bottom: 1px solid #e2e8f0; }
.cell-row-3 { height: 95px; padding: 4px 0; border-bottom: 1px solid #e2e8f0; display: flex; flex-direction: column; justify-content: center; }
.cell-row-4 { height: 75px; padding: 4px 0; border-bottom: 1px solid #e2e8f0; font-size: 14px; display: flex; flex-direction: column; justify-content: flex-start; }
.cell-row-5 { height: 55px; padding: 4px 0; font-size: 13px; color: #d63638; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }

/* 上方主命盤八字核心大字 */
.char-main {
    font-size: 30px;
    line-height: 33px;
    height: 33px;
    font-weight: bold;
    text-align: center;
    width: 100%;
}
.ss-top-text { font-size: 13px; color: #718096; }

/* 隱藏神煞時保持高度不變 */
.shensha-hidden { visibility: hidden !important; }

/* Tag/Button 開關標籤 */
.tag-btn {
    display: inline-block;
    padding: 4px 12px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 12px;
    background-color: #e2e8f0;
    color: #4a5568;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    border: 1px solid #cbd5e0;
}
.tag-btn.active {
    background-color: #3182ce;
    color: #ffffff;
    border-color: #2b6cb0;
}

.eye-btn {
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e2e8f0;
    transition: background 0.2s;
}
.eye-btn:hover { background: #cbd5e0; }

/* 下方 12 大運 / 流年 / 流月 / 流日 / 流時 橫向選擇排版 */
.layer-row-container {
    display: flex;
    align-items: stretch;
    margin-bottom: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.layer-row-title {
    width: 60px;
    min-width: 60px;
    background-color: #e8e8e8;
    color: #4a5568;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px 0 0 6px;
    border: 1px solid #cbd5e0;
    border-right: none;
}
.layer-row-boxes {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 2px;
}

/* ==========================================
   運勢方向切換 (左順/右順) - 連標題一齊反轉
   ========================================== */
/* 1. 整個橫排反轉 (標題移去右邊) */
.layer-row-container.is-reversed {
    flex-direction: row-reverse !important;
}

/* 2. 入面啲年份格仔順序反轉 (由右至左排) */
.layer-row-container.is-reversed .layer-row-boxes {
    flex-direction: row-reverse !important;
    justify-content: flex-start !important; /* 確保格仔貼近右邊標題 */
}

/* 3. 調整標題嘅左右間距 (視乎你原本設定，將右邊空位轉去左邊) */
.layer-row-container.is-reversed .layer-row-title {
    margin-right: 0 !important;
    margin-left: 10px !important;
}


/* ==========================================
   運勢標題直排與瘦身 (大運/流年/流月等)
   ========================================== */
.layer-row-title {
    writing-mode: vertical-rl; /* 啟用直排模式 (由上至下) */
    text-orientation: upright; /* 確保中文字體正向顯示 */
    width: 36px !important;    /* 強制縮窄灰柱寬度，達到瘦身效果 */
    min-width: 36px !important;
    padding: 12px 0 !important; /* 移除左右多餘空白，增加上下空間 */
    letter-spacing: 4px;       /* 讓文字之間保留少少間距，更加美觀 */
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* ==========================================
   統一所有運勢橫排（大運至流時）的高度
   ========================================== */
/* 1. 統一右邊所有流年/流月/流時格仔嘅高度 */
.layer-row-boxes > div {
    min-height: 105px !important; /* 你可以根據喜好微調呢個數值，例如改做 110px 或 130px */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;  /* 確保入面嘅文字統一由頂部開始向下排，唔會高低不平 */
}

/* 2. 確保左邊嘅直排標題框高度都同右邊格仔一致 */
.layer-row-title {
    min-height: 105px !important; /* 呢個數值要同上面嘅 min-height 一樣 */
}

.layer-box {
    min-width: 65px;
    padding: 4px;
    text-align: center;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.layer-box div > span:first-child {
    font-size: 22px !important;
    line-height: 1.2 !important;
}

.layer-box.active {
    background-color: #feebc8;
    border-color: #dd6b20;
    box-shadow: 0 0 0 1px #dd6b20;
}

#bazi-info { margin-top: 25px; padding: 20px; background: #fdfaf2; border: 2px solid #d4af37; border-radius: 12px; text-align: left; line-height: 2.0; font-size: 16px; font-weight: bold; }

/* ==========================================
   響應式 (RWD) 窄螢幕防爆框優化
   ========================================== */
@media screen and (max-width: 768px) {
    .char-main { font-size: 22px !important; }
    
    .bazi-cell {
        min-width: 0 !important;
        padding: 2px 1px !important;
    }
    
    .cell-row-1, .cell-row-2 {
        font-size: 12px !important;
    }
}

/* 強制原局命盤的 4 柱網格（bazi-grid）絕對只顯示前 4 個格子，多出的強制隱藏 */
#bazi-result-area .bazi-grid .bazi-cell:nth-child(n+5) {
    display: none !important;
}


[id^="dyn-meta-"] {
    display: inline-block !important;
    text-align: center !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    
    /* 固定的上下內距，確保雙行文字完美置中 */
    padding-top: 3px !important;
    padding-bottom: 3px !important;
    
    height: 34px !important;         /* 鎖死高度，避免任何走位 */
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* ==========================================
   運勢格仔：內容置中及加入分隔虛線
   ========================================== */
/* 1. 確保格仔內所有內容橫向置中 */
.layer-row-boxes > div {
    align-items: center !important; /* 讓內部元素橫向置中 */
    text-align: center !important;  /* 讓文字本身置中 */
}

/* 2. 在上方時間/年份與下方干支之間加入虛線 */
/* 呢度假設上方嘅「歲數/年份/日期」係格仔入面嘅第一個區塊 */
.layer-row-boxes > div > *:first-child {
    border-bottom: 1px dotted #8d8888 !important; /* 淺灰色虛線 */
    width: 96% !important;                     /* 虛線寬度 (如果想連住邊緣可以改做 100%) */
    padding-bottom: 8px !important;            /* 虛線同上方文字嘅距離 */
    margin-bottom: 8px !important;             /* 虛線同下方干支嘅距離 */
    display: flex;
    flex-direction: column;
    align-items: center;
}
