/* HabitWins Calendar CSS */

/* Calendar Base Styles */
.calendar-section {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Global Calendar Styles */
.global-calendar-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-top: 0;
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.calendar-header {
    text-align: center;
    margin-bottom: 15px;
}

.calendar-header h3 {
    color: #666;
    margin-bottom: 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.calendar-header p {
    color: #666;
    font-size: 0.9rem;
}

/* Calendar View Selector */
.calendar-view-selector {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 15px;
}

.view-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    min-width: 60px;
}

.view-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.view-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Month Selector */
.month-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

.month-selector h2 {
    color: #333;
    font-size: 1.5em;
}

.month-selector h4 {
    color: #333;
    text-align: center;
    line-height: 1.2;
    margin: 0 10px;
}

.month-btn,
.month-selector button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    white-space: nowrap;
}

.month-btn:hover,
.month-selector button:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

/* Calendar Grid */
.calendar,
.global-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.global-calendar {
    margin-bottom: 12px;
    background: #f8f9fa;
    padding: 6px;
    border-radius: 8px;
    gap: 1px;
}

/* Day Headers */
.day-header,
.calendar-day-header {
    text-align: center;
    font-weight: bold;
    padding: 10px;
    background: #667eea;
    color: white;
    border-radius: 5px;
}

.calendar-day-header {
    padding: 10px 5px;
    font-size: 0.85rem;
}

/* Calendar Days */
.day,
.calendar-day,
.global-calendar-day {
    aspect-ratio: 1;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    background: white;
}

.day:hover,
.calendar-day:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.calendar-day:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.global-calendar-day {
    border-radius: 6px;
    font-size: 0.8rem;
    padding: 4px;
    min-height: 40px;
    max-height: 50px;
    border: none;
}

.global-calendar-day:hover {
    background: #667eea;
    color: white;
}

/* Day States */
.day.other-month,
.calendar-day.other-month,
.global-calendar-day.other-month {
    opacity: 0.3;
    cursor: default;
}

.day.other-month:hover,
.calendar-day.other-month:hover {
    transform: none;
    box-shadow: none;
}

.day.future,
.calendar-day.future {
    background: #f5f5f5;
    cursor: default;
}

.day.future:hover,
.calendar-day.future:hover {
    transform: none;
    box-shadow: none;
}

.calendar-day.has-session {
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
    border-color: #f59e0b;
}

.global-calendar-day.today {
    background: #FF6B35;
    color: white;
    font-weight: bold;
}

/* Day Numbers and Content */
.day-number,
.calendar-day-number {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    font-size: 0.85rem;
}

.day-number {
    margin-bottom: 5px;
}

/* Stars and Stickers */
.stickers,
.calendar-day-stickers {
    display: flex;
    gap: 2px;
}

.calendar-day-stickers {
    margin-top: 2px;
}

.sticker,
.calendar-sticker {
    font-size: 20px;
}

.calendar-sticker {
    font-size: 14px;
}

.global-calendar-stars {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1px;
    font-size: 0.6rem;
}

/* Calendar Legend */
.legend,
.calendar-legend,
.global-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.calendar-legend {
    margin-bottom: 20px;
    gap: 30px;
}

.global-legend {
    gap: 16px;
    padding: 12px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
}

.legend-star {
    font-weight: bold;
}

/* Calendar Stats */
.calendar-stats {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 10px;
}

.calendar-stats .stat-item {
    text-align: center;
}

.calendar-stats .stat-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.calendar-stats .stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
}

/* Week View Styles */
.week-view {
    display: none;
    margin-bottom: 15px;
}

.week-view.active {
    display: block;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
}

.week-day {
    background: white;
    border-radius: 8px;
    padding: 8px 4px;
    text-align: center;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: relative;
}

.week-day-header {
    font-weight: bold;
    font-size: 0.75rem;
    margin-bottom: 4px;
    color: #666;
}

.week-day-number {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.week-day.today .week-day-number {
    color: #FF6B35;
}

.week-day-sessions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.week-session-item {
    font-size: 0.65rem;
    padding: 1px 3px;
    border-radius: 3px;
    background: #e3f2fd;
    color: #1976d2;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Day View Styles */
.day-view {
    display: none;
    padding: 15px;
    background: white;
    border-radius: 8px;
    margin-bottom: 15px;
}

.day-view.active {
    display: block;
}

.day-session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    font-size: 0.85rem;
}

.day-session-item .task-name {
    flex: 1;
}

.day-session-item .task-stars {
    color: #667eea;
    font-weight: bold;
    flex-shrink: 0;
    margin-left: 8px;
}

/* Mobile Calendar Responsive */
@media (max-width: 768px) {
    .global-calendar-section {
        padding: 8px; /* Ultra-compact padding for mobile */
        margin-top: 0 !important; /* ✅ FIXED: Remove margin that creates gap between tasks and calendar */
        margin-bottom: 0 !important; /* Remove any bottom margin */
    }
    
    .calendar-controls {
        padding: 12px;
    }

    .calendar-stats {
        flex-direction: column;
        gap: 10px;
    }

    .calendar-legend {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        margin-bottom: 6px; /* tighter spacing below calendar */
    }
    /* Tighten header and month selector spacing on mobile */
    .calendar-header { margin-bottom: 8px; }
    .month-selector { margin-bottom: 12px; }
    
    /* Week view responsive */
    .week-grid {
        gap: 2px;
        padding: 4px;
    }
    .day-session-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

@media (max-width: 600px) {
    
    .month-selector button {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }

    
    .calendar-sticker {
        font-size: 12px;
    }

    /* Week view ultra mobile */
    .week-grid {
        gap: 1px;
    }

    /* Further tighten legend spacing on very small screens */
    .calendar-legend {
        margin-bottom: 4px !important;
    }
    .week-session-item {
        font-size: 0.55rem;
        padding: 1px 2px;
    }
}

/* Progressive responsive design for week view */
@media (max-width: 400px) {
    .week-grid {
        padding: 3px;
        gap: 0px;
    }
}

@media (max-width: 360px) {
    .week-grid {
        padding: 2px;
    }
}