:root {
    --bg-color: #f8f9fa;
    --sidebar-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --holiday-bg: #cbd5e1;
    --weekend-bg: #cbd5e1;
    /* Unified Dark Gray for all rest days */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --header-height: 60px;
    --sidebar-width: 600px;
    /* Wider sidebar */

    /* Table Dimensions */
    --col-service-width: 150px;
    --col-detail-width: 250px;
    --col-duration-width: 80px;
    --day-cell-width: 36px;
    --row-height: 36px;
    /* Match day-cell-width for square cells */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* ========== Tab Navigation ========== */
.tab-nav {
    width: 80px;
    background: #1e293b;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    gap: 0.5rem;
    flex-shrink: 0;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.75rem;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-btn i {
    font-size: 1.5rem;
}

/* ========== Content Area ========== */
.content-area {
    flex: 1;
    overflow: auto;
    background: var(--bg-color);
}

.page {
    display: none;
    height: 100%;
}

.page.active {
    display: flex;
    flex-direction: column;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-header h1 i {
    color: var(--primary-color);
}

/* ========== Calendar Page ========== */
.calendar-content {
    flex: 1;
    overflow: auto;
    padding: 2rem;
    display: flex;
    gap: 2rem;
}

.calendar-year-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

.month-container {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.month-header {
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.month-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 0.25rem;
}

.month-weekday {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.25rem 0;
    font-weight: 500;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.month-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.month-day.empty {
    cursor: default;
}

.month-day.workday {
    background: white;
    color: var(--text-color);
}

.month-day.holiday {
    background: #cbd5e1;
    color: #64748b;
}

.month-day.today {
    border: 2px solid var(--primary-color);
    font-weight: bold;
}

.month-day:not(.empty):hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-sm);
    z-index: 1;
}

/* Year Controls */
.year-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.year-display {
    font-size: 1.25rem;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

width: var(--sidebar-width);
background: var(--sidebar-bg);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
box-shadow: var(--shadow-sm);
z-index: 10;
transition: width 0.3s ease;
overflow: hidden;
position: relative;
white-space: nowrap;
/* Prevent breaking when collapsing */
}

.sidebar.collapsed {
    width: 60px;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-color);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
    transition: opacity 0.2s;
}

.sidebar.collapsed .brand h1 {
    display: none;
    opacity: 0;
}

.sidebar.collapsed .brand {
    display: none;
}

/* Hide Manage Holidays button when collapsed */
.sidebar.collapsed #btnManageHolidays {
    display: none;
}

.btn-icon-only {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-only:hover {
    color: var(--primary-color);
}

/* Sidebar Content Areas */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 1.5rem 1rem;
    /* Hide scrollbar when checking overflow? */
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Hide content when collapsed */
.sidebar.collapsed .sidebar-content,
.sidebar.collapsed .sidebar-footer {
    display: none;
}

.control-group {
    margin-bottom: 2rem;
}

.control-group h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-select,
.input-group input {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-select:focus,
.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.service-selection-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#inputService {
    display: none;
    /* Hidden by default */
}

/* Show when it has a special class (managed by JS) or we can just toggle display in JS directly */

/* Segmented Control */
.segmented-control {
    display: flex;
    background: #eef1f6;
    padding: 3px;
    border-radius: 8px;
    width: fit-content;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    padding: 6px 16px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    color: #64748b;
    transition: all 0.2s;
    user-select: none;
}

.segmented-control input[type="radio"]:checked+label {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

.setting-item {
    margin-bottom: 12px;
}

.setting-label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
    font-weight: 500;
}

.makeup-workday {
    background-color: #fff7ed;
    /* Light Orange */
    position: relative;
}

.makeup-workday::after {
    content: '?;
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 8px;
    color: #f97316;
    line-height: 1;
}

/* Adjust grid cell to handle absolute positioning if needed, but it's likely simple div */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    width: 100%;
    margin-bottom: 0.5rem;
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

.btn.primary:hover {
    background-color: var(--primary-hover);
}

.btn.secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn.secondary:hover {
    background-color: var(--bg-color);
}

.btn.danger {
    background-color: #fee2e2;
    color: var(--danger-color);
}

.btn.danger:hover {
    background-color: #fecaca;
}

.btn.ghost {
    background: transparent;
    color: var(--text-muted);
    width: auto;
}

.btn.ghost:hover {
    color: var(--primary-color);
}

.btn.small {
    font-size: 0.8rem;
    padding: 5px 10px;
    width: auto;
    display: inline-flex;
}

.btn.small-btn {
    padding: 4px 8px;
    font-size: 0.8rem;
    width: auto;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.toggle-switch input {
    display: none;
}

.toggle-switch .slider {
    width: 36px;
    height: 18px;
    background-color: var(--border-color);
    border-radius: 20px;
    position: relative;
    transition: 0.3s;
    margin-right: 0.75rem;
}

.toggle-switch .slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: 0.3s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.toggle-switch input:checked+.slider {
    background-color: var(--success-color);
}

.toggle-switch input:checked+.slider::before {
    transform: translateX(18px);
}

.label-text {
    font-size: 0.9rem;
}

/* Sub-items Form */
.sub-items-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 10px;
}

.sub-item-row {
    display: flex;
    gap: 5px;
    align-items: center;
    background: #f8fafc;
    padding: 5px;
    border: 1px dashed var(--border-color);
    border-radius: 4px;
}

.sub-item-row.dragging {
    opacity: 0.5;
    background: #e2e8f0;
}

.drag-handle {
    cursor: move;
    color: var(--text-muted);
    padding: 5px;
}

.sub-item-row input {
    width: auto;
    flex: 1;
    /* Stretch detail input */
    min-width: 0;
}

.sub-item-row .row-start-date {
    width: 110px;
    /* Fixed width for date */
    flex: none;
    font-size: 0.8rem;
}

.sub-item-row .row-duration {
    width: 50px;
    flex: none;
    text-align: center;
}

.btn.remove-row {
    width: auto;
    padding: 5px;
    color: var(--danger-color);
    background: transparent;
    margin-bottom: 0;
}

.annotation {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
}

.form-actions {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    margin-top: 1rem;
}

.form-actions .btn {
    flex: 1;
    /* Equal width buttons */
    width: auto;
    margin-bottom: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #fff;
}

.top-bar {
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.top-bar h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Gantt Chart Container */
.gantt-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    background: white;
}

.gantt-header-wrapper {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.gantt-left-header {
    width: 480px;
    flex-shrink: 0;
    background: #1e293b;
    color: white;
    /* Match left pane border */
    border-right: 1px solid var(--border-color);
}

.gantt-right-header {
    flex: 1;
    overflow: hidden;
    background: #0f172a;
    display: flex;
    /* Ensure child fills height */
    align-items: stretch;
}

.fixed-columns-header {
    display: flex;
    flex-shrink: 0;
    color: white;
    font-weight: 600;
    z-index: 5;
    height: 100%;
    /* Fill left-header */
}

.fixed-columns-header>div {
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center align ALL header items */
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    height: 100%;
    /* Fill container */
    min-height: 48px;
    /* Safe min */
    color: white !important;
    /* Force white text for all headers */
}

.col-service {
    width: var(--col-service-width);
}

.col-detail {
    width: var(--col-detail-width);
    flex: 1;
}

.col-duration {
    width: var(--col-duration-width);
    /* Removed justify-content: center; as it's now handled by parent .fixed-columns-header>div */
}

.scrollable-dates-header {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    color: white;
    scrollbar-width: none;
    height: 100%;
    /* Fill container */
}

.scrollable-dates-header::-webkit-scrollbar {
    display: none;
}

.month-group {
    display: flex;
    flex-direction: column;
}

.month-label {
    text-align: center;
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
    font-size: 0.65rem;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
    height: 2rem;
    /* Fixed height */
    display: flex;
    align-items: center;
    justify-content: center;
}

.days-row {
    display: flex;
}

.day-cell {
    width: var(--day-cell-width);
    height: calc(var(--row-height) * 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

/* Gantt Body */
/* Gantt Body - Split Pane Layout */
.gantt-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    /* Two panes: Left (Fixed), Right (Scrollable) */
}

/* Header Actions container */
.actions {
    display: flex;
    align-items: center;
}

/* LEFT PANE: Service, Detail, Duration */
.gantt-left-pane {
    width: 480px;
    /* Sum of col widths: 150 + 250 + 80 */
    overflow: hidden;
    /* No scrollbars here, synced via JS */
    background: white;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* RIGHT PANE: Calendar Grid */
.gantt-right-pane {
    flex: 1;
    overflow: auto;
    /* Scrolls both X and Y */
    background: white;
}

/* Rows in Panes */
.left-pane-row,
.right-pane-row {
    height: var(--row-height);
    display: flex;
    align-items: center;
    /* Border is now on cells to allow merging effects */
    /* border-bottom: 1px solid var(--border-color); */
    box-sizing: border-box;
}

.left-pane-row:hover,
.right-pane-row:hover {
    background-color: #f8fafc;
}

/* Thicker border between service groups - Applied via Pseudo-element to sit ON TOP */
.left-pane-row.service-separator,
.right-pane-row.service-separator {
    border-bottom: none !important;
    /* Remove old border */
    position: relative;
    /* Anchor for pseudo-element */
}

.left-pane-row.service-separator::after,
.right-pane-row.service-separator::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: #000000;
    z-index: 100;
    /* Ensure on top of all cell backgrounds */
    pointer-events: none;
}

/* Fix: Because of box-sizing, the border-bottom adds to/takes from height.
   If we put it on the row, we need to ensure child borders don't double up. */
.left-pane-row.service-separator>div {
    border-bottom: none !important;
}

.right-pane-row.service-separator>.grid-cell {
    border-bottom: none !important;
}

/* Left Pane Cells */
.left-pane-row>div {
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    /* Moved here */
    height: 100%;
    padding: 0 1rem;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-service {
    width: var(--col-service-width);
    font-weight: 600;
}

/* Specific override for merging visual */
.col-service.no-border-bottom {
    border-bottom-color: transparent;
}

/* Merged Service Text Overlay */
.service-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--col-service-width);
    /* height set inline */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center horizontally too? Or flex-start + padding? User screenshot shows center/left. Default center for now or match col-service */
    padding-left: 1rem;
    /* Match col-service padding */
    justify-content: flex-start;
    /* Actually col-service is left aligned usually */
    pointer-events: auto;
    /* Enable drag interactions */
    cursor: move;
    /* Show move cursor (crosshair arrows) */
    z-index: 10;
    font-weight: 600;
    /* Match col-service */
}

.service-overlay:active {
    cursor: move;
}

/* Detail Column - Parent Container (Always Centered) */
.left-pane-row .col-detail {
    width: var(--col-detail-width);
    flex: 1;
    display: flex;
    align-items: center;
    /* Vertically center the content block */
    padding: 0 1rem;
    overflow: hidden;
}

/* Detail Content - Inner Text Wrapper */
/* Detail Content - Inner Text Wrapper Defaults */
.col-detail .detail-content {
    width: 100%;
    /* Default: Single line */
    font-size: 0.875rem;
    /* 14px */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tier 1: Medium Text (15-16 chars) - Slightly smaller, still single line */
.col-detail.medium-text .detail-content {
    font-size: 0.8125rem;
    /* 13px */
}

/* Tier 2: Small Text (17-19 chars) - Smallest, still single line */
.col-detail.small-text .detail-content {
    font-size: 0.75rem;
    /* 12px */
}

/* Tier 3: Long Text (>19 chars) - Smallest, Multiline Wrap */
.col-detail.long-text .detail-content {
    /* Multi-line logic applies to the inner block */
    white-space: normal;
    font-size: 0.75rem;
    /* 12px */
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Header Detail Column shouldn't be affected by this if possible,
   but .col-detail is used in header too.
   Header is in .fixed-columns-header, not .left-pane-row. So this selector is safe. */

.col-duration {
    width: var(--col-duration-width);
    justify-content: center;
    color: var(--text-muted);
    flex-direction: column;
    /* Stack text */
    line-height: 1.2;
}

/* Right Pane Grid Cells */
/* Right Pane Grid Cells */
.grid-cell {
    width: var(--day-cell-width);
    height: 100%;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
}

.grid-cell.weekend {
    background-color: var(--weekend-bg);
}

.grid-cell.holiday {
    background-color: var(--holiday-bg);
}

.grid-cell.makeup-workday {
    background-color: #ffffff;
    /* Unified White for all workdays */
}

.grid-cell.makeup-workday::after {
    content: '?;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6rem;
    color: #c2410c;
    /* Dark Orange */
    opacity: 0.7;
}

.grid-cell.filled {
    background-color: var(--success-color);
    border-color: #059669;
}

/* Ensure right pane content is wide enough */
/* Ensure right pane content is wide enough */
.right-pane-content {
    display: block;
    /* Rows should be block elements stacking vertically */
    min-width: max-content;
    /* Ensure container expands to fit widest row (all days) */
}

/* Ensure Row takes full width of content */
.right-pane-row {
    width: 100%;
    /* Or max-content? If parent is max-content, 100% works */
    min-width: 100%;
}

/* Sidebar Header Fix for Collapsed State */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem 0;
    flex-direction: column;
    /* Stack vertically */
    gap: 1rem;
}

.sidebar.collapsed .brand {
    display: none;
    /* Hide brand */
}

.sidebar.collapsed #btnManageHolidays {
    display: none;
    /* Hide Settings Button */
}

/* Ensure Toggle button remains and is centered */
.sidebar.collapsed .sidebar-header>div {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 380px;
    /* Reduced from 450px */
    max-height: 90vh;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.modal-header,
.modal-footer {
    padding: 0.8rem 1rem;
    /* Compact padding */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-footer {
    border-bottom: none;
    border-top: 1px solid var(--border-color);
    text-align: right;
    justify-content: flex-end;
    gap: 12px;
    /* Add space between buttons */
}

.modal-footer .btn {
    width: auto;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
}

/* Improve Cancel Button Look */
.modal-footer .btn.ghost {
    background-color: #f1f5f9;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.modal-footer .btn.ghost:hover {
    background-color: #e2e8f0;
    color: var(--text-color);
}

.close-modal {
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.modal-body {
    padding: 1rem;
    /* Compact padding */
    overflow-y: auto;
}

.calendar-picker {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
    /* Compact padding */
    margin: 0.5rem 0;
}

.cal-nav {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    /* No gaps */
}

/* Weekday Headers */
.cal-weekday {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 0;
    font-weight: 600;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    /* Smaller font */
    border: 1px solid transparent;
    /* Placeholder to avoid jump */
}

/* Add grid lines if gaps are gone? or just tight packing? User said "Remove blank separators". 
   Let's keep it clean without borders for now, or subtle borders. */

.cal-day:hover {
    background: #f1f5f9;
}

.cal-day.selected {
    background: var(--danger-color);
    color: white;
}

.cal-day.custom-workday {
    background: #f97316;
    /* Orange */
    color: white;
}

.cal-month-block {
    margin-bottom: 10px;
}

.cal-month-title {
    text-align: center;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--text-color);
}

/* Calendar Navigation */
.cal-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cal-nav-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 28px;
    /* Smaller buttons */
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s;
}

.cal-nav-btn:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

/* Calendar Visual Feedback - Simplified */
/* Workdays: white background */
.cal-day {
    background-color: #ffffff;
    color: var(--text-color);
}

/* Non-workdays (holidays, weekends, custom holidays): gray background */
.cal-day.weekend,
.cal-day.official-holiday,
.cal-day.selected {
    background-color: #cbd5e1;
    color: #64748b;
}

/* Custom workdays: white background (override any holiday/weekend styling) */
.cal-day.custom-workday {
    background-color: #ffffff;
    color: var(--text-color);
    font-weight: 600;
}

/* Helper for modal close */
.close-modal:hover {
    color: var(--danger-color);
}

.calendar-picker {
    padding: 0.5rem;
    margin: 0.5rem 0;
}

/* Legend Styles */
.status-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-right: 1.5rem;
    /* Space before export button */
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.legend-green {
    background-color: var(--success-color);
    /* #10b981 */
}

.legend-gray {
    background-color: var(--holiday-bg);
    /* #cbd5e1 */
}

/* ========== NEW MULTI-PAGE LAYOUT STYLES ========== */

/* Calendar Settings Panel */
.calendar-settings-panel {
    width: 350px;
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    align-self: flex-start;
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
}

.calendar-settings-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-group {
    margin-bottom: 1.5rem;
}

.setting-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-size: 0.9rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.radio-option:hover {
    background: #f1f5f9;
}

.holidays-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.holidays-list li {
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.settings-actions {
    margin-top: 1.5rem;
}

.settings-actions .btn {
    width: 100%;
}

/* Task Sidebar */
.task-sidebar {
    position: fixed;
    right: -600px;
    top: 0;
    width: 600px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.task-sidebar.active {
    right: 0;
}

.task-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.task-sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.task-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Hide old elements */
.sidebar, .sidebar-header, .sidebar-content, .top-bar {
    display: none !important;
}

#schedulePage .gantt-wrapper {
    flex: 1;
    overflow: hidden;
    padding: 1rem;
}



/* ========== Schedule Page Optimizations ========== */

#schedulePage {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-color);
}

#schedulePage .gantt-wrapper {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: white;
    margin: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

#schedulePage .gantt-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#schedulePage .gantt-header {
    flex-shrink: 0;
}

#schedulePage .gantt-body {
    flex: 1;
    overflow: hidden;
}

/* Ensure proper alignment */
#schedulePage .gantt-left-header,
#schedulePage .gantt-left-pane {
    width: 480px;
    flex-shrink: 0;
}

/* Page header improvements */\r\n#schedulePage .page-header {\r\n    background: white;\r\n    color: var(--text-color);\r\n    padding: 1.5rem 2rem;\r\n    border-bottom: 2px solid var(--border-color);\r\n}\r\n\r\n#schedulePage .page-header h1 {\r\n    color: var(--text-color);\r\n    font-size: 1.5rem;\r\n}\r\n\r\n#schedulePage .page-header h1 i {\r\n    color: var(--primary-color);\r\n}\r\n\r\n#schedulePage .page-header p {\r\n    color: var(--text-muted);\r\n    margin: 0;\r\n}\r\n\r\n#schedulePage .page-header .btn {\r\n    background: transparent;\r\n    color: var(--primary-color);\r\n    border: 1px solid var(--primary-color);\r\n    padding: 0.5rem 1rem;\r\n    font-size: 0.875rem;\r\n}\r\n\r\n#schedulePage .page-header .btn:hover {\r\n    background: var(--primary-color);\r\n    color: white;\r\n}



/* ========== Gantt Header Layout Fix ========== */

.gantt-header {
    display: flex;
    background: #0f172a;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.gantt-left-header {
    width: 480px;
    flex-shrink: 0;
    background: #0f172a;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.gantt-right-header {
    flex: 1;
    overflow: hidden;
    background: #0f172a;
}

.fixed-columns-header {
    display: flex;
    height: 100%;
    color: white;
    font-weight: 600;
}

.fixed-columns-header > div {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    min-height: 48px;
}

.fixed-columns-header .col-service {
    width: var(--col-service-width);
}

.fixed-columns-header .col-detail {
    width: var(--col-detail-width);
    flex: 1;
}

.fixed-columns-header .col-duration {
    width: var(--col-duration-width);
}

.scrollable-dates-header {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    color: white;
    height: 100%;
}




/* Fix task manager button width */
#schedulePage .page-header .btn {
    width: auto !important;
    white-space: nowrap;
    flex-shrink: 0;
}



