/* === 主題變數（方便日後調整） === */
:root {
    --color-bg: #020617;           /* slate-950 主背景 */
    --color-bg-secondary: #0f172a; /* slate-900 */
    --color-bg-tertiary: #1e293b;  /* slate-800 */
    --color-border: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-primary: #3b82f6;
    --color-primary-hover: rgba(59, 130, 246, 0.5);
    --color-accent-blue: #60a5fa;
    --color-accent-green: #34d399;
    --color-accent-amber: #fbbf24;
    --color-accent-rose: #f87171;
    --color-weekend-bg: #450a0a;
    --color-weekend-text: #f87171;
    --color-holiday-bg: #dc2626;
    --color-holiday-text: #fecaca;
    --color-duty-bg: #b45309;
    --color-duty-text: #fef3c7;
}

/* 基礎設定 */
body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
}

[v-cloak] {
    display: none;
}

/* 滾動條美化 (暗色系) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* 排班表核心樣式 */
.excel-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.excel-table th,
.excel-table td {
    border: 1px solid var(--color-border);
    text-align: center;
    transition: background-color 0.2s;
    height: 40px !important;
    padding: 0 !important;
    vertical-align: middle;

}


td {
    text-align: center;
    vertical-align: middle;
}

td .flex {
    gap: 4px;
    /* 班別之間的間距 */
}

.excel-table tbody tr {
    height: 40px !important;
}

/* 員額清冊預覽：凍結第 1~4 列 */
.quota-preview-table .quota-preview-thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgb(30 41 59);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.quota-preview-table .quota-preview-thead th {
    background: rgba(51 65 85 / 0.95);
}

/* 讓右側統計表的表頭高度與左表一致，方便垂直對齊 */
.stat-table thead th {
    height: 60px !important;
}

/* 人員管理表格樣式 */
.staff-table {
    table-layout: fixed;
}

.staff-table th {
    padding: 1rem;
    text-align: left;
    vertical-align: middle;
}

.staff-table td {
    padding: 1rem;
    vertical-align: middle;
}

.staff-table td:not(:last-child) {
    text-align: left;
}

.staff-table th:last-child,
.staff-table td:last-child {
    text-align: center;
}

/* 人員姓名欄位：固定在左側 */
.name-col {
    position: sticky;
    left: 0;
    z-index: 25;
    background-color: var(--color-bg) !important;
    width: 180px !important;
    min-width: 180px !important;
    max-width: 180px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 10px 4px;
    font-size: 12px;
    font-weight: bold;
    color: var(--color-text);
    border-right: 2px solid var(--color-primary) !important;
}

/* 日期格子 */
.date-cell {
    width: 28px;
    min-width: 28px;
    font-size: 11px;
}

.date-cell.weekend {
    background-color: var(--color-weekend-bg) !important;
    color: var(--color-weekend-text);
}

/* 右側統計欄位 */
.stat-col {
    min-width: 28px;
    max-width: 28px;
    width: 28px !important;
    height: 40px !important;
    background-color: var(--color-bg-secondary) !important;
    color: #38bdf8;
    font-weight: bold;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 0 !important;
    display: table-cell;
    vertical-align: middle;
}


/* 統計表左欄（姓名） */
.name-col-stat {
    position: sticky;
    left: 0;
    z-index: 20;
    background-color: var(--color-bg) !important;
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 10px 4px;
    font-size: 12px;
    font-weight: bold;
    color: var(--color-text);
    border-right: 2px solid var(--color-primary) !important;
    text-align: left;
}

/* 特殊日期（假日出勤）樣式 */
.date-cell.special-day {
    background-color: #7c3aed !important;
    color: #e9d5ff !important;
}

/* 國定假日表頭樣式 */
.date-cell.holiday-cell {
    background-color: var(--color-holiday-bg) !important;
    color: var(--color-holiday-text) !important;
}
/* 讓 input type="date" 的日曆圖標變白色 */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1); /* 將圖標顏色反轉（黑變白） */
    cursor: pointer;
}

/* 值班人員單元格樣式 */
.on-duty-cell {
    background-color: var(--color-duty-bg) !important;
    color: var(--color-duty-text) !important;
    box-shadow: inset 0 0 0 1px #d97706 !important;
}

