/* Course Schedule Styles */

/* 1. GLOBAL VARIABLES (Applied to Body so they inherit Theme colors) */
body {
    /* --- CORE PALETTE MAPPING --- */
    /* By attaching to body, we ensure these update when the theme updates body variables */
    --sched-bg-page: var(--main-bg-color, #ffffff);
    --sched-text-main: var(--main-text-color, #24292f);
    --sched-text-muted: var(--main-blockquote-text-color, #57606a);
    
    /* Borders */
    --sched-border-light: var(--main-header-border-bottom-color, #d0d7de);
    --sched-border-week: var(--sidebar-toc-h1-border-color, #8c959f); 
    --sched-border-day: var(--code-block-border-color, #d0d7de); 
    
    /* Today Highlight Colors */
    --sched-today-accent: #0969da; 
    --sched-today-bg: rgba(9, 105, 218, 0.05); 
    
    /* --- SEMANTIC COLORS (LIGHT MODE DEFAULTS) --- */
    --sched-bg-lecture: #ddf4ff; 
    --sched-border-lecture: #54aeff;
    
    --sched-bg-lab: #dafbe1;        
    --sched-bg-lab-cell: #bbf7d0;   
    --sched-border-lab: #4ac26b;
    
    --sched-bg-due: #ffebe9;
    --sched-border-due: #ff8182;
    
    --sched-bg-exam: #fff8c5;
    --sched-border-exam: #d4a72c;
    
    --sched-bg-event: var(--tt-bg-color, #f6f8fa);
    --sched-border-event: var(--main-header-border-bottom-color, #d0d7de);
}

/* 2. DARK MODE OVERRIDES (Global) */
/* We target body when it is in a dark context */
html[data-theme-mode="dark"] body,
html[data-color-mode="dark"] body,
body[data-theme-mode="dark"],
body[data-color-mode="dark"],
body.dark-mode {
    --sched-border-week: #6e7681; 
    --sched-border-day: #30363d;   
    --sched-border-light: #30363d; 
    
    --sched-today-accent: #58a6ff;
    --sched-today-bg: rgba(56, 139, 253, 0.1);
    
    --sched-bg-lecture: rgba(56, 139, 253, 0.15); 
    --sched-border-lecture: rgba(56, 139, 253, 0.4);
    
    --sched-bg-lab: rgba(46, 160, 67, 0.15);
    --sched-bg-lab-cell: rgba(46, 160, 67, 0.25);
    --sched-border-lab: rgba(55, 198, 78, 0.4);
    
    --sched-bg-due: rgba(248, 81, 73, 0.15);
    --sched-border-due: rgba(248, 81, 73, 0.4);
    
    --sched-bg-exam: rgba(187, 128, 9, 0.15);
    --sched-border-exam: rgba(187, 128, 9, 0.4);
    
    --sched-bg-event: rgba(110, 118, 129, 0.1);
    --sched-border-event: rgba(110, 118, 129, 0.4);
}

/* --- CONTAINER STYLES --- */
.schedule-container,
.announcement-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--sched-text-main);
    background: var(--sched-bg-page);
    line-height: 1.4;
    font-size: 15px; 
    
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12); 
    border: 1px solid var(--sched-border-light);
    overflow: visible; 
    margin-bottom: 2rem; 
}

.announcement-container {
    /* 1. Define the width behavior */
    width: 100%;             /* Fills the available space on small screens */
    max-width: 1200px;       /* Stops expanding once it hits 1200px */
    
    /* 2. Safety for padding/borders */
    box-sizing: border-box;  /* Prevents padding from causing horizontal scrollbars */

    /* 3. Left Alignment */
    margin-left: 0;          /* Aligns box to the left */
    margin-right: auto;      /* Allows the right side to remain empty */

    /* 4. Text Handling */
    white-space: normal;     /* Ensures text wraps */
    overflow-wrap: break-word; /* Prevents long words/URLs from breaking the layout */

    /* Optional: Add mobile 'gutters' so text doesn't touch the screen edge */
    /* padding: 0 15px; */ 
}

/* FORCE LAB TAGS TO WRAP IN ANNOUNCEMENTS */
.announcement-container .tag.type-lab,
a.tag.type-lab[style*="block"] { 
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    height: auto !important;
}

/* --- STICKY HEADER GROUP --- */
.sticky-header-group {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--sched-bg-page);
    border-bottom: 2px solid var(--sched-border-week);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* --- UI: CONTROL BAR --- */
.schedule-controls {
    padding: 1rem;
    border-bottom: 1px solid var(--sched-border-light);
    display: flex;
    justify-content: flex-end; 
    align-items: center;
    gap: 1rem;
}

.control-actions { display: flex; gap: 0.5rem; }

.search-wrapper { position: relative; }

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sched-text-muted);
    font-size: 0.85rem;
}

#schedule-search {
    width: 300px; 
    padding: 0.4rem 0.5rem 0.4rem 2rem;
    border: 1px solid var(--sched-border-light);
    border-radius: 6px;
    background-color: var(--sched-bg-page);
    color: var(--sched-text-main);
    font-size: 0.9rem;
}

.jump-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--sched-border-light);
    border-radius: 6px;
    background-color: var(--sched-bg-page);
    color: var(--sched-text-main);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.jump-btn:hover { background-color: var(--sched-bg-event); }

/* Disabled state for Jump Button */
.jump-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- SEARCH HIGHLIGHTS --- */
.tag.dimmed { opacity: 0.2; }
.tag.highlight-match { box-shadow: 0 0 0 2px var(--sched-today-accent); }

/* --- GRID LAYOUT DEFINITION --- */
.week-block { display: flex; border-bottom: 2px solid var(--sched-border-week); }
.week-block:last-child { border-bottom: none; }

.week-block.is-past-week {
    opacity: 0.6;
    filter: grayscale(100%);
    background-color: rgba(0,0,0,0.02);
}

.week-sidebar { width: 70px; flex-shrink: 0; background-color: rgba(127, 127, 127, 0.05); padding: 0.5rem; text-align: center; border-right: 1px solid var(--sched-border-day); display: flex; flex-direction: column; justify-content: center; }
.week-label { font-size: 0.85rem; text-transform: uppercase; color: var(--sched-text-muted); font-weight: bold;}
.week-num { font-size: 1.75rem; font-weight: 800; color: var(--sched-text-main); }
.week-content { flex-grow: 1; display: flex; flex-direction: column; }

/* THE HEADER ROW FOR COLUMNS */
.column-headers {
    display: grid;
    gap: 0.5rem; 
    padding: 0.75rem 0.5rem 0.75rem 70px; 
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sched-text-muted);
    font-weight: 700;
}
.column-headers > div { padding: 0.5rem; }

