/* =================================== */
/* Base Calendar Styles              */
/* =================================== */

#calendar-main-container {
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
}

#calendar-container {
    width: 100%;
    max-width: 1400px;
    background-color: rgba(255, 255, 255, 0.92);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
}

#calendar-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #57b31b;
    background-color: #67ce25;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    gap: 10px;
    position: relative;
    color: white;
    flex-shrink: 0;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.month-navigation {
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.month-display-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 10px;
    min-width: 220px;
}

#current-month-display {
    color: white;
    margin: 0;
    line-height: 1;
}

#hoursTallyDisplayToolbar {
    margin-top: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    flex-grow: 1;
    min-height: 0;
}

.calendar-header-day {
    font-weight: bold;
    text-align: center;
    padding: 8px 5px;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    height: 40px;
}
.calendar-header-day:last-child {
    border-right: none;
}

.calendar-day {
    border-bottom: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    padding: 8px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.day-number {
    font-weight: 500;
    margin-bottom: 5px;
}

.calendar-day.other-month .day-number {
    color: #adb5bd;
}

.calendar-day.today {
    background-color: #fffbe6;
}

.calendar-day.today .day-number {
    background-color: #0000EE;
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.shift-event {
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1a237e;
    border-left: 4px solid;
}

.shift-event:hover {
    background-color: #cce4ff;
}

#publish-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shift-event.draft-new { box-shadow: 0 0 0 2px #28a745; }
.shift-event.draft-modified { box-shadow: 0 0 0 2px #ffc107; }
.shift-event.draft-deleted {
    opacity: 0.5;
    text-decoration: line-through;
    background-color: #e9ecef !important;
    border-color: #6c757d !important;
}

#calendar-store-filter { width: 200px; background-color: white; color: #343a40; }
#calendar-view-switcher { width: 100px; background-color: white; color: #343a40; }

#filters-toggle-btn { display: none; }
#filters-menu .form-group { margin-bottom: 0; }
#userSettingsModal .management-setting-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
#userSettingsModal .toggle-switch { width: 44px; height: 24px; }

/* Styles for Week and Day Views */
#calendar-grid.week-view,
#calendar-grid.day-view {
    position: relative;
    overflow-y: auto;
    /* This removes the row grid, as positioning is now handled by JS */
    grid-template-rows: 50px auto; 
}

/* This is the new container for each day in week/day view */
.day-column-container {
    position: relative;
    border-right: 1px solid #dee2e6;
    padding: 4px; /* Add a little padding inside the day column */
}

.today-highlight {
    background-color: #fffbe6;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 0;
}

.time-slot-header {
    height: 50px;
    text-align: center;
    border-bottom: 1px solid #dee2e6;
    font-weight: bold;
    padding: 5px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

.time-slot-header.today {
    background-color: #fff9d4;
    border-bottom: 2px solid #ffc107;
}

.time-label-column {
    /* This column is no longer needed with the stacked view */
    display: none;
}

.week-view .shift-event, .day-view .shift-event,
.week-view .timeoff-event, .day-view .timeoff-event,
.gap-event {
    position: relative;
    z-index: 2; /* Increased z-index to appear above highlights */
    white-space: normal;
    overflow: hidden;
    margin: 0 0 4px 0; /* Removed horizontal margins for full width */
    padding: 2px 6px;
    font-size: 0.8rem;
    box-sizing: border-box;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* This is the new style for our individual time blocks */
.time-slot {
    border-bottom: 1px dotted #e9ecef;
    box-sizing: border-box;
}

/* This is the new style for a gap in coverage */
.time-slot.is-gap {
    background-color: rgba(220, 53, 69, 0.4);
    border-left: 1px solid rgba(220, 53, 69, 0.6);
    border-right: 1px solid rgba(220, 53, 69, 0.6);
}

/* This rule replaces the old .hour-line and .half-hour-line */
.time-slot.hour-start {
    border-top: 1px solid #dee2e6;
}

/* =================================== */
/* MODAL STYLES FOR CALENDAR PAGE      */
/* =================================== */

.modal-overlay {
	display: none;
	position: fixed;
	top: 0; left: 0;
	width: 100%; height: 100%;
	background-color: rgba(0, 0, 0, 0.6);
	z-index: 1000;
}

.modal-overlay.is-visible {
    display: block;
}

.modal {
	display: none;
	position: fixed;
	left: 50%; 
	top: 50%;
	transform: translate(-50%, -50%);
	background-color: #fff;
	border-radius: 8px;
	box-shadow: 0 4px 15px rgba(0,0,0,0.2);
	overflow: hidden;
	z-index: 1010;
	width: 90%;
}
.modal .modal-header {
    background-color: #67ce25;
    border-bottom: 1px solid #57b31b;
    color: white;
}
.modal .modal-header h2, .modal .modal-header h3 { color: white; }
.modal .modal-header .close-button { color: white; opacity: 0.8; }
.modal .modal-header .close-button:hover { opacity: 1; }

#shift-modal { max-width: 500px; }
#shift-detail-modal { max-width: 450px; }
#userSettingsModal { max-width: 450px; }
#infoModal { max-width: 450px; }
#confirmationModal { z-index: 1060; max-width: 450px; }

/* =================================== */
/* New Menu and Gap Coverage Styles    */
/* =================================== */

#menu-toggle-btn {
    display: inline-block;
}

.side-menu {
    position: fixed;
    top: 0;
    right: -300px; /* Start off-screen */
    width: 280px;
    height: 100%;
    background-color: #f8f9fa;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    padding: 20px;
    padding-top: 60px; /* Space for close button */
    transition: right 0.3s ease-in-out;
    border-left: 1px solid #dee2e6;
    z-index: 1050; /* Z-INDEX MUST BE HIGHER THAN OVERLAY */
}

.side-menu.open {
    right: 0;
}

.side-menu .close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 28px;
}

.side-menu h3 {
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #ccc;
    padding-bottom: 10px;
}

.side-menu .form-group {
    margin-bottom: 15px;
}
.side-menu .form-group label {
    font-weight: bold;
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-actions .btn {
    width: 100%;
    margin: 0;
}

.gap-indicator {
    position: absolute;
    left: 0;
    width: 100%;
    background-color: rgba(220, 53, 69, 0.4);
    z-index: 1; /* Places it behind shifts */
    pointer-events: none;
    box-sizing: border-box;
}

/* This is the key fix that temporarily overrides the body style from style.css */
body.side-menu-is-open {
    overflow-x: visible !important;
}

/* --- Time Off Approval Modal Styles --- */
.pending-request-item {
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    margin-bottom: 10px;
    background-color: #f8f9fa;
}

.pending-request-item:last-child {
    margin-bottom: 0;
}

.pending-request-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.pending-request-header h4 {
    margin: 0;
    font-size: 1.1rem;
}

.pending-request-header .request-date {
    font-size: 0.9rem;
    color: #6c757d;
}

.pending-request-details p {
    margin: 4px 0;
    font-size: 0.95rem;
}

.pending-request-actions {
    margin-top: 15px;
    text-align: right;
}

/* --- Side Menu Theming --- */
.side-menu {
    padding: 0; /* Remove old padding to allow header to be full-width */
}

.side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #67ce25;
    border-bottom: 1px solid #57b31b;
    color: white;
}

.side-menu-header h3 {
    margin: 0;
    padding: 0;
    border: none;
    color: white;
    font-size: 1.2rem;
}

.side-menu-header .close-button {
    color: white;
    opacity: 0.9;
}
.side-menu-header .close-button:hover {
    opacity: 1;
}

.side-menu-content {
    padding: 20px; /* Add padding to the content area instead */
}

/* --- Time Off Event Style Enhancements --- */
.timeoff-event {
    /* These new properties give the event block depth and shape */
    padding: 5px 8px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-size: 0.85rem; /* This line was added */
    
    /* These are existing properties, but ensure they are set */
    background-color: transparent !important;
    background-image: repeating-linear-gradient(
        45deg,
        #d1d1d1,
        #d1d1d1 8px,
        transparent 8px,
        transparent 16px
    );
    border-left: 4px solid #6c757d !important;
    color: #343a40 !important;
    font-weight: normal; /* This line was changed from 500 */
    cursor: default !important;
}

.gap-event {
    background-color: #fbebee;
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.timeoff-event.editable-for-admin {
    cursor: pointer !important;
}

.timeoff-event:hover.editable-for-admin {
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    filter: brightness(1.05);
}

/* --- Consistent Event Sizing & Text Styling --- */
.month-view .shift-event, .month-view .timeoff-event {
    min-height: 40px;
    height: 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.shift-event .event-time, .timeoff-event .event-time, .gap-event .event-time {
    font-weight: bold;
    font-size: 0.9em;
}

.shift-event .event-details, .timeoff-event .event-details {
    font-size: 0.8rem;
}

/* --- Widen Day View Events --- */
.day-view .shift-event, .day-view .timeoff-event {
    margin: 1px 2px; /* Reduce horizontal margin to maximize width */
}

/* --- Side Menu Reset Button Style --- */
#reset-calendar-filters-btn {
    color: white;
    opacity: 0.9;
    margin-right: 10px; /* Adds space between it and the close button */
    font-size: 1.2rem;  /* Makes the icon a bit smaller than the 'X' */
    vertical-align: middle;
}
#reset-calendar-filters-btn:hover {
    opacity: 1;
}

/* --- Pending Requests Button & Badge Styles --- */
.btn-warning {
    background-color: #ffc107;
    color: #000;
    border-color: #ffc107;
}

.btn-warning:hover {
    background-color: #ffca2c;
    border-color: #ffc720;
}

#menu-toggle-btn {
    position: relative;
}

#pending-requests-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    display: none; /* Hidden by default */
}

