/* CSG Brand Variables - True School Colors */
:root {
    --csg-red: #C8102E;          /* Official CSG Crimson Red */
    --csg-gold: #FFB81C;         /* Official CSG Gold */
    --csg-light-gold: #FFF2CC;   /* Light gold background */
    --csg-gray: #6c757d;         /* Secondary gray */
    --csg-light-gray: #f8f9fa;   /* Light gray background */
    --csg-white: #ffffff;        /* Pure white */
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 15px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
    
    /* Legacy navy variable for compatibility - now points to red */
    --csg-navy: var(--csg-red);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Source Sans Pro', sans-serif;
    background: var(--csg-light-gray);
    color: var(--csg-navy);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Layout */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--csg-white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.header-text {
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.last-refresh-text {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.75rem;
    color: var(--csg-gray);
    font-weight: 400;
    white-space: nowrap;
}

.app-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--csg-navy);
    margin: 0;
    line-height: 1.2;
}

.app-subtitle {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--csg-gray);
    margin: 2px 0 0 0;
    line-height: 1.2;
}

/* Main Content */
.app-main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 16px;
}

.main-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    min-height: 400px;
}

/* Filters Sidebar */
.filters-sidebar {
    background: var(--csg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.filters-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--csg-red);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--csg-light-gold);
}

.filter-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 0;
    transition: var(--transition);
}

.filter-item:hover {
    background-color: var(--csg-light-gold);
    border-radius: 4px;
    padding: 6px 8px;
    margin: 0 -8px;
}

.filter-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--csg-red);
    cursor: pointer;
}

.filter-label {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.9rem;
    color: var(--csg-red);
    cursor: pointer;
    line-height: 1.3;
    flex: 1;
}

.filter-count {
    font-size: 0.8rem;
    color: var(--csg-gray);
    font-weight: 500;
    padding: 2px 6px;
    background-color: var(--csg-light-gray);
    border-radius: 12px;
    min-width: 18px;
    text-align: center;
}

.calendar-section {
    min-width: 0; /* Allows grid item to shrink */
}

/* Toggle Section */
.toggle-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid var(--csg-light-gold);
}

.toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.toggle-label {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.9rem;
    color: var(--csg-red);
    font-weight: 500;
    cursor: pointer;
    flex: 1;
}

/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--csg-light-gray);
    border: 1px solid var(--csg-gray);
    transition: var(--transition);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--csg-white);
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-input:checked + .toggle-slider {
    background-color: var(--csg-red);
    border-color: var(--csg-red);
}

.toggle-input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-input:focus + .toggle-slider {
    outline: 2px solid var(--csg-gold);
    outline-offset: 2px;
}

#calendar-container {
    background: var(--csg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 400px;
}

/* Button System */
.btn {
    font-family: 'Source Sans Pro', sans-serif;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    line-height: 1;
    white-space: nowrap;
}

.btn:focus {
    outline: 2px solid var(--csg-gold);
    outline-offset: 2px;
}

/* Button Sizes */
.btn-sm {
    padding: 8px 12px;
    font-size: 0.875rem;
}

.btn {
    padding: 12px 20px;
    font-size: 1rem;
}

/* Button Variants */
.btn-primary {
    background-color: var(--csg-gold);
    color: var(--csg-white);
}

.btn-primary:hover {
    background-color: var(--csg-navy);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--csg-navy);
    border: 1.5px solid var(--csg-navy);
}

.btn-secondary:hover {
    background-color: var(--csg-navy);
    color: var(--csg-white);
}

.refresh-icon {
    font-size: 1.1em;
    transition: transform 0.3s ease;
}

.btn-secondary:hover .refresh-icon {
    transform: rotate(180deg);
}

/* FullCalendar Customization */
.fc {
    font-family: 'Source Sans Pro', sans-serif;
    padding: 16px;
}

.fc .fc-toolbar {
    margin-bottom: 16px;
    gap: 8px;
}

.fc .fc-toolbar-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--csg-navy);
}

.fc .fc-button-primary {
    background-color: var(--csg-gray);
    border-color: var(--csg-gray);
    color: var(--csg-white);
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: var(--transition);
    font-size: 0.875rem;
}

.fc .fc-button-primary:hover {
    background-color: var(--csg-red);
    border-color: var(--csg-red);
    color: var(--csg-white);
}

.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary:not(:disabled).fc-button-active {
    background-color: var(--csg-red);
    border-color: var(--csg-red);
}

.fc .fc-button-primary:focus {
    box-shadow: 0 0 0 2px var(--csg-light-gold);
}

/* Calendar Header */
.fc-theme-standard th {
    background-color: var(--csg-navy);
    color: var(--csg-white);
    font-weight: 600;
    padding: 8px 4px;
    font-size: 0.875rem;
    border: none;
}