/* THE ROW FOR EACH DAY */
.date-row {
    display: grid;
    gap: 0.5rem; 
    padding: 0; 
    border-bottom: 1px solid var(--sched-border-day); 
    align-items: stretch; 
    min-height: 50px; 
    position: relative;
}
.date-row:last-child { border-bottom: none; }

/* --- TODAY HIGHLIGHT --- */
.date-row.is-today {
    background-color: var(--sched-today-bg);
}
.date-row.is-today::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--sched-today-accent);
}

/* --- COLUMN STYLES --- */
.col-date, .col-content { display: flex; flex-direction: column; justify-content: center; padding: 0.5rem; box-sizing: border-box; }
.date-dayname { font-size: 0.85rem; text-transform: uppercase; font-weight: 700; color: var(--sched-text-muted); }
.date-val { font-weight: 700; color: var(--sched-text-main); font-size: 1.1rem; }
.col-content { gap: 0.35rem; font-size: 1rem; min-height: 50px; border-radius: 4px; }
.col-lab.cell-shaded { background-color: var(--sched-bg-lab-cell); }
.col-content:empty { display: flex; } 
.col-lab.cell-shaded:empty { display: flex; }

/* --- TAG STYLES --- */
.tag {
    padding: 0.35rem 0.75rem; 
    border-radius: 6px;
    background: var(--sched-bg-page); 
    border: 1px solid var(--sched-border-light);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    color: var(--sched-text-main);
    transition: all 0.15s ease;
}
.card-icon { margin-right: 4px; opacity: 0.7; font-size: 0.9em; }
a.tag { text-decoration: none; color: var(--sched-text-main); }
a.tag::after { 
    content: " ↗"; 
    font-size: 0.85em; 
    opacity: 0.5; 
    display: inline-block; 
    margin-left: 4px; 
    font-weight: normal;
}
a.tag:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.15); border-color: var(--sched-text-muted); cursor: pointer; }

