/* 基础设置 */
:root {
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-weekend-sat: #3498db;
    /* 蓝色 */
    --text-weekend-sun: #e74c3c;
    /* 红色 */
    --text-holiday: #e74c3c;
    /* 节假日红 */
    --text-workday: #27ae60;
    /* 补班绿 */
    --border-color: #e0e0e0;
    --bg-color: #ffffff;
    --print-width: 210mm;
    --print-height: 297mm;
}

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
    color: var(--text-primary);
    box-sizing: border-box;
}

/* 控制面板 */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background-color: #333;
    color: #fff;
}

/* 页面容器 - 模拟 A4 */
.page-container {
    width: var(--print-width);
    height: var(--print-height);
    height: var(--print-height);
    /* 减去一点 margin 防止溢出 */
    background-color: #fff;
    margin: 0 auto 20px auto;
    /* 屏幕显示时，页与页之间有间距 */

    padding: 10mm 15mm;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* 最后一个页面不需要底部 margin (屏幕显示) */
.page-container:last-child {
    margin-bottom: 0;
}

/* 头部 Header */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 20px;
    border-bottom: 1px solid transparent;
    border-bottom: 1px solid transparent;
    /* 占位 */
    height: 120px;

}

/* Header 左侧 */
.header-left {
    display: flex;
    align-items: flex-start;
}

.year-month-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.arrow-icon {
    font-size: 24px;
    color: #666;
    margin-top: 5px;
}

.large-month {
    font-size: 64px;
    line-height: 1;
    font-weight: 300;
    color: var(--text-primary);
}

.year-month-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 8px;
}

.year {
    font-size: 20px;
    font-weight: 400;
    color: #999;
}

.month-name {
    font-size: 16px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #333;
}

/* 头部右侧迷你日历 */
.header-right {
    /* 移除固定宽度以允许扩展 */
}


.mini-calendars-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* 基础迷你日历样式 (共享) */
.mini-calendar {
    font-size: 10px;
    /* 基础样式中移除宽度，在下方具体设置 */
    /* 给一个固定宽度确保对齐 */
}


/* 周视图迷你日历 */
.calendar-header .mini-calendar {
    width: 210px;
}

/* 月视图迷你日历 */

.month-header .mini-calendar {
    width: 190px;
    /* 月视图专用宽度 - 稍微缩小 */
    flex-shrink: 0;
    /* 防止在 flex 容器较紧时缩小 */
    transform-origin: top;

    margin-bottom: 0;
}

/* ================== 日视图：周末与节假日特殊配色 ================== */

/* 星期六：蓝色 (默认 var(--text-weekend-sat) #3498db) */
.day-page.sat .day-big-num-link {
    color: var(--text-weekend-sat) !important;
}

.day-page.sat .day-grid-cells {
    border-top-color: var(--text-weekend-sat) !important;
    border-top-width: 4px;
    /* 加粗一点强调 */
}

/* 星期日：红色 (默认 var(--text-weekend-sun) #e74c3c) */
.day-page.sun .day-big-num-link {
    color: var(--text-weekend-sun) !important;
}

.day-page.sun .day-grid-cells {
    border-top-color: var(--text-weekend-sun) !important;
    border-top-width: 4px;
    /* 加粗一点强调 */
}

/* 节假日：红色 (优先级应当高于周末，或者与周日一致) */
.day-page.holiday-day .day-big-num-link {
    color: var(--text-holiday) !important;
}

.day-page.holiday-day .day-grid-cells {
    border-top-color: var(--text-holiday) !important;
    border-top-width: 4px;
    /* 加粗一点强调 */
}

.mini-cal-header {
    text-align: left;
    font-size: 24px;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 5px;
    padding-left: 2px;
}

.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    gap: 2px;
}

/* ... existing mini-cal styles ... */

/* ... */

.month-sidebar-tabs {
    width: 30px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #ccc;
}