/* Ensure input visibility in task sidebar */
.task-sidebar #inputService {
    display: block !important;
    width: 100%;
    margin-top: 0.5rem;
}

.task-sidebar .service-selection-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.task-sidebar .mt-2 {
    margin-top: 0.5rem;
}



/* Last day of task highlight */
.grid-cell.filled-last {
    background-color: #ef4444; /* Red color */
    border-radius: 2px;
}



/* Fix border radius for last day */
.grid-cell.filled-last {
    border-radius: 0 !important;
}



/* Ensure filled-last overrides background */
.grid-cell.filled.filled-last {
    background-color: #ef4444 !important;
    opacity: 1; /* Make it pop */
}



/* Collapsible Settings Panel */
.calendar-layout {
    display: block !important; /* Remove grid layout to allow full width calendar */
    position: relative;
    overflow-x: hidden;
}

.calendar-settings-panel {
    position: fixed;
    top: 0;
    right: -320px; /* Hide by default */
    width: 320px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 1050;
    transition: right 0.3s ease;
    padding: 1.5rem;
    overflow-y: auto;
}

.calendar-settings-panel.active {
    right: 0;
}

/* Overlay for settings */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    z-index: 1040;
    display: none;
}

.settings-overlay.active {
    display: block;
}

/* Add close button within panel if needed, but clicking outside is enough usually */