/* Specific Column Styling & Widget Styling (Shared) */

/* 1. LECTURE Style */
.col-lecture .tag,
.tag.type-lecture { 
    background: var(--sched-bg-lecture); 
    /* Thick left line style */
    border-left: 4px solid var(--sched-border-lecture);
    border-top: 1px solid var(--sched-border-lecture);
    border-right: 1px solid var(--sched-border-lecture);
    border-bottom: 1px solid var(--sched-border-lecture);
    
    font-style: normal;
    color: var(--sched-text-main);
    width: 100%;
    box-sizing: border-box;
}

/* 2. LAB Style */
.col-lab .tag,
.tag.type-lab { 
    background: var(--sched-bg-lab); 
    
    /* --- THE FIX START --- */
    /* Changed from "border: 2px..." to specific sides to match Lecture/Due styles */
    border-left: 4px solid var(--sched-border-lab); 
    border-top: 1px solid var(--sched-border-lab);
    border-right: 1px solid var(--sched-border-lab);
    border-bottom: 1px solid var(--sched-border-lab);
    /* --- THE FIX END --- */
    
    width: 100%; 
    box-sizing: border-box; 
    text-align: left; 
    
    /* Layout: Labs in calendar are usually single-line. */
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    color: var(--sched-text-main);
}

/* 3. DUE DATE Style */
.col-due .tag,
.tag.type-due { 
    background: var(--sched-bg-due); 
    /* Thick left line style */
    border-left: 4px solid var(--sched-border-due); 
    border-top: 1px solid var(--sched-border-due);
    border-right: 1px solid var(--sched-border-due);
    border-bottom: 1px solid var(--sched-border-due);
    
    width: 100%; 
    box-sizing: border-box;
    color: var(--sched-text-main);
    display: block;
}

/* 4. EVENT Style */
.col-event .tag,
.tag.type-event { 
    background: var(--sched-bg-event); 
    border: 1px solid var(--sched-border-event);
    
    /* Removed font-style: italic */
    font-style: normal; 
    /* Changed from muted text to main text */
    color: var(--sched-text-main); 
    
    width: 100%;
    box-sizing: border-box;
    display: block;
}

/* 5. EXAM Style */
.tag-exam, 
.tag.type-exam { 
    background: var(--sched-bg-exam) !important; 
    border: 2px solid var(--sched-border-exam) !important; 
    font-weight: 800 !important; 
    text-align: left; 
    color: var(--sched-text-main) !important; 
    display: block;
}

.tag-holiday { 
    background: transparent !important; 
    border: none !important; 
    box-shadow: none !important; 
    color: var(--sched-text-muted) !important; 
    font-style: italic; 
    opacity: 0.8; 
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 1024px) {
    .schedule-container { border-radius: 0; box-shadow: none; border: none; }
    .column-headers { display: none; }
    .sticky-header-group { position: static; border: none; box-shadow: none; }
    .schedule-controls { justify-content: space-between; }
    
    #schedule-search { width: 100%; } /* Adjust search width on mobile */

    .date-row {
        display: grid;
        grid-template-columns: 60px 1fr !important; 
        gap: 0.25rem; 
        padding: 0.5rem 0.75rem; 
        height: auto;
        border-bottom: 1px solid var(--sched-border-light);
    }
    .date-row.is-today::before { width: 4px; }
    .col-date { grid-column: 1; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 0; margin: 0; padding: 0; padding-top: 0.25rem; border: none; width: auto; height: auto; }
    .col-content, .col-lab { grid-column: 2; width: 100%; padding: 0; min-height: auto; }
    .col-content:empty { display: none; } 
    .col-lab.cell-shaded:empty { display: block; padding: 0.25rem; border-radius: 6px; min-height: 15px; }
    .col-lab.cell-shaded { display: block; padding: 0.25rem; border-radius: 6px; }
    .col-lab .tag { white-space: normal; }
}