/* Ensure tab-item styles are global if unnested */
.tab-item {
    /* Re-asserting styles if needed, but the previous declaration is fine. */
    /* Wait, I need to make sure I don't delete the .tab-item block if it's elsewhere. */
    /* The .tab-item block is actually lines 443-463 in previous version? No, wait. */
    /* In the file content from step 161, .tab-item declaration is MISSING! */
    /* Lines 443-447 are .month-sidebar-tabs. */
    /* Lines 450-455 are .tab-item.active. */
    /* WHERE IS .tab-item base style? It seems to have been deleted or I missed it. */
    /* Ah, looking back at Step 137 diff, I replaced the block containing .month-sidebar-tabs AND .tab-item with a block that DID NOT include .tab-item! */
    /* I accidentally DELETED .tab-item base styles in Step 137! */
    /* That explains "fix sidebar tabs style". */
}

/* Let's restore .tab-item */
.tab-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-bottom: 1px solid #eee;
    background: #fdfdfd;

    /* Rounded right corners */
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    margin-bottom: 2px;
    border: 1px solid #eee;
    border-left: none;

    /* Link styles */
    text-decoration: none;
    color: #999;
    cursor: pointer;
}

.tab-item:last-child {
    margin-bottom: 0;
}

.tab-item.active {
    background: #4a90e2;
    color: white;
    font-weight: bold;
    border-color: #4a90e2;
}

.mini-day-name {
    color: #999;
    font-weight: 500;
    padding-bottom: 2px;
    border-bottom: 1px solid #ccc;
    margin-bottom: 2px;
}

.mini-cal-day {
    padding: 2px 0;
    color: var(--text-primary);
    position: relative;
    /* 为伪元素圆圈定位 */
    z-index: 1;
}

.mini-cal-day.empty {
    /* 空白占位 */
}


/* Mini Calendar 配色 */
.mini-day-name.is-weekend.sat,
.mini-cal-day.is-weekend.sat {
    color: var(--text-weekend-sat);
}

.mini-day-name.is-weekend.sun,
.mini-cal-day.is-weekend.sun {
    color: var(--text-weekend-sun);
}

.mini-cal-day.current-week {
    background-color: #f0f0f0;
    border-radius: 2px;
    font-weight: bold;
}

.mini-cal-day.current-day-highlight {
    background-color: #ccc;
    /* Gray box for current day */
    color: #fff !important;
    /* White text for contrast */
    border-radius: 2px;
    font-weight: bold;
}

/* 主体区域 Main */
.calendar-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 10px;
}

