/**
 * 课表统计系统 - 统一样式表
 * 设计理念：简约、现代、专业
 */

/* ==================== 全局样式 ==================== */
:root {
    /* 主色调 - 简约蓝灰色系 */
    --primary-color: #4A90E2;
    --primary-light: #6BA3E8;
    --primary-dark: #357ABD;
    
    /* 中性色 */
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --text-light: #95A5A6;
    
    /* 背景色 */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F9FA;
    --bg-hover: #F0F2F5;
    
    /* 边框色 */
    --border-color: #E1E4E8;
    --border-light: #F0F0F0;
    
    /* 状态色 */
    --success-color: #27AE60;
    --warning-color: #F39C12;
    --danger-color: #E74C3C;
    
    /* 阴影 */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    
    /* 圆角 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* 间距 */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 容器 ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* ==================== 头部导航 ==================== */
.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    font-size: 24px;
}

.nav-menu {
    display: flex;
    gap: var(--spacing-sm);
    list-style: none;
}

.nav-menu li {
    display: flex;
    align-items: center;
}

.nav-menu a,
.nav-menu button {
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.nav-menu a:hover,
.nav-menu button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-menu a.active {
    background: var(--primary-color);
    color: white;
}

.nav-menu button.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.nav-menu button.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ==================== 卡片 ==================== */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--border-light);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* ==================== 按钮 ==================== */
.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #C0392B;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #d68910;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: var(--spacing-sm);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

/* ==================== 表单控件 ==================== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-input::placeholder {
    color: var(--text-light);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

/* ==================== 筛选器 ==================== */
.filters {
    background: var(--bg-primary);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--border-light);
}

.filter-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    align-items: end;
}

/* ==================== 课表表格 ==================== */
.schedule-container {
    overflow-x: auto;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    cursor: grab;
    user-select: none;
}

.schedule-container:active {
    cursor: grabbing;
}

.schedule-container::-webkit-scrollbar {
    height: 8px;
}

.schedule-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.schedule-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

.schedule-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
}

/* 课表容器 - 支持横向滚动 */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    margin: 0;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: white;
    position: relative;
}

/* 美化滚动条 */
.table-wrapper::-webkit-scrollbar {
    height: 10px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.schedule-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    font-size: 13px;
    margin: 0;
}

.schedule-table thead th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    padding: var(--spacing-md);
    text-align: center;
    border: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    min-width: 60px;
    white-space: nowrap;
}

.schedule-table tbody td {
    padding: var(--spacing-sm);
    border: 1px solid var(--border-light);
    text-align: center;
    vertical-align: middle;
    transition: all 0.2s;
    min-width: 80px;
}

.class-header {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    left: 0;
    z-index: 5;
}

.schedule-cell {
    min-height: 60px;
    position: relative;
}

.schedule-cell:hover:not(.empty) {
    background: var(--bg-hover);
    cursor: pointer;
}

.schedule-cell.empty {
    color: var(--text-light);
    background: var(--bg-secondary);
}

