:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --light-color: #f8f9fc;
    --dark-color: #5a5c69;
    --border-color: #e3e6f0;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --highlight-bg: #fff3cd;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.week-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 4px 8px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.btn-sm {
    padding: 2px 8px;
    font-size: 0.75rem;
}

.header-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.weekend-col.hidden {
    display: none;
}

h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    background-color: var(--primary-color);
    color: white;
}

/* Timetable */
.timetable-wrapper {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.timetable {
    width: 100%;
    min-width: 800px; /* 保证手机端横向滚动 */
    border-collapse: collapse;
    table-layout: fixed;
}

.timetable th, .timetable td {
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: center;
    vertical-align: top;
    height: 100px;
}

.timetable th {
    background-color: var(--light-color);
    font-weight: 600;
    height: 50px;
    vertical-align: middle;
}

.timetable th.time-col {
    width: 100px;
}

.timetable .current-day-col {
    background-color: rgba(78, 115, 223, 0.05);
}

.timetable .current-day-header {
    background-color: var(--primary-color);
    color: white;
}

/* Course Cell */
.course-item {
    padding: 8px;
    border-radius: 4px;
    color: white;
    font-size: 0.85rem;
    margin-bottom: 5px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: left;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.course-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.course-name {
    font-weight: bold;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.course-info {
    font-size: 0.75rem;
    opacity: 0.9;
}

.course-item.active {
    outline: 3px solid var(--warning-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { outline-color: rgba(246, 194, 62, 0.4); }
    50% { outline-color: rgba(246, 194, 62, 1); }
    100% { outline-color: rgba(246, 194, 62, 0.4); }
}

/* Time Cell */
.time-slot {
    font-size: 0.8rem;
}

.time-slot .slot-name {
    font-weight: bold;
    color: var(--dark-color);
}

.time-slot .slot-time {
    color: var(--secondary-color);
}

.time-slot.active {
    background-color: var(--highlight-bg);
}

/* Footer Status */
.status-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-online { background-color: var(--success-color); }
.dot-offline { background-color: var(--danger-color); }

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--primary-color); color: white; }
.btn-success { background: var(--success-color); color: white; }
.btn-secondary { background: var(--secondary-color); color: white; }
.btn-danger { background: var(--danger-color); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: white;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

/* Search & Filters */
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
}

/* Holiday Banner */
.holiday-banner {
    background-color: var(--highlight-bg);
    color: #856404;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
    border: 1px solid #ffeeba;
}

/* Empty Cell */
.empty-cell {
    color: #ddd;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 10px; }
    
    header { 
        flex-direction: column; 
        align-items: stretch; 
        gap: 15px;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    .header-left h1 {
        font-size: 1.2rem;
        margin: 0;
    }

    .header-right { 
        width: 100%; 
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .header-right select {
        grid-column: span 2;
        width: 100% !important;
        margin: 0;
    }

    .header-right .btn {
        width: 100%;
        justify-content: center;
        padding: 8px 4px;
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .filters input[type="text"] {
        width: 100%;
    }

    .filters div {
        margin-left: 0 !important;
        justify-content: center;
        background: var(--light-color);
        padding: 8px;
        border-radius: 4px;
    }

    .timetable-wrapper {
        margin: 0 -10px; /* 负边距让表格占满屏幕宽度 */
        border-radius: 0;
    }

    .timetable {
        min-width: 600px; /* 减小最小宽度，适配折叠周末后的显示 */
    }

    .status-footer { 
        flex-direction: column; 
        gap: 8px; 
        padding: 10px;
        text-align: center;
    }

    .status-left, .status-right { 
        width: 100%; 
        justify-content: center;
        flex-direction: column;
        gap: 5px;
    }

    body { padding-bottom: 100px; }
}

@media (min-width: 769px) {
    body { padding-bottom: 60px; }
}