/* Timeline Header */
.timeline-header {
    display: flex;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.date-col-placeholder {
    width: 70px;
    /* 左侧日期列宽度 */
    flex-shrink: 0;
    border-right: 1px solid #ccc;
    /* 关键竖线 */
}


.hours-row {
    flex: 1;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
}

.hour-mark {
    font-size: 12px;
    color: #999;
    width: 20px;
    text-align: center;
}

/* 周记录行 */
.week-rows {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.day-row {
    flex: 1;
    /* 均分剩余高度 */
    display: flex;

    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    /* reset nav link */
    color: inherit;
    /* reset nav link */
    cursor: pointer;
}

.day-row:hover {
    background-color: rgba(0, 0, 0, 0.01);
}

.day-info {
    width: 70px;
    flex-shrink: 0;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Changed from center to start to align nicely at top */
    border-right: 1px solid #ccc;
    /* 关键竖线 */
}

.day-num {
    font-size: 32px;
    font-weight: 300;
    line-height: 1;
}

.day-name {
    font-size: 10px;
    text-transform: uppercase;
    margin-top: 4px;
    font-weight: 500;
    color: #666;
}

/* 周末配色 - 大行 */
.day-row.sat .day-num {
    color: var(--text-weekend-sat);
}

.day-row.sat .day-name {
    color: var(--text-weekend-sat);
}

.day-row.sun .day-num {
    color: var(--text-weekend-sun);
}

.day-row.sun .day-name {
    color: var(--text-weekend-sun);
}

.day-grid {
    flex: 1;
    position: relative;
    /* 可以在这里画辅助线 */
}

/* 不需要画横线，只要底部边框 */

/* 重要：左侧强调色条 (参考图中左边的一条蓝线) */
/* 可以加在 body 或者 page-container 上，这里模拟一下 */
.page-container {
    position: relative;
    border-left: 5px solid #3498db;
    /* 默认蓝色装饰条 */
}


/* ================== v4.0 新增样式：节假日与补班 ================== */

/* 通用标签样式 */
.label {
    font-size: 12px;
    border-radius: 3px;
    padding: 0 2px;
    margin-top: 2px;
    border: 1px solid transparent;
    font-weight: bold;
}

/* 节假日 (红色) */
.holiday-text {
    color: var(--text-holiday) !important;
}

.label.holiday {
    color: var(--text-holiday);
    border-color: var(--text-holiday);
}

.holiday-name {
    display: block;
    font-size: 8px;
    color: var(--text-holiday);
    margin-top: 1px;
    line-height: 1;
}

/* 补班 (绿色) */
.workday-text {
    color: var(--text-workday) !important;
}

.label.workday {
    color: var(--text-workday);
    border-color: var(--text-workday);
}

.labels-group {
    display: flex;
    flex-direction: column;
    margin-left: 5px;
    line-height: 1;
    justify-content: center;
}

/* 迷你日历：节假日圆圈背景 */
.mini-cal-day.is-holiday {
    color: var(--text-holiday) !important;
}

.mini-cal-day.is-holiday::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    background-color: rgba(231, 76, 60, 0.3);
    /* 降低一点透明度让数字看清楚 */
    border-radius: 50%;
    z-index: -1;
}

/* 迷你日历：补班圆圈背景 */
.mini-cal-day.is-workday {
    color: var(--text-workday) !important;
}

.mini-cal-day.is-workday::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    background-color: rgba(39, 174, 96, 0.3);
    border-radius: 50%;
    z-index: -1;
}


/* 打印样式 */
@media print {
    body {
        background: none;
        padding: 0;
        margin: 0;
    }

    .controls {
        display: none !important;
    }

    .page-container {
        width: 100%;
        height: 100vh;
        /* 充满全页 */
        box-shadow: none;
        margin: 0;
        border-left: 5px solid #3498db !important;
        /* 强制打印出来 */

        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;

        /* 强制分页 */
        page-break-after: always;
        break-after: page;
    }

    /* 最后一页不要分页符，否则可能多出一张白纸 */
    .page-container:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }
}

/* ---------------- 月历样式 ---------------- */

.month-page {
    /* 复用基础页面布局 */
}


.month-layout {
    display: flex;
    height: 100%;
    gap: 10px;
}

.month-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.month-sidebar-tabs {
    width: 30px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #ccc;
}

.tab-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-bottom: 1px solid #eee;
    background: #fdfdfd;

    /* Rounded right corners */
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    margin-bottom: 2px;
    border: 1px solid #eee;
    border-left: none;

    /* Link styles */
    text-decoration: none;
    color: #999;
    cursor: pointer;
}

.tab-item:last-child {
    margin-bottom: 0;
}

.tab-item.active {
    background: #4a90e2;
    color: white;
    font-weight: bold;
    border-color: #4a90e2;
}

/* 表头区域 */
/* 表头区域 */
.month-header {
    display: flex;
    flex-direction: column;
    /* 垂直排列：Brand 在上，Row 在下 */
    margin-bottom: 20px;
    /* Removed border-bottom previously */
}

.month-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* 顶部对齐 */
    width: 100%;
}

.brand-name {
    font-family: 'Times New Roman', serif;
    font-size: 32px;
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-bottom: 15px;
    /* Spacing between Brand and Content Row */
    color: #333;
    width: 250px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    line-height: 1;
}

.month-title-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
    /* Slight offset against mini cals if needed */
}

.big-month-number {
    font-size: 72px;
    line-height: 1;
    font-weight: bold;
    color: #222;
}

.year-month-sub {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
}

.year-month-sub .bullet {
    color: #ccc;
    margin: 0 5px;
}

