﻿/* =========================================================================
   1. 全域現代化與極致空腔回收（徹底消滅紅框空白 - 豁免優化版）
   ========================================================================= */
body {
    background-color: #f4f7fa;
    font-family: "Segoe UI", "Microsoft JhengHei", Helvetica, Arial, sans-serif;
    color: #1e293b;
    margin: 6px !important;
    line-height: 1.1 !important;
}

/* ❌ 終極斬草除根：消滅空白，但【絕對豁免】DataGrid 內部的任何 tr，防止標題被誤殺 */
table tr:has(td.CONTENTTITLE) + tr:not(:has(table[id*="MyDataGrid"])):not(:has([id*="MyDataGrid"])),
table tr:has(td.CONTENTTITLE) + tr td:not([id*="MyDataGrid"]),
form > table > tbody > tr:nth-child(2):not(:has([id*="MyDataGrid"])),
#spaceImg, img[src*="blank"] {
    display: none !important; /* 🌟 只有真正的無用空白才會被消滅 */
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 🚀 核心大絕招：強迫 DataGrid 內部的所有行 (tr) 與儲存格 (td/th) 滿血復活，徹底破除隱形咒 */
#MyDataGrid tr, #MyDataGrid td, #MyDataGrid th,
table[id*="MyDataGrid"] tr, table[id*="MyDataGrid"] td, table[id*="MyDataGrid"] th {
    display: table-row !important;
}

#MyDataGrid td, #MyDataGrid th,
table[id*="MyDataGrid"] td, table[id*="MyDataGrid"] th {
    display: table-cell !important;
    visibility: visible !important;
}

/* =========================================================================
   2. 報價單明細 大標題：保證橫向一整行不中斷
   ========================================================================= */
.CONTENTTITLE, td.CONTENTTITLE, .CONTENTTITLE span, td.CONTENTTITLE span {
    background: #4c1d95 !important;
    background-color: #4c1d95 !important;
    color: #ffffff !important;
    font-weight: bold !important;
    font-size: 11pt !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    display: inline-block !important;
    height: 26px !important;
    line-height: 26px !important;
    padding: 0 12px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 4px rgba(76, 29, 149, 0.15) !important;
    text-align: left !important;
    width: auto !important;
}

td[bgcolor="seashell"], td[bgColor="seashell"] {
    background: transparent !important;
    background-color: transparent !important;
    width: auto !important;
}

/* =========================================================================
   3. 查詢畫面工具列配置
   ========================================================================= */
td.DEFAULT[bgcolor="aliceblue"], td.DEFAULT[bgColor="aliceblue"], td[bgcolor="aliceblue"] {
    background-color: #f3e8ff !important;
    color: #581c87 !important;
    font-weight: bold !important;
    padding: 3px 6px !important;
    border-radius: 4px;
    font-size: 10.5pt !important;
}

/* =========================================================================
   4. 增修主要輸入表格：行距壓到最緊
   ========================================================================= */
form > table, form table {
    width: auto !important;
    margin-left: 0 !important;
    margin-top: 4px !important;
    border-collapse: collapse !important;
}

    form table tr, form table td {
        padding-top: 1px !important;
        padding-bottom: 1px !important;
        padding-left: 6px !important;
        padding-right: 6px !important;
        vertical-align: middle !important;
        font-size: 10.5pt !important;
        height: 26px !important;
    }

tr[style*="background-color:aliceblue"], tr[style*="background-color: aliceblue"] {
    background-color: #f8fafc !important;
}

/* =========================================================================
   5. 按鈕美化強制作業：🌟 刪除鍵【紅底白字】強力執行
   ========================================================================= */