.fc-theme-standard .fc-scrollgrid {
    border-color: var(--csg-light-gray);
    border-width: 1px;
}

/* Day Cells */
.fc-daygrid-day {
    transition: background-color 0.2s ease;
    min-height: 80px;
}

.fc-daygrid-day:hover {
    background-color: var(--csg-light-gold);
}

.fc-daygrid-day-number {
    color: var(--csg-navy);
    font-weight: 600;
    padding: 6px;
    font-size: 0.875rem;
}

.fc-day-today {
    background-color: var(--csg-light-gold) !important;
}

.fc-day-today .fc-daygrid-day-number {
    background-color: var(--csg-gold);
    color: var(--csg-white);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Events */
.fc-event {
    background-color: var(--csg-red) !important;
    border-color: var(--csg-red) !important;
    color: var(--csg-white) !important;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: normal !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 16px;
    margin-bottom: 1px;
    border: 1px solid var(--csg-red) !important;
}

.fc-event:hover {
    background-color: var(--csg-gold) !important;
    border-color: var(--csg-gold) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    z-index: 10;
}

.fc-event.event-full {
    background-color: var(--csg-red) !important;
    border-color: var(--csg-red) !important;
    opacity: 0.4 !important;
    color: var(--csg-white) !important;
}

/* Custom Event Layout */
.fc-event {
    padding: 4px 6px !important;
    min-height: 32px !important;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 2px;
    line-height: 1;
}

.event-time {
    color: var(--csg-white) !important;
    flex-shrink: 0;
}

.event-slots {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 1px 4px;
    border-radius: 2px;
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--csg-white) !important;
    text-align: right;
}

.event-slots.full {
    background-color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

.event-title-wrap {
    line-height: 1.1;
}

.event-title-text {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--csg-white) !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Hide FullCalendar's default event content */
.fc-event .fc-event-main {
    display: none !important;
}

.fc-event .fc-event-title {
    display: none !important;
}

.fc-event .fc-event-main-frame {
    display: none !important;
}

.fc-event .fc-event-title-container {
    display: none !important;
}

/* Loading States */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 58, 82, 0.1);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background: var(--csg-white);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 200px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--csg-light-gray);
    border-top: 3px solid var(--csg-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

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

.loading-content p {
    font-size: 0.875rem;
    color: var(--csg-gray);
    margin: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 58, 82, 0.4);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: var(--csg-white);
    margin: 5% auto;
    padding: 24px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.close {
    color: var(--csg-gray);
    float: right;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
    margin-top: -4px;
}

.close:hover {
    color: var(--csg-navy);
}

#modalTitle {
    font-family: 'Playfair Display', serif;
    color: var(--csg-navy);
    margin-bottom: 16px;
    font-size: 1.25rem;
    line-height: 1.3;
}

#modalBody {
    color: var(--csg-navy);
    line-height: 1.6;
}

#modalBody p {
    margin-bottom: 12px;
}

.event-detail {
    margin-bottom: 12px;
    padding: 8px 12px;
    background-color: var(--csg-light-gray);
    border-left: 3px solid var(--csg-gold);
    border-radius: 4px;
}

.event-label {
    font-weight: 600;
    color: var(--csg-navy);
    margin-right: 8px;
}

.availability.available {
    color: var(--csg-gold);
    font-weight: 600;
}