/* --- PRINT STYLES --- */
@media print {
    .schedule-container { border: none; box-shadow: none; margin: 0; width: 100%; }
    .schedule-controls { display: none; } 
    .week-sidebar, .column-headers { background-color: #f0f0f0 !important; color: black !important; }
    .tag { border: 1px solid #ccc !important; box-shadow: none !important; color: black !important; page-break-inside: avoid; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* --- WIDGET STYLES --- */
.deadlines-list { display: flex; flex-direction: column; }
.deadline-row { display: grid; grid-template-columns: 120px 1fr; padding: 0.75rem 1rem; border-bottom: 1px solid var(--sched-border-light); align-items: center; }
.deadline-row:last-child { border-bottom: none; }
.deadline-date { font-weight: 600; color: var(--sched-text-muted); font-size: 0.9rem; }
.status-widget-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.status-box { background: var(--sched-bg-page); border: 1px solid var(--sched-border-light); border-radius: 12px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.status-box h4 { margin-top: 0; margin-bottom: 1rem; font-size: 1rem; color: var(--sched-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.status-placeholder { font-style: italic; color: var(--sched-text-muted); font-size: 0.9rem; }
@media (max-width: 768px) { .status-widget-grid { grid-template-columns: 1fr; } }

/* --- ANNOUNCEMENT SPECIFIC STYLES --- */

/* Structure for the list */
.announcement-list {
    display: flex;
    flex-direction: column;
}

.announcement-item {
    padding: 1.25rem;
    border-bottom: 1px solid var(--sched-border-light);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: background-color 0.2s ease;
}

.announcement-item:last-child {
    border-bottom: none;
}

.announcement-item:hover {
    background-color: var(--sched-bg-event); /* Subtle hover effect */
}

/* Header: Title + Date + Tag alignment */
.ann-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.ann-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ann-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--sched-text-main);
}

.ann-date {
    font-size: 0.85rem;
    color: var(--sched-text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Content Body */
.ann-body {
    color: var(--sched-text-main);
    font-size: 0.95rem;
    line-height: 1.5;
}

.ann-body p { margin: 0; } /* Reset defaults */

/* Mobile adjustment for announcements */
@media (max-width: 600px) {
    .ann-header {
        flex-direction: column-reverse; /* Put tags above title on mobile */
        gap: 0.5rem;
    }
}

/* ==========================================================================
   WIDGET LAYOUT ADJUSTMENTS
   ========================================================================== */
/* Add spacing between cards in the widget sidebar */
.status-box .status-item-project,
.status-box .status-item-lab {
    margin-bottom: 8px;
}

/* Ensure Lab text in the widget wraps (doesn't get cut off with ...) 
   Overrides the 'white-space: nowrap' from the shared Calendar style */
.status-box .tag.type-lab {
    white-space: normal;
    height: auto;
}

/* ==========================================================================
   "VIEW SCHEDULE" LINK CARD STYLE
   ========================================================================== */
/* Big Button Style */
.schedule-big-link {
    display: block;
    text-align: center; /* Keeps the text inside the box centered */
    padding: 1.25rem !important;
    
    /* 1. Limit width so it doesn't get wider than your schedule */
    max-width: 1200px; 
    
    /* 2. ALIGNMENT: 
       0 top, 0 right, 2rem bottom, 0 left. 
       Removing 'auto' from the left stops it from centering. */
    margin: 0 0 2rem 0; 
    
    /* Visuals (Optional - keeps it looking like a card) */
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    background: var(--sched-bg-page);
    color: var(--sched-text-main);
    border: 1px solid var(--sched-border-light);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
