/**
 * TaskFlow - Improved Styles
 * IMPROVEMENTS:
 * - Fixed delete button visibility
 * - Google Calendar-inspired desktop calendar with dots/indicators
 * - Cleaner, less crowded desktop view
 * - Mobile-friendly swipe gestures
 * - Overdue task styling
 */

/* Import base styles */
@import url('../css/styles.css');

/* ===================================
   DELETE BUTTON FIX
   =================================== */

#deleteTaskBtn {
    margin-right: auto !important;
    /* When the button is meant to be shown, ensure it's fully visible */
    opacity: 1 !important;
    visibility: visible !important;
}

/* Only hide when explicitly set to display: none */
#deleteTaskBtn[style*="display: none"] {
    display: none !important;
}

/* Ensure button is visible on all devices when shown */
#deleteTaskBtn:not([style*="display: none"]) {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
}

/* ===================================
   DAY NAVIGATION (Today View)
   =================================== */

.day-navigation {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.day-nav-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    justify-content: center;
}

.day-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #DADCE0;
    background: white;
    color: #5F6368;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.day-nav-btn:hover:not(:disabled) {
    background: #F8F9FA;
    border-color: #4caf50;
    color: #4caf50;
}

.day-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.day-nav-date {
    min-width: 200px;
    text-align: center;
}

.day-nav-date span {
    font-size: 18px;
    font-weight: 600;
    color: #3C4043;
}

.back-to-today-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.back-to-today-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.4);
}

.back-to-today-btn i {
    font-size: 14px;
}

@media (max-width: 768px) {
    .day-navigation {
        padding: 12px;
    }
    
    .day-nav-controls {
        gap: 12px;
    }
    
    .day-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .day-nav-date {
        min-width: 150px;
    }
    
    .day-nav-date span {
        font-size: 16px;
    }
    
    .back-to-today-btn {
        font-size: 13px;
        padding: 8px 16px;
    }
}

/* ===================================
   OVERDUE TASK STYLING
   =================================== */

.task-item.overdue {
    background: #ffebee !important;
    border-left: 4px solid #f44336;
}

.task-item.overdue:hover {
    background: #ffcdd2 !important;
}

