
/* Schedule Module Styles */

.schedule-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
    overflow: hidden;
}

.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.schedule-controls {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.view-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.view-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.current-date {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.schedule-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

/* Month View */
.month-view {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-color); /* Grid lines */
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.day-header {
    background: var(--bg-card);
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.calendar-day {
    background: var(--bg-card);
    min-height: 100px;
    /* Ensure fixed height/width behavior */
    height: 120px; /* Fixed height to prevent row stretching */
    overflow: hidden; /* Hide overflow events */
    
    padding: 0.25rem;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    
    /* Ensure width is respected in grid */
    min-width: 0; 
}

.calendar-day:hover {
    background: var(--bg-dark);
}

.calendar-day.today {
    background: rgba(99, 102, 241, 0.05);
}

/* Day Header Row (Number + Holiday) */
.day-header-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.holiday-label {
    font-size: 0.7rem;
    color: #ef4444; /* Red for holidays */
    font-weight: 500;
}

.day-number {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Removed duplicate .mini-day definition here to avoid conflict */

.calendar-day.today .day-number {
    color: var(--primary);
    font-weight: bold;
}

.calendar-day.other-month {
    opacity: 0.5;
    background: var(--bg-darker);
}

.calendar-day.past {
    /* Cleaner look: Just a subtle gray background, no heavy stripes */
    background: rgba(0, 0, 0, 0.02); /* Very light gray */
    color: var(--text-muted);
}

.calendar-day.past .day-number {
    opacity: 0.6;
    text-decoration: line-through; /* Keep the strikethrough as requested */
}

/* Grayscale events in past days - lighter style */
.calendar-day.past .event-chip {
    background: transparent !important;
    color: var(--text-muted) !important;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--text-muted) !important;
    box-shadow: none;
    opacity: 0.8;
}

/* Day View */
.day-view {
    display: flex;
    flex-direction: column;
    gap: 0; /* Removed gap to ensure time slots align with absolute positioning of events */
    position: relative;
    padding-bottom: 2rem; /* Add space at bottom */
}

.time-slot {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    height: 60px; /* Fixed height to match JS calculation (60px/hour) */
    box-sizing: border-box;
    position: relative;
}

.time-label {
    width: 60px;
    text-align: right;
    padding-right: 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    transform: translateY(-0.6rem);
}

.time-content {
    flex: 1;
    position: relative;
    border-left: 1px solid var(--border-color);
}

/* Event Chips */
.event-chip {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    background: var(--primary);
    color: white;
    /* Removed white-space: nowrap to allow wrapping if needed, but usually we want to truncate */
    /* User request: "too ugly, need line break, long text use ellipsis instead of changing table proportion" */
    
    /* Fixed width behavior */
    width: 100%; 
    max-width: 100%;
    
    /* Text truncation */
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
    
    cursor: pointer;
    margin-bottom: 2px;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
    
    /* Add subtle shadow for better look */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.event-chip.ai-generated {
    background: var(--accent); /* Different color for AI */
    border-left-color: rgba(255, 255, 255, 0.5);
}

.event-chip:hover {
    filter: brightness(1.1);
}

/* Day View Event Positioning */
.day-event {
    position: absolute;
    left: 5px;
    right: 5px;
    background: rgba(99, 102, 241, 0.2);
    border-left: 3px solid var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    overflow: hidden;
    cursor: pointer;
    z-index: 10;
}

.day-event.ai-generated {
    background: rgba(16, 185, 129, 0.2);
    border-left-color: var(--accent);
}

.day-event-title {
    font-weight: 600;
    color: var(--text-primary);
}

.day-event-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Event Details Modal */
.event-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.detail-icon {
    width: 20px;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.detail-content {
    flex: 1;
    color: var(--text-primary);
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 0.1rem 0.4rem;
    border-radius: 1rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Year View */
.year-view {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding-bottom: 1rem;
}

.year-month-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    /* height: 100%;  <-- Removed fixed height to allow content to fit */
    min-height: 0;
}

.year-month-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.year-month-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}

.year-month-preview {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    align-content: start; /* Ensure grid rows are packed at start */
}

.mini-day {
    /* aspect-ratio: 1;  <-- Removed to prevent overflow if width is too small */
    height: 24px; /* Fixed height for better alignment */
    border-radius: 4px; /* Square with slight radius instead of circle */
    /* No text content, so we rely on background color */
    background: transparent; /* No background by default, just text */
    opacity: 1; /* Reset opacity */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.mini-day.has-events {
    background: var(--primary);
    color: white;
}

.mini-day.holiday {
    color: #ef4444; /* Red */
    font-weight: bold;
    position: relative;
}

/* Holiday dot indicator */
.mini-day.holiday::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 3px;
    height: 3px;
    background: #ef4444;
    border-radius: 50%;
}

.mini-day.has-events.holiday {
    background: var(--primary);
    color: white;
}

/* If it has events AND is holiday, maybe show holiday dot in white? */
.mini-day.has-events.holiday::after {
    background: white;
}

.mini-day.today {
    border: 1px solid var(--primary);
    color: var(--primary);
}

.mini-day.today.has-events {
    background: var(--primary);
    color: white;
    border-color: transparent;
}

.mini-day.past {
    color: var(--text-muted);
    opacity: 0.3; /* Make it very faint */
    background: transparent !important; /* Remove background even if it has events */
    text-decoration: line-through;
}

/* Ensure today is still visible even if time calculation is close */
.mini-day.today {
    opacity: 1 !important; 
    text-decoration: none !important;
}

@media (max-width: 768px) {
    .month-view {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        background: transparent;
        border: none;
    }
    
    .day-header {
        display: none;
    }
    
    .calendar-day {
        min-height: auto;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        padding: 0.75rem;
    }
    
    .calendar-day.other-month {
        display: none;
    }
    
    .calendar-day .day-number {
        text-align: left;
        margin-bottom: 0.5rem;
        font-weight: 600;
    }
    
    .event-chip {
        white-space: normal;
        padding: 0.4rem;
    }

    .year-view {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Event Colors */
.event-chip.event-color-0 { background: var(--primary); }
.event-chip.event-color-1 { background: #10b981; } /* Emerald */
.event-chip.event-color-2 { background: #f59e0b; } /* Amber */
.event-chip.event-color-3 { background: #ef4444; } /* Red */
.event-chip.event-color-4 { background: #8b5cf6; } /* Violet */
.event-chip.event-color-5 { background: #ec4899; } /* Pink */

/* Day View Event Colors */
.day-event.event-color-0 { background: rgba(99, 102, 241, 0.2); border-left-color: var(--primary); }
.day-event.event-color-1 { background: rgba(16, 185, 129, 0.2); border-left-color: #10b981; }
.day-event.event-color-2 { background: rgba(245, 158, 11, 0.2); border-left-color: #f59e0b; }
.day-event.event-color-3 { background: rgba(239, 68, 68, 0.2); border-left-color: #ef4444; }
.day-event.event-color-4 { background: rgba(139, 92, 246, 0.2); border-left-color: #8b5cf6; }
.day-event.event-color-5 { background: rgba(236, 72, 153, 0.2); border-left-color: #ec4899; }