.availability.full {
    color: var(--csg-gray);
    font-weight: 600;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .header-content {
        padding: 12px;
    }
    
    .app-title {
        font-size: 1.25rem;
    }
    
    .app-subtitle {
        font-size: 0.8rem;
    }
    
    .btn-text {
        display: none;
    }
    
    .app-main {
        padding: 12px;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .filters-sidebar {
        position: static;
        order: -1;
        padding: 16px;
    }
    
    .filters-header h3 {
        font-size: 1rem;
        margin-bottom: 12px;
    }
    
    .filter-list {
        gap: 8px;
    }
    
    .filter-label {
        font-size: 0.85rem;
    }
    
    .toggle-section {
        margin-top: 16px;
        padding-top: 12px;
    }
    
    .toggle-label {
        font-size: 0.85rem;
    }
    
    .fc {
        padding: 8px;
    }
    
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 12px;
    }
    
    .fc .fc-toolbar-title {
        font-size: 1.25rem;
        text-align: center;
        order: 1;
    }
    
    .fc .fc-toolbar-chunk:first-child {
        order: 2;
    }
    
    .fc .fc-toolbar-chunk:last-child {
        order: 3;
    }
    
    .fc .fc-button {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    .fc-theme-standard th {
        padding: 6px 2px;
        font-size: 0.75rem;
    }
    
    .fc-daygrid-day {
        min-height: 60px;
    }
    
    .fc-daygrid-day-number {
        font-size: 0.75rem;
        padding: 4px;
    }
    
    .fc-event {
        padding: 3px 4px !important;
        min-height: 28px !important;
    }
    
    .event-header {
        font-size: 0.6rem;
        margin-bottom: 1px;
    }
    
    .event-time {
        font-size: 0.6rem;
    }
    
    .event-slots {
        font-size: 0.55rem;
        padding: 0px 3px;
    }
    
    .event-title-text {
        font-size: 0.6rem;
        -webkit-line-clamp: 1;
    }
    
    .fc-day-today .fc-daygrid-day-number {
        width: 20px;
        height: 20px;
        font-size: 0.75rem;
    }
    
    .modal-content {
        margin: 10px;
        width: calc(100% - 20px);
        padding: 20px;
        max-height: 90vh;
    }
    
    #modalTitle {
        font-size: 1.125rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 10px;
    }
    
    .app-title {
        font-size: 1.125rem;
    }
    
    .app-subtitle {
        font-size: 0.75rem;
    }
    
    .app-main {
        padding: 8px;
    }
    
    .fc .fc-toolbar-title {
        font-size: 1.125rem;
    }
    
    .fc-daygrid-day {
        min-height: 50px;
    }
    
    .fc-event {
        padding: 2px 3px !important;
        min-height: 24px !important;
    }
    
    .event-header {
        font-size: 0.55rem;
    }
    
    .event-time, .event-slots {
        font-size: 0.5rem;
    }
    
    .event-title-text {
        font-size: 0.55rem;
    }
}

/* Week View Styling */
.fc-timeGridWeek-view .fc-timegrid-slot-minor {
    border-top-style: dotted;
    border-top-color: var(--csg-light-gray);
}

.fc-timeGridWeek-view .fc-timegrid-slot-major {
    border-top-color: var(--csg-gray);
}

.fc-timegrid-axis {
    color: var(--csg-gray);
    font-size: 0.8rem;
    font-weight: 500;
}

.fc-timegrid-slot-label {
    color: var(--csg-gray);
}

/* Day View Styling */
.fc-timeGridDay-view .fc-timegrid-slot {
    min-height: 30px;
}

.fc-timeGridDay-view .fc-daygrid-event {
    margin-bottom: 2px;
}

/* Time grid events (for week and day views) */
.fc-timegrid-event {
    border-radius: 4px !important;
    font-size: 0.8rem !important;
    padding: 2px 4px !important;
}

.fc-timegrid-event .fc-event-title {
    font-weight: 500;
    color: var(--csg-white) !important;
}

.fc-timegrid-event .fc-event-time {
    font-weight: 600;
    color: var(--csg-white) !important;
}

/* List View Styling */
.fc-list {
    background-color: var(--csg-white);
}

.fc-list-table {
    border: none;
}

.fc-list-day-cushion {
    background-color: var(--csg-red) !important;
    color: var(--csg-white) !important;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 12px 16px;
    border: none;
}

.fc-list-event {
    border-bottom: 1px solid var(--csg-light-gray);
    transition: background-color 0.2s ease;
    cursor: pointer;
    background-color: var(--csg-white) !important;
}

.fc-list-event:hover {
    background-color: var(--csg-light-gray) !important;
}

.fc-list-event-time {
    background-color: var(--csg-white) !important;
    color: var(--csg-red) !important;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 12px 16px;
    border: none;
    width: 120px;
    vertical-align: top;
}

.fc-list-event-title {
    background-color: var(--csg-white) !important;
    color: var(--csg-red) !important;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 12px 16px;
    border: none;
    line-height: 1.4;
}

.fc-list-event-dot {
    background-color: var(--csg-red) !important;
    border-color: var(--csg-red) !important;
    width: 8px;
    height: 8px;
}

/* Hide the duplicate content that FullCalendar creates */
.fc-list-event .fc-list-event-title .fc-event-title {
    display: none;
}

.fc-list-event .fc-list-event-title a {
    display: none;
}

/* Hide the red dot column */
.fc-list-event-graphic {
    display: none !important;
}

/* Override any conflicting FullCalendar styles */
.fc-theme-standard .fc-list-day-cushion,
.fc-theme-standard .fc-list-event:hover td {
    background-color: transparent;
}

/* Empty state for list view */
.fc-list-empty {
    background-color: var(--csg-light-gray);
    color: var(--csg-gray);
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}

.fc-list-empty-cushion {
    color: var(--csg-gray);
    font-size: 0.9rem;
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    .fc-event {
        border-width: 0.5px;
    }
    
    .fc-theme-standard .fc-scrollgrid {
        border-width: 0.5px;
    }
}