.overdue-label {
    display: inline-block;
    background: #f44336;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Today's tasks - light green styling */
.task-item.today {
    background: #e8f5e9 !important;
    border-left: 4px solid #4caf50;
}

.task-item.today:hover {
    background: #c8e6c9 !important;
}

.today-label {
    display: inline-block;
    background: #4caf50;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Project tasks - light blue styling */
.task-item.project {
    background: #e3f2fd !important;
    border-left: 4px solid #2196f3;
}

.task-item.project:hover {
    background: #bbdefb !important;
}

.project-label {
    display: inline-block;
    background: #2196f3;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===================================
   IMPROVED CALENDAR - GOOGLE STYLE
   =================================== */

/* Desktop calendar improvements */
@media (min-width: 769px) {
    .calendar {
        background: white;
        border-radius: 12px;
        padding: 24px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }
    
    .calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 0;
        border: 1px solid #DADCE0;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .calendar-day-cell {
        min-height: 120px;
        max-height: 120px;
        border-right: 1px solid #DADCE0;
        border-bottom: 1px solid #DADCE0;
        padding: 8px;
        cursor: pointer;
        transition: all 0.15s ease;
        background: white;
        display: flex;
        flex-direction: column;
        position: relative;
        overflow: hidden;
    }
    
    .calendar-day-cell:nth-child(7n) {
        border-right: none;
    }
    
    .calendar-day-cell:hover {
        background: #F8F9FA;
        box-shadow: inset 0 0 0 1px #4A90E2;
    }
    
    .calendar-day-cell.other-month {
        background: #FAFAFA;
        opacity: 0.6;
    }
    
    .calendar-day-cell.weekend:not(.other-month) {
        background: #F8F9FA;
    }
    
    .calendar-day-cell.today {
        background: #E8F4FD !important;
    }
    
    .calendar-day-cell.today .day-number {
        background: #1A73E8;
        color: white;
        border-radius: 50%;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
    }
    
    .day-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
        gap: 4px;
    }
    
    .day-number {
        font-size: 13px;
        font-weight: 500;
        color: #3C4043;
        line-height: 1;
    }
    
    /* IMPROVED: Task count badges (Google Calendar style) */
    .task-count-badge {
        font-size: 10px;
        font-weight: 600;
        padding: 2px 6px;
        border-radius: 10px;
        line-height: 1;
        white-space: nowrap;
    }
    
    .task-count-badge.active {
        background: #1A73E8;
        color: white;
    }
    
    .task-count-badge.completed {
        background: #5F6368;
        color: white;
        margin-left: 2px;
    }
    
    /* IMPROVED: Task indicators (dots) instead of full titles on desktop */
    .day-tasks-indicators {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-top: 6px;
    }
    
    .task-indicator {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        cursor: pointer;
        transition: transform 0.15s ease;
        flex-shrink: 0;
    }
    
    .task-indicator:hover {
        transform: scale(1.5);
    }
    
    .task-indicator.default,
    .task-indicator.none {
        background: #1A73E8;
    }
    
    .task-indicator.low {
        background: #34A853;
    }
    
    .task-indicator.medium {
        background: #FBBC04;
    }
    
    .task-indicator.high {
        background: #EA4335;
    }
    
    .task-indicator.completed {
        background: #9AA0A6;
        opacity: 0.7;
    }
    
    .more-indicator {
        font-size: 10px;
        color: #5F6368;
        font-weight: 500;
        cursor: pointer;
        padding: 2px 4px;
        border-radius: 4px;
        transition: background 0.15s ease;
    }
    
    .more-indicator:hover {
        background: #E8EAED;
    }
}

/* ===================================
   MOBILE CALENDAR (KEEP CLEAN)
   =================================== */

@media (max-width: 768px) {
    .calendar {
        padding: 12px;
        border-radius: 8px;
        /* Enable touch-action for swipe */
        touch-action: pan-y;
    }
    
    .calendar-day-cell {
        min-height: 50px !important;
        max-height: 50px;
        padding: 4px !important;
        cursor: pointer;
    }
    
    .calendar-day-cell .day-header {
        flex-direction: column;
        align-items: center;
        gap: 2px;
        justify-content: center;
    }
    
    .calendar-day-cell .day-number {
        font-size: 14px;
        font-weight: 500;
    }
    
    /* Hide task indicators on mobile - just show dot */
    .day-tasks-indicators {
        display: none !important;
    }
    
    .task-count-badge {
        display: none !important;
    }
    
    /* Simple dot indicator on mobile for days with tasks */
    .calendar-day-cell.has-tasks:not(.other-month)::after {
        content: '';
        width: 6px;
        height: 6px;
        background: #1A73E8;
        border-radius: 50%;
        position: absolute;
        bottom: 6px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .calendar-day-cell.today.has-tasks::after {
        background: white;
    }
}

/* ===================================
   DAY DETAIL MODAL
   =================================== */

#dayDetailModal .modal-content {
    max-width: 500px;
}

.no-tasks-message {
    text-align: center;
    padding: 40px 20px;
    color: #5F6368;
    font-size: 14px;
}

.day-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.day-task-item {
    background: white;
    border: 1px solid #DADCE0;
    border-left: 4px solid #1A73E8;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.day-task-item:hover {
    background: #F8F9FA;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.day-task-item.completed {
    opacity: 0.6;
    text-decoration: line-through;
}

.day-task-item.priority-low {
    border-left-color: #34A853;
}

.day-task-item.priority-medium {
    border-left-color: #FBBC04;
}

.day-task-item.priority-high {
    border-left-color: #EA4335;
}

.day-task-item .task-time {
    font-size: 12px;
    font-weight: 600;
    color: #5F6368;
    min-width: 60px;
}

.day-task-item .task-title {
    flex: 1;
    font-size: 14px;
    color: #3C4043;
}

.day-task-item i {
    color: #5F6368;
    font-size: 12px;
}

/* ===================================
   WEEK VIEW IMPROVEMENTS
   =================================== */

.calendar-week-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.week-day {
    background: white;
    border: 1px solid #DADCE0;
    border-radius: 8px;
    padding: 12px;
    min-height: 200px;
}

.week-day.today {
    background: #E8F4FD;
    border-color: #1A73E8;
}

.week-day-header {
    border-bottom: 2px solid #F1F3F4;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.week-day-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: #3C4043;
    margin: 0 0 4px 0;
}

.week-day-date {
    font-size: 24px;
    font-weight: 300;
    color: #5F6368;
}

.week-day-tasks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.week-task-item {
    background: white;
    border: 1px solid #DADCE0;
    border-left: 3px solid #1A73E8;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s ease;
}

.week-task-item:hover {
    background: #F8F9FA;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.week-task-item.completed {
    opacity: 0.6;
    text-decoration: line-through;
}

.week-task-item.priority-low {
    border-left-color: #34A853;
}

.week-task-item.priority-medium {
    border-left-color: #FBBC04;
}

.week-task-item.priority-high {
    border-left-color: #EA4335;
}

.week-task-item .task-time {
    font-size: 11px;
    font-weight: 600;
    color: #5F6368;
    margin-right: 6px;
}

.no-tasks {
    text-align: center;
    padding: 20px;
    color: #9AA0A6;
    font-size: 13px;
}

/* ===================================
   CALENDAR CONTROLS
   =================================== */

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-nav button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #5F6368;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-nav button:hover:not(:disabled) {
    background: #F8F9FA;
    color: #3C4043;
}