/* 迷你日历在表头中的样式复用 - 移至主代码块 */

/* 网格表头 */
.month-grid-header {
    display: grid;
    grid-template-columns: 25px repeat(7, 1fr);

    text-align: center;
    /* 移除底部边框 */
    padding-bottom: 5px;
    margin-bottom: 5px;

    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    color: #555;
}

.month-grid-header .sat {
    color: #4a90e2;
}

.month-grid-header .sun {
    color: #e15554;
}

.week-link-sidebar {
    background-color: #eaf4fc;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a90e2;
    font-size: 10px;
    text-decoration: none;
    transition: background-color 0.2s;
}

.week-link-sidebar:hover {
    background-color: #d6eaf8;
}

.week-link-sidebar .arrow {
    font-size: 8px;
    /* 小三角形 */
    transform: scaleY(1.2);
    /* 稍微拉高一点 */
}

/* 网格主体 */
.month-grid-body {
    flex: 1;
    display: grid;
    grid-template-columns: 25px repeat(7, 1fr);

    grid-template-rows: repeat(5, 1fr);
    /* 强制 5 行 */
    border-top: 1px solid #000;
    border-left: 1px solid #000;
}

.month-cell {
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 0;
    /* padding 移动到内部 link */
    position: relative;
    display: flex;
    flex-direction: column;
}

.month-cell-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    padding: 5px;
    /* 恢复 padding */
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    cursor: pointer;
}

.month-cell-link:hover {
    background-color: rgba(0, 0, 0, 0.02);
    /* hover effect */
}

.cell-date {
    font-size: 24px;
    line-height: 1;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.cell-content {
    flex: 1;
    font-size: 10px;
}

/* 日期颜色 */
.month-cell.sat .cell-date {
    color: #4a90e2;

}

.month-cell.sun .cell-date {
    color: #e15554;
}

.month-cell.holiday .cell-date {
    color: #e15554;
}

.month-cell.workday .cell-date {
    color: var(--text-workday);
}

/* Indicators */
.month-cell .holiday-label {
    display: inline-block;
    background: #e15554;
    color: white;
    font-size: 10px;
    padding: 1px 3px;
    border-radius: 2px;
    /* margin-left: 5px; handled by wrapper */
    vertical-align: top;
}

.month-cell .workday-label {
    display: inline-block;
    background: var(--text-workday);
    color: white;
    font-size: 10px;
    padding: 1px 3px;
    border-radius: 2px;
    /* margin-left: 5px; handled by wrapper */
    vertical-align: top;
}

.controls fieldset {
    border: 1px solid #ccc;
    padding: 10px;
    margin-right: 15px;
    border-radius: 4px;
}

.controls legend {
    font-weight: bold;
    padding: 0 5px;
}

html {
    scroll-behavior: smooth;
}

/* 导航链接 */
a.calendar-link {
    text-decoration: none;

    color: inherit;
    cursor: pointer;
    display: block;
    width: 100%;
    height: 100%;
}

a.calendar-link:visited {
    color: inherit;
}

a.calendar-link:hover {
    /* Optional: feedback on hover */
    opacity: 0.8;
}

/* 月历视图中的周导航 */
.month-week-link {
    position: absolute;
    left: 0;

    top: 0;
    bottom: 0;
    width: 20px;
    /* 可点击区域宽度 */
    cursor: pointer;
    z-index: 10;
    /* 调试/视觉辅助：通常透明，也许悬停时微弱显示 */
}


.month-cell:hover .month-week-link {
    background-color: rgba(0, 0, 0, 0.02);
}

/* 打印提示文字 */
.print-instruction {
    text-align: center;
    color: #666;
    margin-top: 10px;
    font-size: 13px;
    width: 100%;
}

/* ================== 日视图样式 ================== */

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 20px;
    height: 130px;
    /* Reduced from 180px to move grid up */
    /* 增加高度以容纳更大的日期数字 */
    position: relative;
    /* 确保绝对定位子元素相对于此容器 */
}