/* Page Layout Fixes */
.page {
    display: none;
    height: 100%;
    overflow-y: auto; /* Allow internal scrolling */
    flex-direction: column;
}

.page.active {
    display: flex;
}

/* Header Actions Layout */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}



/* Enforce Page Hiding */
.page {
    display: none !important;
}

.page.active {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    overflow-y: hidden; /* Main page container should not scroll if content scrolls */
}

/* Allow calendar content to scroll if needed, but usually year grid fits or scrolls internally */
.calendar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}



/* Distinct Holiday Colors */
.grid-cell.holiday-official {
    background-color: #fee2e2; /* Red-100 */
    color: #991b1b;
}

.grid-cell.holiday-custom {
    background-color: #f3e8ff; /* Purple-100 */
    color: #581c87;
}

.grid-cell.workday-makeup {
    background-color: #ffedd5; /* Orange-100 */
    color: #9a3412;
    position: relative;
}
.grid-cell.workday-makeup::after {
    content: '\73ED';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    opacity: 0.5;
}

.grid-cell.workday-custom {
    background-color: #dbeafe; /* Blue-100 */
    color: #1e40af;
}



/* Calendar Month View Distinct Colors */
.month-day.holiday-official {
    background-color: #fee2e2;
    color: #991b1b;
}