.calendar-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.calendar-nav h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 400;
    min-width: 200px;
    text-align: center;
    color: #3C4043;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid #DADCE0;
    background: #FAFAFA;
    border-radius: 8px 8px 0 0;
}

.calendar-weekday-name {
    padding: 12px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: #5F6368;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===================================
   FIX: ENSURE TASKS DON'T APPEAR UNDER CALENDAR
   =================================== */

#taskListContainer_inner[style*="display: none"] {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
}

#calendarContainer[style*="display: block"] ~ #taskListContainer_inner {
    display: none !important;
}

/* ===================================
   RESPONSIVE IMPROVEMENTS
   =================================== */

@media (max-width: 768px) {
    .calendar-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .calendar-nav h3 {
        font-size: 18px;
        min-width: 150px;
    }
    
    .calendar-nav button {
        width: 32px;
        height: 32px;
    }
    
    .calendar-weekday-name {
        font-size: 10px;
        padding: 8px 4px;
    }
    
    .calendar-week-view {
        grid-template-columns: 1fr;
    }
}

/* ===================================
   SMOOTH TRANSITIONS FOR SWIPE
   =================================== */

.calendar {
    transition: transform 0.3s ease-out;
}

.calendar.swiping {
    transition: none;
}

/* ===================================
   ADDITIONAL UI POLISH
   =================================== */

.view-btn {
    padding: 8px 16px;
    border: 1px solid #DADCE0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: #5F6368;
}

.view-btn:hover {
    background: #F8F9FA;
    border-color: #1A73E8;
    color: #1A73E8;
}

.view-btn.active {
    background: #1A73E8;
    color: white;
    border-color: #1A73E8;
}

.view-btn i {
    font-size: 14px;
}

/* ===================================
   PAST DAY STYLING
   =================================== */

.calendar-day-cell.past-day:not(.today) {
    opacity: 0.7;
}

.calendar-day-cell.past-day:not(.today) .day-number {
    color: #9AA0A6;
}

/* ===================================
   CATEGORY FILTER STYLES
   =================================== */

.category-filter-wrapper {
    position: relative;
    margin-left: 15px;
}

.category-filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid #DADCE0;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #5F6368;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-filter-btn:hover {
    background: #F8F9FA;
    border-color: #1A73E8;
    color: #1A73E8;
}

.category-filter-btn i:first-child {
    font-size: 12px;
}

.category-filter-btn i:last-child {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.category-filter-dropdown.active + .category-filter-btn i:last-child {
    transform: rotate(180deg);
}

#categoryFilterLabel {
    font-weight: 500;
}

.category-filter-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    border: 1px solid #DADCE0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 250px;
    max-width: 300px;
    z-index: 1000;
    display: none;
}

.category-filter-dropdown.active {
    display: block;
}

.category-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #E0E0E0;
    font-weight: 600;
    font-size: 14px;
    color: #3C4043;
}

.clear-filter-btn {
    background: none;
    border: none;
    color: #1A73E8;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.clear-filter-btn:hover {
    background: #E8F0FE;
}

.category-filter-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}

.category-filter-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.category-filter-item:hover {
    background: #F8F9FA;
}

.category-filter-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.category-filter-item input[type="checkbox"] {
    margin: 0;
    margin-right: 10px;
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #1A73E8;
}

.category-filter-item span {
    font-size: 14px;
    color: #3C4043;
}

.category-filter-separator {
    height: 1px;
    background: #E0E0E0;
    margin: 4px 16px;
}

/* Smooth transitions for filter changes */
#taskListContainer_inner {
    transition: opacity 0.3s ease;
}

#taskListContainer_inner.filtering {
    opacity: 0.7;
}

/* Mobile adjustments for category filter */
@media (max-width: 768px) {
    .category-filter-wrapper {
        margin-left: 8px;
    }
    
    .category-filter-btn {
        padding: 5px 10px;
        font-size: 13px;
    }
    
    #categoryFilterLabel {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .category-filter-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 12px 12px 0 0;
        max-width: 100%;
        max-height: 70vh;
    }
    
    .category-filter-list {
        max-height: calc(70vh - 100px);
    }
}

/* Hide filter icon text on very small screens */
@media (max-width: 480px) {
    .category-filter-btn i:first-child {
        display: none;
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    .calendar-controls,
    .modal,
    .sidebar,
    .top-nav {
        display: none !important;
    }
    
    .calendar {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .calendar-day-cell {
        page-break-inside: avoid;
    }
}

/* ===================================
   SCREEN TITLE WITH DATE
   =================================== */

.screen-title-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1.2;
}

.screen-title-wrapper h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.screen-date {
    font-size: 0.75rem;
    color: #5F6368;
    font-weight: 400;
    margin-top: 2px;
}

/* Mobile optimization */
@media (max-width: 768px) {
    .screen-title-wrapper h2 {
        font-size: 1.25rem;
    }
    
    .screen-date {
        font-size: 0.7rem;
    }
}