/* Header Left */
.day-header-left {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-top: 20px;
    /* Arrow gap */
}

.nav-arrow {
    font-size: 24px;
    color: #666;
    margin-top: 5px;
    cursor: pointer;
    /* 这里的箭头通常是视觉元素，但也可能是链接 */
}

.nav-month-num {
    font-size: 48px;
    line-height: 1;
    font-weight: 300;
    color: #333;
}

.nav-year-month {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 5px;
}

.nav-year {
    font-size: 14px;
    color: #999;
}

.nav-month-name {
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    color: #333;
}

/* Header Center */
.day-header-center {
    display: flex;
    flex-direction: row;
    /* 横向排列 */
    align-items: flex-end;
    /* 底部对齐：确保 Weekday 始终与数字底部对齐，不受上方 holiday 影响 */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 30px;
    /* Moved down from 10px */
    z-index: 10;
    gap: 15px;
    /* 间距 */
}

.day-info-left-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* 右对齐，使其紧靠数字 */
    margin-bottom: 25px;
    /* Manually visual adjustment */
    position: relative;
    top: -15px;
    /* User request: move up 15px */
}

.day-holiday-name {
    font-size: 14px;
    color: var(--text-holiday);
    /* Red */
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 2px;
    white-space: nowrap;
}

.day-weekday {
    font-size: 18px;
    text-transform: uppercase;
    color: #333;
    letter-spacing: 2px;
    margin-right: 0;
    /* Removed old margins/z-index */
    line-height: 1;
}

.day-big-num-link {
    font-size: 130px;
    /* Slightly smaller to fit in 130px header */
    line-height: 1;
    font-weight: 300;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    padding: 10px 40px;
    /* 增加点击区域 */
    margin-top: -15px;
    /* Pull up a bit */
    display: block;
    transition: transform 0.2s;
}

.day-big-num-link:hover {
    color: #000;
    transform: scale(1.05);
    /* 悬停微放大 */
    background-color: rgba(0, 0, 0, 0.02);
    /* 悬停背景反馈 */
    border-radius: 10px;
}

/* Header Right */
.day-header-right {
    position: relative;
    z-index: 20;
    /* Ensure it stays on top of grid */
}

/* Ensure Day View Mini Calendar has background to cover grid if overlapping */
.day-header-right .mini-calendar {
    background-color: #fff;
    padding-bottom: 5px;
    /* Little buffer */
    width: 190px;
    margin-bottom: 0;
}

/* Main Grid */
.day-main-grid {
    flex: 1;
    /* 填满剩余空间 */
    display: flex;
    /* border: 1px solid #999; removed outer border */
    margin-top: 26px;
    /* Increased to avoid overlap with 6-row mini cal */
    position: relative;
    /* Context for absolute axis */
}

.day-time-axis {
    width: 40px;
    flex-shrink: 0;
    /* border-right removed */
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    /* align to center of spaces */
    padding-bottom: 2px;
    /* manual tweak for perfect center */
    padding-right: 10px;
    /* space between text and grid */
    background-color: transparent;
    /* transparent to not block anything */

    position: absolute;
    left: -50px;
    /* Move into left margin (40px width + 10px padding) */
    top: 0;
    height: 100%;
}

.time-label {
    text-align: right;
    font-size: 10px;
    color: #999;
    line-height: 1;
}

/* 日视图网格区域 */
.day-grid-cells {
    flex: 1;
    position: relative;
    border: 2px solid #000;
    /* Solid strong frame */
    display: flex;
    flex-direction: column;
    background: none;
    /* remove old gradient */
}

/* 13个格子，中间12条虚线 */
.grid-row {
    flex: 1;
    border-bottom: 1px dashed #ccc;
    box-sizing: border-box;
}

.grid-row:last-child {
    border-bottom: none;
    /* simple removal of last border */
}

/* 微调日视图中的迷你日历大小 */
.day-header .mini-calendar {
    width: 140px;
    /* 比顶部稍微小一点，或者保持一致 */
}