.course-info {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.teacher-info {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 2px;
}

.classroom-info {
    color: var(--text-light);
    font-size: 11px;
}

/* 增强版大课表专用样式 */
.weekday-header {
    background: var(--primary-color) !important;
    color: white !important;
    font-weight: 600;
    font-size: 15px;
    padding: 12px !important;
}

.date-header {
    background: var(--primary-light) !important;
    color: white !important;
    font-size: 13px;
    padding: 8px !important;
}

.period-header {
    background: var(--bg-secondary) !important;
    font-size: 12px;
    padding: 8px !important;
    min-width: 80px;
    white-space: nowrap;
}

.add-period-header {
    background: #f0f0f0 !important;
    color: #999;
    cursor: pointer;
    min-width: 60px;
}

.add-period-header:hover {
    background: #e0e0e0 !important;
}

.empty-text {
    color: #ccc;
    font-size: 24px;
    text-align: center;
    cursor: pointer;
}

.schedule-cell.empty:hover .empty-text {
    color: var(--primary-color);
    font-size: 28px;
}

.add-period-cell {
    background: #fafafa;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    border-left: 2px dashed #ddd !important;
}

.add-period-cell:hover {
    background: #f0f0f0;
    color: var(--primary-color);
}

.add-period-text {
    font-size: 12px;
}

.clickable-header {
    cursor: pointer;
}

.clickable-header:hover {
    background: var(--bg-hover) !important;
}

/* 课程类型样式 */
.course-regular {
    background: #e3f2fd;
    border-left: 3px solid #2196F3;
}

.course-experiment {
    background: #f3e5f5;
    border-left: 3px solid #9C27B0;
}

.course-sports {
    background: #e8f5e9;
    border-left: 3px solid #4CAF50;
}

.course-evening {
    background: #fff3e0;
    border-left: 3px solid #FF9800;
}

.course-self-study {
    background: #fce4ec;
    border-left: 3px solid #E91E63;
}

.active-cell {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

/* ==================== 统计信息 ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--bg-primary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ==================== 加载状态 ==================== */
.loading {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--spacing-md);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

.modal.show,
.modal-overlay.show,
.modal-overlay {
    display: flex !important;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    margin: 20px;
}

/* 编辑课程模态框特定样式 */
#editModal .modal-content {
    max-width: 500px;
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.modal-close:hover {
    background: var(--bg-hover);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* 编辑模态框内的表单样式 */
.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.modal-body .form-group input[type="text"],
.modal-body .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.2s;
}

.modal-body .form-group input[type="text"]:focus,
.modal-body .form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.modal-body .form-group select:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

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

/* ==================== 消息提示 ==================== */
.message {
    position: fixed;
    top: 80px;
    right: var(--spacing-lg);
    max-width: 400px;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.message-success {
    background: var(--success-color);
    color: white;
}

.message-error {
    background: var(--danger-color);
    color: white;
}

.message-info {
    background: var(--primary-color);
    color: white;
}

/* ==================== 每日备注样式 ==================== */
.note-btn-mini {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 8px;
    transition: all 0.3s ease;
}

.note-btn-mini:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.note-preview {
    display: inline-block;
    margin-left: 8px;
    color: #667eea;
    font-size: 12px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.date-header.has-note {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%) !important;
}

.note-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

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

.note-dialog {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.note-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e1e4e8;
}

.note-dialog-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 20px;
}

.note-dialog-close {
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.note-dialog-close:hover {
    color: #333;
}

.note-dialog-body {
    padding: 24px;
}

.note-date-display {
    margin: 0 0 16px 0;
    color: #666;
    font-size: 14px;
}

.note-content-input {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.note-content-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.note-dialog-footer {
    padding: 16px 24px;
    border-top: 1px solid #e1e4e8;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.note-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.note-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.note-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.note-btn-secondary {
    background: #f0f0f0;
    color: #666;
}

.note-btn-secondary:hover {
    background: #e0e0e0;
}

.note-btn-danger {
    background: #e74c3c;
    color: white;
    margin-right: auto;
}

.note-btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    body {
        font-size: 12px;
    }
    
    .container {
        padding: 8px;
    }
    
    .header {
        position: relative;
    }
    
    .header-content {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding: 12px;
    }
    
    .logo {
        font-size: 16px;
    }
    
    .nav-menu {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }
    
    .nav-menu a,
    .nav-menu button {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .nav-menu button {
        white-space: nowrap;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .card {
        margin-bottom: 12px;
        padding: 12px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .card-title {
        font-size: 16px;
    }
    
    .form-row, .filter-group {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .btn-group {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
        font-size: 13px;
        padding: 10px;
    }
    
    /* 手机端课表优化 */
    .schedule-container {
        border-radius: 4px;
        margin: 0 -8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .schedule-table {
        font-size: 10px;
        min-width: auto;
    }
    
    .schedule-table thead th {
        padding: 6px 4px;
        min-width: 45px;
        font-size: 11px;
    }
    
    .schedule-table tbody td {
        padding: 4px 2px;
        min-width: 45px;
    }
    
    .schedule-cell {
        min-height: 50px;
    }
    
    .class-header {
        font-size: 11px;
        min-width: 60px !important;
        position: sticky;
        left: 0;
        background: var(--bg-secondary) !important;
        z-index: 5;
        box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    }
    
    .course-info {
        font-size: 11px;
        font-weight: 600;
        margin-bottom: 2px;
    }
    
    .teacher-info {
        font-size: 9px;
        margin-bottom: 1px;
    }
    
    .classroom-info {
        font-size: 8px;
    }
    
    .description-info {
        font-size: 8px !important;
        margin-top: 1px !important;
    }
    
    /* 模态框手机端优化 */
    .password-modal .password-content {
        width: 90%;
        max-width: 90%;
        padding: 20px;
    }
    
    .password-header h3 {
        font-size: 18px;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .header,
    .filters,
    .btn,
    .card-header,
    .nav-menu {
        display: none;
    }
    
    .schedule-table {
        font-size: 10px;
    }
    
    .schedule-table tbody td {
        padding: 4px;
    }
}