/* --- Fix for Clickable Event Cursor --- */
.clickable-event {
    cursor: pointer !important;
}

/* --- Fix for Detail Modal Button Layout --- */
#shift-detail-modal .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-indicator {
    background-color: rgba(220, 53, 69, 0.4);
    border-left: 2px solid #dc3545;
    border-right: 2px solid #dc3545;
    z-index: 0;
    pointer-events: none;
    box-sizing: border-box;
}

/* --- Fix for Shift Modal Button Layout --- */
#shift-modal .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Time Clock Header Styles --- */
.time-clock-container {
    display: flex;
    flex-direction: column; /* Stack items vertically */
    align-items: center;    /* Center them horizontally */
    justify-content: center;
    gap: 4px;               /* Space between text and buttons */
    margin: 0 auto;
    min-width: 220px;       /* Give the container a consistent width */
}

.time-clock-buttons {
    display: flex;
    gap: 10px; /* Space between buttons when there are two */
}

#time-clock-container {
    display: none !important;
}

/* =================================== */
/* Mobile Layout Improvements        */
/* =================================== */

@media (max-width: 768px) {
    #calendar-container { height: auto; }
    
    #calendar-toolbar {
        display: grid !important;
        width: 100% !important;
        grid-template-columns: auto 1fr auto !important;
        grid-template-rows: auto auto !important;
        grid-template-areas:
            "prev month next"
            "today add_shift filters" !important;
        gap: 10px 5px !important;
        align-items: center !important;
        flex-direction: initial !important;
        padding: 10px !important;
    }

    #calendar-toolbar .month-navigation, 
    #calendar-toolbar .action-controls {
        display: contents !important;
    }

    #calendar-toolbar #prev-month-btn { grid-area: prev !important; }
    #calendar-toolbar .month-display-group { grid-area: month !important; text-align: center !important; }
    #calendar-toolbar #next-month-btn { grid-area: next !important; }
    #calendar-toolbar #today-btn { grid-area: today !important; justify-self: start !important; }
    #calendar-toolbar #publish-controls { grid-area: add_shift !important; display: flex !important; justify-content: center !important; }
    #calendar-toolbar #menu-toggle-btn { grid-area: filters !important; justify-self: end !important; }
    
    #add-shift-btn, #menu-toggle-btn {
        display: inline-block !important;
    }

    #prev-month-btn, #next-month-btn, #today-btn, #menu-toggle-btn, #add-shift-btn {
        padding: 6px 10px;
        font-size: 0.9em;
        white-space: nowrap;
    }

    #current-month-display {
        min-width: 0;
        font-size: 1.1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    #hoursTallyDisplayToolbar {
        display: block;
    }
    
    #calendar-grid { overflow-y: visible; }
    .calendar-header-day { font-size: 0.8rem; padding: 5px 2px; }
    .calendar-day { padding: 4px; }
    .day-number { font-size: 0.9rem; }
    .shift-event { font-size: 0.75rem; padding: 3px 5px; }
    .shift-event .event-details { display: block !important; }
}