.month-day.holiday-custom {
    background-color: #f3e8ff;
    color: #581c87;
}

.month-day.workday-makeup {
    background-color: #ffedd5;
    color: #9a3412;
}
.month-day.workday-makeup::after {
    content: '\73ED';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    opacity: 0.8;
}

.month-day.workday-custom {
    background-color: #dbeafe;
    color: #1e40af;
}
/* Override default holiday/workday if needed */



/* Calendar Legend */
.calendar-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 12px;
    font-size: 0.8rem;
    color: #64748b;
}
.calendar-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}
.color-dot.holiday-official { background-color: #fee2e2; border: 1px solid #fecaca; }
.color-dot.workday-makeup { background-color: #ffedd5; border: 1px solid #fed7aa; }
.color-dot.holiday-custom { background-color: #f3e8ff; border: 1px solid #e9d5ff; }
.color-dot.workday-custom { background-color: #dbeafe; border: 1px solid #bfdbfe; }



/* Force Panel Logic */
.calendar-settings-panel {
    position: fixed !important;
    top: 0;
    right: -320px !important;
    width: 320px;
    height: 100vh;
    background: white;
    z-index: 1050;
    transition: right 0.3s ease;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    display: block;
}
.calendar-settings-panel.active {
    right: 0 !important;
}



/* Force Gantt Visibility */
.gantt-wrapper {
    flex: 1;
    height: calc(100vh - 120px) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.gantt-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
}
.gantt-body {
   flex: 1;
   overflow: auto;
   background: white;
}



/* Fix holiday panel visibility */
.calendar-settings-panel {
    z-index: 50;
    position: sticky;
    top: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Ensure header does not overlap */
.page-header {
    z-index: 60;
    position: relative;
}



/* Center Year Controls */
#calendarPage .page-header {
    position: relative;
    justify-content: center;
}

#calendarPage .page-header h1 {
    position: absolute;
    left: 2rem;
}

#calendarPage .year-controls {
    margin: 0 auto;
    background: #f8f9fa;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}



/* Force panel visibility */
.calendar-content {
    flex-wrap: wrap;
    justify-content: center;
}

.calendar-settings-panel {
    min-width: 350px;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    margin-top: 1rem;
}



/* Use Grid for Calendar Layout to fix panel visibility */
.calendar-content {
    display: grid !important;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    align-items: start;
    overflow-x: hidden;
}

.calendar-year-grid {
    width: 100%;
    min-width: 0; /* Prevent grid blowout */
}

/* Responsive: Stack vertically on smaller screens */
@media (max-width: 1400px) {
    .calendar-content {
        grid-template-columns: 1fr;
    }
    .calendar-settings-panel {
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
        position: static; /* Disable sticky when stacked */
    }
}



/* Settings Sidebar (Slide-out) */
.settings-sidebar {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.settings-sidebar.active {
    right: 0;
}

.settings-sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-sidebar-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Reset Calendar Layout */
.calendar-content {
    display: block !important;
    padding: 2rem;
}

.calendar-year-grid {
    width: 100%;
    max-width: 1600px; /* Limit max width for better readability */
    margin: 0 auto;
}



/* Refine Holiday Settings Button */
#btnOpenHolidaySettings {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    gap: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
}

#btnOpenHolidaySettings i {
    font-size: 0.9rem;
}



/* Fix Holiday Settings Button Style */
#btnOpenHolidaySettings {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    box-shadow: var(--shadow-sm);
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    z-index: 100;
    /* Reset any inherited flex properties */
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
}

#btnOpenHolidaySettings:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
    color: var(--primary-color);
}



