/* ── 產品管理專用：資料卡片表格 (Data Table) ── */
.data-table {
    width: calc(100% - 4px);
    margin: 8px auto;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #003366;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
}
.data-table thead th {
    background: #003366;
    color: #ffffff;
    font-weight: 700;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 15px;
}
.data-table thead th:last-child {
    border-right: none;
}
.data-table tbody td {
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    transition: all 0.2s;
}
.data-table tbody td:last-child {
    border-right: none;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}
.data-table tbody tr:nth-child(even) td {
    background: rgba(248, 250, 252, 0.8);
}
.data-table tbody tr:hover td {
    background: #f1f5f9;
}
.data-table .mobile-text { display: none; }

@media (max-width: 768px) {
    /* 確保在窄螢幕下標題列依然顯示，以符合「所有表格一致」的要求 */
    .data-table thead { display: table-header-group; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: table; width: 100%; border-collapse: collapse; }
    .data-table tr { display: table-row; border: none; }
    .data-table td { display: table-cell; text-align: left; padding: 12px 16px; border-bottom: 1px solid #f1f5f9; position: static; }
    .data-table td::before { display: none; }
}

/* ── 進銷存單據明細：專業輸入表格 (Items Table) ── */
.items-table {
    width: calc(100% - 4px);
    margin: 8px auto;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 15px;
    border: 1px solid #003366;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
}
.items-table th {
    background-color: #003366;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
    font-size: 15px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}
.items-table th.right {
    text-align: right;
}
.items-table th.center {
    text-align: center;
}
.items-table th:last-child {
    border-right: none;
}
.items-table td {
    padding: 5px 6px;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    vertical-align: middle;
}
.items-table td:last-child {
    border-right: none;
}
.items-table tr:nth-child(even) td {
    background-color: rgba(248, 250, 252, 0.8);
}
.items-table tr:hover td {
    background-color: #cbd5e1 !important;
}

/* 明細行與合計區輸入框 (Cell Inputs) */
.cell-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 15px;
    font-family: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
    background: #fff;
    transition: border-color 0.2s;
}
.cell-input:focus {
    outline: none;
    border-color: #003366;
    box-shadow: 0 0 0 2px rgba(0, 51, 102, 0.1);
}

/* 數值欄位規範：支援 10 碼金額 / 8 碼數量 */
.cell-input.number { 
    text-align: right !important; 
    font-variant-numeric: tabular-nums; /* 強制等寬數字，確保垂直對齊 */
    padding-right: 6px;
}

/* 摘要/總計列 */
.summary-row td {
    background-color: #f0f4fa !important;
    font-weight: 700;
    color: #003366;
    border-top: 2px solid #003366;
}

/* ── 通用搜尋組件樣式 (Modal & Popup Picker) ── */

/* 搜尋浮層容器 (Popup Picker) */
.search-picker-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background: #fff;
    border: 2px solid #003366;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 51, 102, 0.25);
    width: 720px;
    max-width: 95vw;
    max-height: 520px;
    overflow-y: auto;
    display: none;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* 視窗標題列 (Popup/Modal Header) */
.popup-header {
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}
.popup-header h3 { font-size: 16px; color: #003366; margin: 0; font-weight: 700; }
.popup-close { cursor: pointer; color: #64748b; font-size: 24px; transition: color 0.2s; }
.popup-close:hover { color: #dc2626; }

/* 搜尋框區塊 (Search Box inside Modal/Popup) */
.popup-search-area {
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 12px;
}

/* 表格容器與間距 (Table Container) */
.picker-table-container {
    padding: 0 20px 20px 20px;
}

/* Picker 專用表格樣式 */
.picker-table {
    width: calc(100% - 4px);
    margin: 8px auto;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 16px;
    border: 1px solid #003366;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
}

/* 加大 Checkbox 尺寸 */
.picker-table input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #003366;
}
.picker-table thead {
    position: sticky;
    top: 0; /* 若在 table-container 內 */
    z-index: 9;
}
.picker-table th {
    background: #003366;
    color: #ffffff;
    font-weight: 600;
    padding: 12px 16px;
    text-align: left;
    border-bottom: none;
    font-size: 15px;
}
.picker-table tr.picker-row {
    cursor: pointer;
    transition: all 0.15s;
}
.picker-table tr.picker-row:hover {
    background: #f1f5f9 !important;
}
.picker-table tr.picker-row td {
    padding: 16px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}
.picker-table tr.picker-row .emp-text {
    font-weight: 700;
    color: #003366;
}
.picker-table tr.picker-row .sub-text {
    color: #64748b;
    font-size: 13px;
}
.picker-table tr.picker-row .num-text {
    text-align: right;
    font-weight: 700;
    color: #003366;
    font-family: 'Inter', sans-serif;
}

/* 強制 Modal 表格寬度與對齊 */
.modal-data-table th, .modal-data-table td {
    padding: 16px 20px !important;
    font-size: 16px !important;
}


/* ── 客戶/地址選取組合樣式 (Input + Picker Button) ── */
.cus-select-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}
.cus-select-wrap .form-control {
    flex: 1;
}
.cus-select-wrap .btn-sm {
    height: 38px;
    min-width: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    background: #003366;
    border: none;
}
.cus-select-wrap .btn-sm:hover {
    background: #004080;
}

/* ── 彈窗樣式 (Modal) ── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #003366;
    font-size: 1.25rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #ef4444;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* ── 玻璃擬態卡片 (Glass Card) ── */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 51, 102, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    box-shadow: 0 12px 40px rgba(0, 51, 102, 0.1);
}

/* ── 按鈕輔助樣式 ── */
.text-danger {
    color: #dc2626 !important;
}

.text-danger:hover {
    background-color: #fef2f2 !important;
    border-color: #fecaca !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── 列表工具列 (List Toolbar) ── */
.list-toolbar-container .toolbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.list-toolbar-container .toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    flex: 1;
}

.list-toolbar-container .toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.list-toolbar-container .filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-toolbar-container .filter-item span {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
}

.list-toolbar-container .filter-item .form-control {
    width: 150px;
    padding: 8px 12px;
    border-radius: 8px;
}

.list-toolbar-container .search-box {
    width: 250px;
    position: relative;
}

.list-toolbar-container .search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.list-toolbar-container .search-box .form-control {
    padding-left: 36px;
    border-radius: 8px;
}
