/* CSS Variables for consistent colors */
:root {
    --primary-color: #282d3b;
    --secondary-color: #6b7280;
    --accent-color: #DC7E7E;
    --hover-bg: rgba(0, 0, 0, 0.1);
    --light-bg: #f8f9fa;
    --border-color: #e5e7eb;
    --text-muted: #9ca3af;
}

/* Infinite Calendar Styles */
.task_tracker_infinite_calendar_container {
    scroll-behavior: smooth;
    position: relative;
    background: #fff;
    /* No height limit - use main page scroll */
    min-height: 100vh;
    margin: 0;
    border-radius: 12px;

    /* Ensure infinite scroll works */
    height: auto;
    overflow: visible;
}

/* Mobile styles for infinite_calendar_container */
@media (max-width: 768px) {
    .task_tracker_infinite_calendar_container {
        margin: 0 4px;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        /* Ensure container is visible and scrollable */
        overflow-x: auto;
        overflow-y: visible;
        width: calc(100% - 8px);
    }
    
    /* Ensure calendar instances are visible */
    .task_tracker_calendar_day_container {
        width: 100%;
        min-width: 320px;
    }
    
    .task_tracker_calendar_day_content {
        width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 576px) {
    .task_tracker_infinite_calendar_container {
        margin: 0 4px;
        border-radius: 6px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
}

/* Loading Spinner Styles - имитация следующего дня */
.task_tracker_loading_spinner {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    margin-top: 20px;
    overflow: hidden;
}

.task_tracker_spinner_day_header {
    background: #f8f9fa;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.task_tracker_spinner_day_number {
    font-size: 2rem;
    font-weight: 700;
    color: #d1d5db;
    min-width: 50px;
}

.task_tracker_spinner_day_name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task_tracker_spinner_content {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--secondary-color);
    font-size: 14px;
    font-weight: 500;
    background: #f8f9fa;
}

.task_tracker_spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Calendar Day Container Styles */
.task_tracker_calendar_day_container {
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 0;
    background: #fff;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Cross-day drag-over visual feedback */
.task_tracker_calendar_day_container.drag-over {
    background: #EFF6FF;
    box-shadow: inset 0 0 0 3px #3B82F6;
}

.task_tracker_calendar_day_header {
    background: #f8f9fa;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 5;
}

.task_tracker_calendar_day_number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 50px;
}

.task_tracker_calendar_day_name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task_tracker_calendar_day_date {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto;
}

.task_tracker_calendar_day_content {
    background: #fff;
    position: relative;
    z-index: 1;
    padding: 0;
}

.task_tracker_calendar_instance {
    width: 100%;
    height: auto;
}

/* Ensure FullCalendar has proper height for infinite scroll */
.task_tracker_calendar_instance .fc {
    height: auto !important;
}

.task_tracker_calendar_instance .fc-view-harness {
    height: auto !important;
}

.task_tracker_calendar_instance .fc-timegrid {
    height: auto;
}

/* Mobile styles for calendar day containers */
@media (max-width: 768px) {
    .task_tracker_calendar_day_header {
        padding: 12px 16px;
        gap: 12px;
    }
    
    .task_tracker_calendar_day_number {
        font-size: 1.8rem;
        min-width: 45px;
    }
    
    .task_tracker_calendar_day_name {
        font-size: 1rem;
    }
    
    .task_tracker_calendar_day_date {
        font-size: 0.8rem;
    }
    
    /* FullCalendar mobile optimizations */
    .task_tracker_calendar_instance {
        width: 100% !important;
        height: auto !important;
        min-height: 400px !important;
    }
    
    .fc {
        font-size: 12px !important;
    }
    
    .fc-timegrid-slot {
        height: 40px !important;
    }
    
    .fc-timegrid-slot-label {
        width: 60px !important;
        font-size: 1.008rem !important;
        padding: 0 8px !important;
        padding-top: 0px !important;
    }
    
    .fc-timegrid-slot-label-cushion {
        margin-top: -12px !important;
    }
    
    /* Special styling for first time slot on mobile */
    .fc-timegrid-slot[data-time="00:00:00"] .fc-timegrid-slot-label-cushion {
        margin-top: -18px !important;
        z-index: 15 !important;
    }
    
    .fc-timegrid-slot-label-cushion::after {
        width: 40px;
        height: 20px;
        border-radius: 10px;
    }
    
    .fc-event {
        font-size: 0.75rem !important;
        padding: 4px 8px !important;
        margin: 1px 2px !important;
    }
    
    .fc-event::after {
        top: 6px;
        right: 6px;
        width: 14px;
        height: 14px;
    }
    
    .fc-event.completed::before {
        top: 4px;
        right: 4px;
        font-size: 10px;
    }
    
    .fc-event::before {
        width: 28px;
        height: 28px;
    }
    
    .fc-timegrid-event {
        font-size: 0.7rem !important;
    }
    
    .fc-timegrid-event-title {
        font-size: 0.7rem !important;
    }
    
    .fc-timegrid-event-time {
        font-size: 0.65rem !important;
    }
}

@media (max-width: 576px) {
    .task_tracker_calendar_day_header {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .task_tracker_calendar_day_number {
        font-size: 1.6rem;
        min-width: 40px;
    }
    
    .task_tracker_calendar_day_name {
        font-size: 0.9rem;
    }
    
    .task_tracker_calendar_day_date {
        font-size: 0.75rem;
    }
    
    /* FullCalendar extra small mobile optimizations */
    .task_tracker_calendar_instance {
        width: 100% !important;
        height: auto !important;
        min-height: 350px !important;
    }
    
    .fc {
        font-size: 11px !important;
    }
    
    .fc-timegrid-slot {
        height: 35px !important;
    }
    
    .fc-timegrid-slot-label {
        width: 50px !important;
        font-size: 0.936rem !important;
        padding: 0 6px !important;
        padding-top: 0px !important;
    }
    
    .fc-timegrid-slot-label-cushion {
        margin-top: -10px !important;
    }
    
    /* Special styling for first time slot on extra small mobile */
    .fc-timegrid-slot[data-time="00:00:00"] .fc-timegrid-slot-label-cushion {
        margin-top: -16px !important;
        z-index: 15 !important;
    }
    
    .fc-timegrid-slot-label-cushion::after {
        width: 36px;
        height: 18px;
        border-radius: 9px;
    }
    
    .fc-event {
        font-size: 0.7rem !important;
        padding: 3px 6px !important;
        margin: 1px !important;
    }
    
    .fc-event::after {
        top: 5px;
        right: 5px;
        width: 12px;
        height: 12px;
    }
    
    .fc-event.completed::before {
        top: 3px;
        right: 3px;
        font-size: 9px;
    }
    
    .fc-event::before {
        width: 24px;
        height: 24px;
    }
    
    .fc-timegrid-event {
        font-size: 0.65rem !important;
    }
    
    .fc-timegrid-event-title {
        font-size: 0.65rem !important;
    }
    
    .fc-timegrid-event-time {
        font-size: 0.6rem !important;
    }
    
    /* Ensure calendar is visible and functional */
    .fc-timegrid-body {
        height: auto !important;
        min-height: 300px !important;
    }
    
    .fc-timegrid-slots {
        height: auto !important;
        min-height: 300px !important;
    }
    
    .fc-timegrid-table {
        height: auto !important;
    }
}

/* React Big Calendar Styles */
.agenda-view-container {
    padding: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Custom styles for React Big Calendar */
.rbc-calendar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.rbc-header {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 12px 8px;
    font-weight: 600;
    color: #495057;
}

.rbc-today {
    background-color: #e3f2fd !important;
}

.rbc-event {
    background-color: #3B82F6 !important;
    border: none !important;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 12px;
    font-weight: 500;
    color: white;
}

.rbc-event:hover {
    background-color: #2563eb !important;
}

.rbc-event-content {
    color: white;
    font-weight: 500;
}

.rbc-time-view .rbc-header {
    border-bottom: 1px solid #dee2e6;
}

.rbc-time-view .rbc-time-gutter {
    background: #f8f9fa;
}

/* All day label styling */
.rbc-time-header-gutter {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #495057 !important;
    /* background: #f8f9fa !important; */
}

/* Agenda Calendar Event with Floating Buttons */
.agenda-calendar-event {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
}

/* Done task background color - apply to rbc-event parent */
.rbc-event:has(.agenda-calendar-event.done) {
    background-color: #5DD155 !important;
    border-color: #5DD155 !important;
}

.agenda-event-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda_floating_icons {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 10;
}

/* Show buttons on hover */
.agenda-calendar-event:hover .agenda_floating_icons {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.agenda_icon_btn {
    width: 23px;
    height: 23px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #495057;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.agenda_icon_btn:hover {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: #3B82F6;
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.agenda_icon_btn i {
    font-size: 14px;
    padding: 3px 0;
}

/* Mobile tap support */
@media (max-width: 768px) {
    .agenda_floating_icons {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
    
    .agenda-calendar-event:hover .agenda_floating_icons,
    .agenda-calendar-event.mobile-tap .agenda_floating_icons {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
    
    .agenda_icon_btn {
        width: 20px;
        height: 20px;
        background: rgba(255, 255, 255, 0.65);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    
    .agenda_icon_btn i {
        font-size: 13px;
        padding: 3px 0;
    }
}

/* Ensure event takes full height in all-day row */
.rbc-addons-dnd-resizable {
    height: 100%;
}

.rbc-event {
    overflow: visible !important;
}

.rbc-event-content {
    overflow: visible !important;
}

/* Agenda Dropdown Menu Styles */
.agenda_dropdown_menu {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(221, 221, 221, 0.5);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    padding: 6px;
    font-size: 14px;
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.agenda_dropdown_item {
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: #495057;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agenda_dropdown_item:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3B82F6;
}

.agenda_dropdown_item:not(:last-child) {
    margin-bottom: 2px;
}

.agenda_dropdown_item_with_submenu {
    position: relative;
}

.agenda_dropdown_item_with_submenu i {
    font-size: 11px;
    opacity: 0.6;
    margin-left: 8px;
}

.agenda_dropdown_item_with_submenu:hover i {
    opacity: 1;
}

/* Agenda Submenu (Move to...) */
.agenda_submenu {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid rgba(221, 221, 221, 0.6);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    min-width: 160px;
    padding: 6px;
    font-size: 14px;
    animation: fadeInRight 0.2s ease-out;
    /* Add invisible padding to create hover bridge */
    margin-left: -10px;
    padding-left: 16px;
    /* Max height with scroll for very small screens */
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Compensate for the extra padding on first item */
.agenda_submenu .agenda_submenu_item:first-child {
    margin-top: 0;
}

/* Custom scrollbar for submenu */
.agenda_submenu::-webkit-scrollbar {
    width: 6px;
}

.agenda_submenu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.agenda_submenu::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 3px;
}

.agenda_submenu::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.5);
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.agenda_submenu_item {
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: #495057;
    font-weight: 500;
}

.agenda_submenu_item:hover {
    background: rgba(59, 130, 246, 0.12);
    color: #3B82F6;
}

.agenda_submenu_item:not(:last-child) {
    margin-bottom: 2px;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .agenda_dropdown_menu,
    .agenda_submenu {
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
        background: rgba(255, 255, 255, 0.98);
    }
    
    .agenda_dropdown_item,
    .agenda_submenu_item {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    /* Ensure submenu fits on mobile screens */
    .agenda_submenu {
        max-width: calc(100vw - 40px);
        min-width: 160px;
        margin-left: 0;
        padding-left: 6px;
    }
    
    .agenda_submenu_item {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.rbc-time-view .rbc-time-content {
    border-left: 1px solid #dee2e6;
}

.rbc-time-view .rbc-timeslot-group {
    border-bottom: 1px solid #e9ecef;
}

.rbc-time-view .rbc-time-slot {
    border-top: 1px solid #f1f3f4;
}

.rbc-toolbar {
    background: #f8f9fa;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.rbc-toolbar button {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rbc-toolbar button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.rbc-toolbar button.rbc-active {
    background: #3B82F6;
    color: white;
    border-color: #3B82F6;
}

.rbc-toolbar-label {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.rbc-month-view .rbc-date-cell {
    padding: 8px;
}

.rbc-month-view .rbc-off-range-bg {
    background: #f8f9fa;
}

.rbc-month-view .rbc-today {
    background-color: #e3f2fd;
}

.rbc-month-view .rbc-today .rbc-date-cell {
    background-color: #3B82F6;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

/* Agenda view specific styles */
.rbc-agenda-view table {
    width: 100%;
    border-collapse: collapse;
}

.rbc-agenda-view .rbc-agenda-date-cell {
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 12px;
    font-weight: 600;
    color: #495057;
    width: 120px;
}

.rbc-agenda-view .rbc-agenda-time-cell {
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 12px;
    font-weight: 500;
    color: #6c757d;
    width: 100px;
}

.rbc-agenda-view .rbc-agenda-event-cell {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
}

.rbc-agenda-view .rbc-agenda-event-cell:hover {
    background: #f8f9fa;
}

/* Responsive design */
@media (max-width: 768px) {
    .agenda-view-container {
        padding: 0;
    }
    
    .rbc-toolbar {
        flex-direction: column;
        gap: 8px;
    }
    
    .rbc-toolbar-label {
        font-size: 16px;
    }
    
    .rbc-toolbar button {
        padding: 8px 12px;
        font-size: 12px;
    }
}