/* Extra Reset for Button */
#calendarPage .page-header {
    position: relative;
    min-height: 60px;
}

#btnOpenHolidaySettings {
    box-sizing: border-box;
    line-height: 1.5;
    cursor: pointer;
    white-space: nowrap;
    min-width: auto;
}



/* Task End Date Style */
.grid-cell.filled-end {
    background-color: #ef4444 !important; /* Red-500 */
    border-color: #dc2626 !important; /* Red-600 */
    position: relative;
}

.grid-cell.filled-end::after {
    /* Optional: Add a small marker or texture if needed, but solid red is requested */
}



/* Export Modal Styles */
.checkbox-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
}

.checkbox-option:hover {
    background: var(--bg-color);
}

.select-all-option {
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

/* Utility for export filtering */
.hidden-for-export {
    display: none !important;
}



/* Export Options Modal */
.export-options-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 300px;
    overflow-y: auto;
    margin: 1rem 0;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.export-option-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

.export-option-item:hover {
    background-color: var(--bg-color);
}

.export-option-item input[type='checkbox'] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

/* Helper for export filtering */
.hidden-for-export {
    display: none !important;
}



/* Export Image Button Hover */
#btnExportImage:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,1);
}



/* Export Image Button Hover */
#btnExportImage:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,1);
}



