/**
 * FullCalendar Custom Styles
 * Override FullCalendar styles để match thiết kế hiện tại
 */

/* FullCalendar Bootstrap 5 customization */
.fc {
    font-family: inherit;
    font-size: 0.875rem;
}

/* Event styling */
.fc-event {
    cursor: pointer;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    margin: 1px 0 !important; /* Đảm bảo margin đều nhau */
    height: auto !important; /* Cho phép height tự động */
    min-height: 20px; /* Đảm bảo minimum height */
}

/* Custom templates (simple/detail) for event/task blocks */
.fc-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.fc-item__row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0; /* allow ellipsis */
}

.fc-item__title {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc-item__time {
    font-size: 12px;
    line-height: 1.2;
    color: inherit; /* match title color */
}

/* Month view stack and responsive height */
.fc .fc-daygrid-event {
    height: auto;
    max-width: 100%;
}

/* Time views expand */
.fc .fc-timegrid-event-harness .fc-timegrid-event,
.fc .fc-timegrid-event {
    height: auto;
}

/* Ensure event content inside time views is column layout */
.fc .fc-timegrid-event .fc-event-main,
.fc .fc-timegrid-event .fc-item {
    display: flex;
    flex-direction: column;
}

/* Ensure full width content */
.fc .fc-event .fc-event-main {
    width: 100%;
}

.fc-event:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.fc-event-main-frame {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.fc-event-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Task indicator */
.fc-event .bi-check-circle {
    color: inherit; /* Màu theo text của event */
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* Event indicator */
.fc-event .bi-calendar-event {
    color: inherit; /* Màu theo text của event */
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* Day cell styling */
.fc-daygrid-day {
    min-height: 100px;
    background-color: white;
    border: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.fc-daygrid-day:hover {
    background-color: #f8f9fa;
}

.fc-daygrid-day-top {
    /* Cố định chiều cao phần header của từng ô để events không bị lệch hàng */
    height: 32px; /* đồng nhất trên mọi ngày */
    padding: 4px 6px !important;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.fc-daygrid-day-number {
    font-weight: 600;
    color: #495057;
    font-size: 0.875rem;
    /* Chuẩn hoá kích thước và bỏ padding để không đẩy lệch events */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    line-height: 24px;
    border-radius: 50%;
    padding: 0; /* tránh cao hơn bình thường */
    margin: 0;  /* tránh lệch so với các ô khác */
}

/* Today highlight */
.fc-day-today {
    background-color: #e3f2fd !important;
}

.fc-day-today .fc-daygrid-day-number {
    background-color: #2196f3;
    color: white;
}

/* Other month days */
.fc-day-other {
    background-color: #f8f9fa;
    color: #6c757d;
}

.fc-day-other .fc-daygrid-day-number {
    color: #6c757d;
}

/* Week view styling */
.fc-timegrid-slot {
    min-height: 60px; /* baseline, sẽ tăng động theo JS */
    height: auto !important;
    border-bottom: 1px solid #e9ecef;
}

.fc-timegrid-slot-label {
    font-size: 0.75rem;
    color: #6c757d;
    padding: 0.25rem;
}

.fc-timegrid-event {
    border-radius: 0.25rem;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.fc-timegrid-event:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

/* Day view styling */
.fc-timegrid-col-events {
    margin: 0 2px;
}

/* Header styling */
.fc-col-header-cell {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 0.875rem;
    color: #6c757d;
    padding: 0.75rem 0.5rem;
    text-align: center;
}

/* More events link */
.fc-more-link {
    color: #6c757d;
    font-size: 0.625rem;
    font-style: italic;
    text-decoration: none;
}

.fc-more-link:hover {
    color: #495057;
    text-decoration: underline;
}

/* Popover styling */
.fc-popover {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.fc-popover-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem;
    font-weight: 600;
}

.fc-popover-body {
    padding: 0.75rem;
}

/* Event overlap handling */
.fc-event-overlap {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .fc {
        font-size: 0.75rem;
    }
    
    .fc-daygrid-day {
        min-height: 80px;
    }
    
    .fc-event {
        font-size: 0.625rem;
        padding: 0.125rem 0.25rem;
    }
    
    .fc-event-main-frame {
        gap: 0.125rem;
    }
    
    .fc-event .bi-check-circle,
    .fc-event .bi-calendar-event {
        font-size: 0.625rem;
        color: inherit; /* Màu theo text của event */
    }
    
    .fc-daygrid-day-number {
        font-size: 0.75rem;
    }
    
    .fc-timegrid-slot {
        min-height: 50px;
        height: auto !important;
    }
    
    .fc-timegrid-slot-label {
        font-size: 0.625rem;
    }
}

@media (max-width: 576px) {
    .fc-daygrid-day {
        min-height: 60px;
    }
    
    .fc-event {
        font-size: 0.5rem;
        padding: 0.125rem;
    }
    
    .fc-daygrid-day-number {
        font-size: 0.625rem;
    }
    
    .fc-timegrid-slot {
        min-height: 40px;
        height: auto !important;
    }
    
    .fc-timegrid-slot-label {
        font-size: 0.5rem;
    }
}

/* (removed) Custom 4 days view */

/* Full width harness and event in timeGrid */
.fc .fc-timegrid-event-harness,
.fc .fc-timegrid-event-harness > .fc-timegrid-event {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
}

/* Cho phép bảng slots auto height theo nội dung */
.fc-timegrid-slots table tr {
    height: auto !important;
}

/* Event colors for different types */
.fc-event.task {
    background-color: #28a745;
    border-color: #28a745;
}

.fc-event.event {
    background-color: #007bff;
    border-color: #007bff;
}

.fc-event.task .fc-event-main-frame {
    color: white;
}

.fc-event.event .fc-event-main-frame {
    color: white;
}

/* Loading state */
.fc-loading {
    opacity: 0.6;
}

/* Empty state */
.fc-daygrid-day-events {
    min-height: 20px;
}

/* Event alignment fixes */
.fc-daygrid-day-events {
    padding: 2px 4px !important; /* Đảm bảo padding đều nhau cho tất cả day cells */
    margin: 0 !important;
}

.fc-daygrid-event {
    margin: 1px 0 !important; /* Đảm bảo margin giữa các events đều nhau */
    width: 100% !important; /* Đảm bảo width đầy đủ */
}

/* Force consistent event positioning */
.fc-daygrid-day-events .fc-event {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
}

/* Hide day numbers in timeGrid views (Week/Day) to remove blue circles */
.fc-timeGridWeek-view .fc-daygrid-day-number,
.fc-timeGridDay-view .fc-daygrid-day-number {
    display: none !important;
}

/* Hide day number containers in timeGrid views */
.fc-timeGridWeek-view .fc-daygrid-day-top,
.fc-timeGridDay-view .fc-daygrid-day-top {
    display: none !important;
}

/* Ensure events in Week/Day view use same styling as Month view */
.fc-timeGridWeek-view .fc-event,
.fc-timeGridDay-view .fc-event {
    cursor: pointer;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    margin: 1px 0 !important;
    height: auto !important;
    min-height: 20px;
}

.fc-timeGridWeek-view .fc-event-main-frame,
.fc-timeGridDay-view .fc-event-main-frame {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.fc-timeGridWeek-view .fc-event-title,
.fc-timeGridDay-view .fc-event-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Task/Event icons in Week/Day view */
.fc-timeGridWeek-view .fc-event .bi-check-circle,
.fc-timeGridWeek-view .fc-event .bi-calendar-event,
.fc-timeGridDay-view .fc-event .bi-check-circle,
.fc-timeGridDay-view .fc-event .bi-calendar-event {
    color: inherit;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* Ensure all events use consistent styling regardless of view type */
.fc-timegrid-event,
.fc-daygrid-event {
    cursor: pointer;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    margin: 1px 0 !important;
    height: auto !important;
    min-height: 20px;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
}

.fc-timegrid-event .fc-event-main-frame,
.fc-daygrid-event .fc-event-main-frame {
    display: flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
    width: 100% !important;
}

.fc-timegrid-event .fc-event-title,
.fc-daygrid-event .fc-event-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.fc-timegrid-event .bi-check-circle,
.fc-timegrid-event .bi-calendar-event,
.fc-daygrid-event .bi-check-circle,
.fc-daygrid-event .bi-calendar-event {
    color: inherit;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* Force timeGrid events to use same styling as dayGrid */
.fc-timegrid-event {
    display: flex !important;
    align-items: center !important;
    flex-direction: row !important;
    width: 100% !important;
}

.fc-timegrid-event .fc-event-main-frame {
    display: flex !important;
    align-items: center !important;
    flex-direction: row !important;
    width: 100% !important;
}

/* Keep existing calendar.css for Schedule and Year views */