/* 排班表左側班別群組字體顏色（早/中/晚/大夜/其他） */
.group-label.group-morning { color: #fbbf24; font-weight: 600; }   /* 早班 - 琥珀 */
.group-label.group-noon     { color: #60a5fa; font-weight: 600; }   /* 中班 - 藍 */
.group-label.group-evening  { color: #a78bfa; font-weight: 600; }   /* 晚班 - 紫 */
.group-label.group-night    { color: #38bdf8; font-weight: 600; }   /* 大夜 - 青 */
.group-label.group-other    { color: #94a3b8; font-weight: 600; }   /* 其他 - 灰 */

/* 班別文字顏色 */
.shift-A {
    color: var(--color-accent-blue);
    font-weight: 900;
}

.shift-B {
    color: var(--color-accent-green);
    font-weight: 900;
}

.shift-C {
    color: var(--color-accent-amber);
    font-weight: 900;
}

/* 請假標記 X */
.shift-X {
    color: var(--color-accent-rose);
    font-weight: 900;
}

/* 拖曳清單樣式 */
.drag-item {
    cursor: grab;
}

.drag-item:active {
    cursor: grabbing;
}

.ghost {
    opacity: 0.5;
    background: var(--color-primary);
}

/* 班別卡片區域 */
.shift-group-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 12px;
}

/* 班別卡片 */
.shift-card {
    position: relative;
    border: 1px solid #24303f;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.6));
}

/* 拖放高亮 */
.shift-card.drag-over {
    outline: 2px dashed rgba(99, 102, 241, 0.6);
    background: rgba(99, 102, 241, 0.06);
}

.shift-card input {
    border: none;
}

/* 拖曳把手：禁止選取文字，避免拖曳失敗時整列反白 */
.drag-handle,
.row-handle,
.schedule-row-handle {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
.drag-handle *,
.row-handle *,
.schedule-row-handle * {
    user-select: none;
}

.drag-handle {
    position: absolute;
    right: 10px;
    bottom: 8px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(148, 163, 184, 0.04);
    border-radius: 6px;
    color: var(--color-text-muted);
    cursor: grab;
    font-size: 14px;
}

.drag-handle:active {
    cursor: grabbing;
}

/* row handle for staff list */
.row-handle {
    cursor: grab;
    color: var(--color-text-muted);
    padding: 6px;
    border-radius: 6px;
}

.row-handle:active {
    cursor: grabbing;
}

/* 排班表／人員管理可拖曳列：禁止整列被選取，輸入欄位仍可選取 */
tbody[data-staff="active"] tr,
tbody[data-staff="departed"] tr,
tbody[data-schedule-rows="true"] tr {
    user-select: none;
    -webkit-user-select: none;
}
tbody[data-staff="active"] tr input,
tbody[data-staff="active"] tr select,
tbody[data-staff="active"] tr textarea,
tbody[data-staff="departed"] tr input,
tbody[data-staff="departed"] tr select,
tbody[data-staff="departed"] tr textarea {
    user-select: text;
    -webkit-user-select: text;
}


/* Modal */
.modal-backdrop {
    background: rgba(2, 6, 23, 0.6);
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}

.modal {
    background: #0b1220;
    border: 1px solid #22303f;
    padding: 18px;
    border-radius: 12px;
    width: 420px;
    color: #e6eef8;
}

.cell-picker-modal {
    width: 720px;
}

/* picker grid inside modal: two columns */
.cell-picker-modal .picker-grid {
    display: flex;
    gap: 16px;
}

.cell-picker-modal .picker-grid .col {
    display: flex;
    flex-direction: column;
}

.cell-picker-modal select {
    min-width: 320px;
    max-width: 340px;
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.modal .row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.modal select,
.modal input {
    background: #0f1722;
    border: 1px solid #213243;
    padding: 8px;
    color: #e6eef8;
    border-radius: 6px;
}

.modal select {
    color: #e6eef8;
}

.modal input[type="date"] {
    color: #e6eef8;
}

.modal select option {
    background: #0f1722;
    color: #e6eef8;
}

.modal select option:checked {
    background: #1e40af;
    color: #e6eef8;
    font-weight: bold;
}

.modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

/* 與主表格的統計欄做視覺分隔 */
.excel-table th.stat-col:first-of-type,
.excel-table td.stat-col:first-of-type {
    border-left: 5px solid var(--color-border);
    padding-left: 4px;
}

/* TIP 樣式 */
.schedule-tip {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(34, 197, 94, 0.05));
    border-left: 4px solid var(--color-primary);
    color: #cbd5e1;
    font-size: 13px;
    padding: 12px 16px;
    margin: 0 0 8px 0;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* 下拉選單樣式 */
.select-dropdown {
    background-color: var(--color-bg-tertiary) !important;
    color: #cbd5e1 !important;
    border: 1px solid var(--color-border) !important;
    /* 邊框顏色 */
    border-radius: 0.5rem !important;
    /* 圓角 */
    padding: 0.5rem !important;
    /* 內距 */
    font-size: 0.875rem !important;
    /* 字體大小 */
    transition: border-color 0.2s, box-shadow 0.2s !important;
    /* 過渡效果 */
}

.select-dropdown:focus {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px var(--color-primary-hover) !important;
    /* 聚焦時的光暈效果 */
    outline: none !important;
    /* 移除預設的聚焦框 */
}

/* 隱藏數字輸入框的上下按鈕 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* 報支頁面專用樣式 */
.report-page .name-col {
    width: 120px !important;
    min-width: 100px !important;
    max-width: 100px !important;
}

.report-page .stat-col {
    min-width: 56px;
    max-width: 56px;
    width: 56px !important;
}

/* 編輯狀態: 高亮列與可編輯欄位樣式 */
.editing-row {
    background: rgba(59,130,246,0.04) !important; /* subtle blue tint */
}

.editing-row td {
    transition: background-color 0.15s;
}

.staff-edit-input {
    background: linear-gradient(180deg, rgba(59,130,246,0.06), rgba(59,130,246,0.02));
    border: 1px solid rgba(59,130,246,0.18);
    padding: 6px 8px;
    border-radius: 6px;
    color: #e6eef8;
    outline: none;
    transition: box-shadow 0.12s, border-color 0.12s;
}

.staff-edit-input:focus,
.staff-edit-input:active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 6px rgba(59,130,246,0.06);
}

/* small helpers to ensure selects look consistent when editing */
.staff-edit-input.select-dropdown {
    padding: 6px 10px !important;
}

/* --- Toast 彈窗過渡動畫 --- */
.fade-enter-active, .fade-leave-active {
    transition: all 0.4s ease;
}
/* 離開時加上 pointer-events-none 確保不擋滑鼠 */
.fade-leave-to {
    transform: translate(-50%, -30px) !important;
    opacity: 0 !important;
    pointer-events: none; 
}
.fade-enter-from {
    transform: translate(-50%, -30px) !important;
    opacity: 0;
}

/* === 簽到簿列印預覽（僅列印時顯示） === */
.attendance-print-area {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    visibility: hidden;
}

@media print {
    body * {
        visibility: hidden;
    }
    #attendance-print-area,
    #attendance-print-area * {
        visibility: visible;
    }
    #attendance-print-area {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        left: 0 !important;
    }
    .attendance-print-page {
        page-break-after: always;
        padding: 12px;
        font-size: 12px;
        color: #000;
    }
    .attendance-print-page:last-child {
        page-break-after: auto;
    }
    .at-title {
        font-weight: bold;
        font-size: 14px;
        margin-bottom: 4px;
        white-space: pre-line;
    }
    .at-loc {
        margin-bottom: 8px;
    }
    .at-head {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 8px;
    }
    .at-head td {
        border: 1px solid #333;
        padding: 2px 6px;
    }
    .at-label {
        font-weight: bold;
        width: 80px;
    }
    .at-days {
        width: 100%;
        border-collapse: collapse;
        font-size: 10px;
    }
    .at-days th,
    .at-days td {
        border: 1px solid #333;
        padding: 1px 3px;
    }
    .at-day { min-width: 20px; }
    .at-remark { min-width: 36px; }
}