/* Improved Export Button Visibility */
#btnExportImage {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background-color: white;
}

#btnExportImage:hover {
    background-color: var(--primary-color);
    color: white;
}



/* Calendar - Fit all in viewport without scrolling */
.calendar-content {
    overflow: hidden !important;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.calendar-year-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
}

.month-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.month-grid {
    flex: 1;
    min-height: 0;
}



/* Fix calendar full display - override previous */
#calendarPage {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#calendarPage .calendar-content {
    flex: 1;
    overflow: auto !important;
    display: block;
    padding: 1.5rem;
}

#calendarPage .calendar-year-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    width: 100%;
    max-width: 100%;
}

#calendarPage .month-container {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 0;
}



/* Compact calendar layout for full year view */
#calendarPage .calendar-year-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.8rem !important;
    padding: 1rem !important;
}

#calendarPage .month-container {
    padding: 0.5rem !important;
    font-size: 0.85rem !important;
}

#calendarPage .month-header {
    font-size: 0.9rem !important;
    padding: 0.3rem !important;
    margin-bottom: 0.3rem !important;
}

#calendarPage .month-weekdays {
    gap: 2px !important;
    margin-bottom: 0.2rem !important;
}

#calendarPage .month-weekday {
    font-size: 0.7rem !important;
    padding: 0.2rem !important;
}

#calendarPage .month-grid {
    gap: 2px !important;
}

#calendarPage .month-day {
    font-size: 0.75rem !important;
    padding: 0.3rem !important;
    min-height: 28px !important;
}



/* Ensure consistent sizing across all months */
#calendarPage .month-container {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

#calendarPage .month-header {
    flex-shrink: 0 !important;
    height: 2rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#calendarPage .month-weekdays {
    flex-shrink: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
}

#calendarPage .month-weekday {
    height: 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#calendarPage .month-grid {
    flex: 1 !important;
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    grid-auto-rows: 1fr !important;
}

#calendarPage .month-day {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}



/* Fix February cell size issue - use fixed aspect ratio */
#calendarPage .month-grid {
    grid-auto-rows: minmax(32px, auto) !important;
    align-content: start !important;
}

#calendarPage .month-day {
    aspect-ratio: 1 / 1 !important;
    max-height: 40px !important;
}



/* Remove bottom whitespace - compact month containers */
#calendarPage .month-container {
    height: auto !important;
    min-height: 0 !important;
}

#calendarPage .month-grid {
    flex: 0 0 auto !important;
}

 
 