input[type="submit"], input[type="button"], button, .DEFAULT button, input {
    font-family: "Segoe UI", "Microsoft JhengHei", sans-serif !important;
}

    /* 1. 查詢、分頁按鈕：【深棕色底 + 純白字】 */
    input[type="submit"][value*="查詢"],
    input[type="submit"][value*="新增資料"],
    input[type="submit"][value*="分頁"],
    .DEFAULT input[type="submit"] {
        background: #5c4033 !important;
        color: #ffffff !important;
        padding: 0 10px !important;
        height: 22px !important;
        line-height: 22px !important;
        border: none !important;
        border-radius: 3px !important;
        font-weight: bold !important;
        font-size: 9.5pt !important;
        cursor: pointer !important;
    }

    /* 2. 儲存新增 / 儲存修改 按鈕：【尊爵深紫底 + 純白字】 */
    input[type="submit"][value*="儲存"],
    input[id*="btnSubmit"] {
        background: linear-gradient(135deg, #581c87, #4c1d95) !important;
        color: #ffffff !important;
        padding: 0 12px !important;
        height: 24px !important;
        line-height: 24px !important;
        border: none !important;
        border-radius: 4px !important;
        font-weight: bold !important;
        font-size: 10pt !important;
        cursor: pointer !important;
    }

        input[type="submit"][value*="儲存"]:hover {
            background: #3b0764 !important;
        }

    /* 3. 回查詢畫面按鈕：【古銅深棕底 + 純白字】 */
    input[id*="btnBack"],
    input[value*="回查詢"],
    input[onserverclick*="btnBack"] {
        background: linear-gradient(135deg, #6b5043, #5c4033) !important;
        color: #ffffff !important;
        padding: 0 12px !important;
        height: 24px !important;
        line-height: 24px !important;
        border: none !important;
        border-radius: 4px !important;
        font-weight: bold !important;
        font-size: 10pt !important;
        cursor: pointer !important;
    }

    /* 4. 🌟【核心修正】刪除資料按鈕：強制覆蓋成【高質感量子警示紅底 + 絕對純白字】 */
    input[id*="btnDelete"],
    input[value*="刪除"],
    input[type="submit"][value*="刪除"] {
        background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
        color: #ffffff !important; /* 🌟 強制純白字 */
        font-weight: bold !important;
        padding: 0 12px !important;
        height: 24px !important;
        line-height: 24px !important;
        border: none !important;
        border-radius: 4px !important;
        font-size: 10pt !important;
        cursor: pointer !important;
        display: inline-block !important;
    }

        input[id*="btnDelete"]:hover, input[value*="刪除"]:hover {
            background: #991b1b !important;
        }

    /* 5. 彈窗「查」、「修」小型按鈕 */
    input[id*="btnQS_"], input[value="查"], input[value="修"] {
        background: #4c1d95 !important;
        color: #ffffff !important;
        height: 20px !important;
        line-height: 20px !important;
        border-radius: 3px !important;
        border: none !important;
        font-weight: bold !important;
        padding: 0 6px !important;
        font-size: 9pt !important;
    }

    /* =========================================================================
   6. 增修文字輸入框與下拉選單
   ========================================================================= */
    input[type="text"], select {
        padding: 2px 4px !important;
        height: 22px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 3px !important;
        background-color: #ffffff !important;
        color: #0f172a !important;
        font-size: 10pt !important;
    }

/* =========================================================================
   7. DataGrid 表格（全系統萬能自適應、高密度對齊終極版）
   ========================================================================= */
#MyDataGrid, .MyDataGrid, table[id*="MyDataGrid"] {
    border-collapse: collapse !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    background-color: #ffffff !important;
    margin-top: 4px;
    /* 🌟 緊湊關鍵：寬度使用 max-content 或 auto，強迫表格緊緊貼著數據，絕不盲目拉寬！ */
    width: max-content !important;
    max-width: 100% !important;
    table-layout: auto !important; /* 釋放鎖死，讓標題與明細欄位自動一對一嚙合 */
}

    /* 1. 上下分頁按鈕列 (Pager)：獨立淡色，優雅靠軸 */
    #MyDataGrid tr:has(td[style*="HorizontalAlign"]) td,
    #MyDataGrid tr[align="center"] td,
    table[id*="MyDataGrid"] tr:first-child td[colspan] {
        background: #f8fafc !important;
        color: #4c1d95 !important;
        font-weight: bold !important;
        font-size: 10pt !important;
        text-align: center !important;
        padding: 5px !important;
        height: auto !important;
    }

    #MyDataGrid tr:has(td[style*="HorizontalAlign"]) a,
    table[id*="MyDataGrid"] tr[align="center"] td a {
        color: #2563eb !important;
        text-decoration: underline !important;
        margin: 0 4px !important;
    }

    /* 🌟 2. 萬能標題列裝飾：只要是 DataGrid 的前兩行中，非分頁的那個 tr，就是標題！ */
    #MyDataGrid tr:nth-child(1) td:not([colspan]),
    /*#MyDataGrid tr:nth-child(2) td:not([colspan]),*/
    #MyDataGrid th, table[id*="MyDataGrid"] th,
    .MyDataGridHeader {
        background: linear-gradient(135deg, #4c1d95, #3b0764) !important; /* 尊爵深紫底 */
        color: #ffffff !important;
        font-weight: bold !important;
        padding: 6px 10px !important;
        font-size: 10.5pt !important;
        border: 1px solid #cbd5e1 !important;
        text-align: left !important;
        height: 28px !important;
        white-space: nowrap !important;
    }

        /* 強迫所有標題內文字與超連結化為「絕對純白字」 */
        /* 💡 覆蓋改成這段完全去除 nth-child(2) 的純淨版： */
        #MyDataGrid th a,
        #MyDataGrid th span,
        #MyDataGrid tr td[scope="col"] a,
        .MyDataGridHeader a,
        .MyDataGridHeader span,
        #MyDataGrid tr:nth-child(1) td a,
        #MyDataGrid tr:nth-child(1) td span {
            color: #ffffff !important; /* 🌟 只有真正的第一行欄位標題文字才允許變白 */
            text-decoration: none !important;
            font-weight: bold !important;
            display: inline-block !important;
        }
       /* #MyDataGrid th a, #MyDataGrid th span,
        #MyDataGrid tr td[scope="col"] a, .MyDataGridHeader a, .MyDataGridHeader span,
        #MyDataGrid tr:nth-child(1) td a, #MyDataGrid tr:nth-child(2) td a,
        #MyDataGrid tr:nth-child(1) td span, #MyDataGrid tr:nth-child(2) td span {
            color: #ffffff !important;
            text-decoration: none !important;
            font-weight: bold !important;
            display: inline-block !important;
        }*/

    /* 3. 明細資料列高密度設定（100% 傳統安全版，格線全面明顯黑化） */
    #MyDataGrid tr td,
    table[id*="MyDataGrid"] tr td {
        padding: 4px 8px !important;
        color: #0f172a !important;
        font-size: 10.5pt !important;
        white-space: nowrap !important; /* 💡 保持您這張圖不憋屈折行的最愛外觀 */
        /* 🚀 【核心大改裝】：把四周（上下左右）全部套上明顯的 1px 黑色實線 */
        border: 1px solid black !important;
    }

    /* 3. 明細資料列高密度設定 */
    /*#MyDataGrid tr:not(:has(td[colspan])) td,
    table[id*="MyDataGrid"] tr:not(:has(td[colspan])) td {
        padding: 4px 8px !important;
        border-bottom: 1px solid #e2e8f0 !important;
        border-right: 1px solid #edf2f7 !important;
        color: #0f172a !important;
        font-size: 10.5pt !important;
        white-space: nowrap !important;
    }*/

    /* 滑鼠滑過行高亮 */
    #MyDataGrid tr:hover, table[id*="MyDataGrid"] tr:hover {
        background-color: #f3e8ff !important;
    }