/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-top: 20px;
    margin-bottom: 20px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.header h1 {
    color: #4a5568;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.controls {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 60px; /* 为按钮留出空间 */
}

.control-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
    align-items: end;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 4px;
}

/* 表单元素样式 */
select, input[type="text"] {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
    cursor: pointer;
    height: 42px;
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    border-color: #ddd;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-width: 120px;
    white-space: nowrap;
}

.btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn:disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 操作按钮样式 */
.action-buttons {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    flex-direction: row;
    gap: 10px;
    z-index: 10;
}

.action-buttons button {
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 80px;
    font-size: 12px;
    padding: 8px 12px;
}

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

.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(33, 150, 243, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ee5a52 0%, #dc4545 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

/* 学期信息显示 */
.semester-info {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

/* 课程表样式 */
.schedule-container {
    margin-bottom: 30px;
    overflow-x: auto;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.schedule-table th {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px 10px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

.schedule-table td {
    padding: 12px 8px;
    text-align: center;
    border: 1px solid #e9ecef;
    min-height: 50px;
    vertical-align: middle;
    cursor: pointer;
    transition: background-color 0.3s ease;
    position: relative;
}

.schedule-table td:hover {
    background-color: #f8f9fa;
}

.schedule-table td.editable:hover {
    background-color: #e3f2fd;
}

.time-header {
    background: #495057 !important;
    color: white;
    font-weight: 600;
}

.section-header {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    font-weight: 600;
    font-size: 16px;
    padding: 15px 8px;
    text-align: center;
    border: none;
}

.period-section-title {
    border: none;
}

.period-section-title td {
    border: none;
}

.schedule-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.schedule-table tbody tr:nth-child(odd) {
    background-color: white;
}

/* 编辑区域样式 */
.edit-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

.edit-section h3 {
    color: #495057;
    margin-bottom: 15px;
    text-align: center;
}

.edit-controls {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    padding: 10px 0;
    width: 100%;
}

.edit-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    min-width: fit-content;
}

.edit-group label {
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    font-size: 13px;
    min-width: fit-content;
}

.edit-group select,
.edit-group input {
    min-width: 80px;
    max-width: 120px;
    font-size: 13px;
    padding: 6px 8px;
    flex-shrink: 0;
}

/* 快速编辑区域内的按钮样式 */
.edit-controls .btn {
    padding: 6px 12px;
    min-width: 60px;
    font-size: 13px;
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: 5px;
}

/* 模板区域样式 */
.templates-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

.templates-section h3 {
    color: #495057;
    margin-bottom: 15px;
    text-align: center;
}

.template-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.template-btn {
    padding: 6px 12px;
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
}



/* 打印样式 */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        /* color-adjust 已被 print-color-adjust 替代 */
    }
    
    body {
        background: white;
        color: black;
        font-family: "Microsoft YaHei", "SimHei", Arial, sans-serif;
        font-size: 12pt;
        line-height: 1.4;
        margin: 0;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        background: white;
        margin: 0;
        padding: 15mm;
        max-width: none;
        width: 100%;
    }
    
    .header .controls,
    .edit-section,
    .templates-section {
        display: none;
    }
    
    .header {
        text-align: center;
        margin-bottom: 20pt;
        page-break-inside: avoid;
    }
    
    .header h1 {
        color: black;
        text-shadow: none;
        font-size: 24pt;
        font-weight: bold;
        margin: 0 0 10pt 0;
        letter-spacing: 2pt;
    }
    
    .semester-info {
        background: #f8f9fa !important;
        color: black;
        border: 2pt solid #333;
        padding: 8pt 12pt;
        margin: 10pt 0 20pt 0;
        border-radius: 0;
        font-size: 11pt;
        text-align: center;
        page-break-inside: avoid;
    }
    
    .schedule-table {
        box-shadow: none;
        border-collapse: collapse;
        border: 2pt solid #000;
        width: 100%;
        margin: 0 auto;
        font-size: 10pt;
        page-break-inside: avoid;
    }
    
    .schedule-table th {
        background: #e9ecef !important;
        color: black !important;
        border: 1pt solid #000;
        padding: 8pt 4pt;
        font-weight: bold;
        text-align: center;
        font-size: 12pt;
    }
    
    .schedule-table td {
        border: 1pt solid #000;
        background: white !important;
        padding: 8pt 4pt;
        text-align: center;
        vertical-align: middle;
        min-height: 35pt;
        font-size: 11pt;
        line-height: 1.4;
    }
    
    .time-header {
        background: #dee2e6 !important;
        color: black !important;
        font-weight: bold;
        width: 60pt;
    }
    
    /* 课程内容样式 */
    .schedule-table td:not(.time-header):not(:first-child) {
        word-wrap: break-word;
        word-break: break-all;
        max-width: 80pt;
    }
    
    /* 确保表格不会被分页 */
    .schedule-table,
    .schedule-table thead,
    .schedule-table tbody {
        page-break-inside: avoid;
    }
    
    /* 打印时隐藏不必要的元素 */
    .modal,
    .temp-message,
    button,
    input,
    select {
        display: none !important;
    }
    
    /* 页面设置 */
    @page {
        size: A4 landscape;
        margin: 15mm;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .controls {
        padding: 15px;
    }
    
    .control-row {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .control-group select {
        font-size: 16px; /* 防止iOS缩放 */
        height: 44px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .button-group button {
        width: 100%;
    }
    
    .action-buttons {
        bottom: 20px;
        right: 20px;
        gap: 10px;
    }
    
    .action-buttons .btn {
        min-width: 100px;
        padding: 10px 18px;
        font-size: 13px;
    }
}

/* 学期管理样式 */
.semester-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.semester-control select {
    flex: 1;
}

.manage-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.manage-btn:hover {
    background: #0056b3;
}

.manage-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    border: none;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-body {
    padding: 20px;
}

.semester-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.semester-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
}

.semester-item.current {
    background: #e3f2fd;
    border-color: #2196f3;
}

.semester-info {
    flex: 1;
}

.semester-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.semester-details {
    font-size: 12px;
    color: #666;
}

.semester-actions {
    display: flex;
    gap: 8px;
}

.semester-actions .btn {
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-switch {
    background: #28a745;
    color: white;
}

.btn-switch:hover {
    background: #218838;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-switch:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state p {
    margin: 0;
    font-size: 16px;
}

/* 临时消息样式 */
.temp-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    font-size: 14px;
    font-weight: 500;
    animation: slideInRight 0.3s ease-out, fadeOut 0.5s ease-in 2.5s forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

@media (max-width: 768px) {
    .schedule-table {
        font-size: 12px;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 8px 4px;
    }
    
    .time-header {
        width: 60px;
    }
    
    .section-header {
        font-size: 14px;
        padding: 12px 8px;
    }
    
    .edit-controls {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        justify-content: center;
    }
    
    .template-buttons {
        justify-content: center;
    }
    
    .template-btn {
        font-size: 12px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .controls {
        padding: 12px;
        gap: 12px;
    }
    
    .control-row {
        gap: 10px;
        margin-bottom: 10px;
    }
    
    .control-group label {
        font-size: 13px;
    }
    
    .control-group select {
        padding: 8px 10px;
        font-size: 14px;
        height: 40px;
    }
    
    .button-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        margin: 0;
    }
    
    .header h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .schedule-table {
        font-size: 11px;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 6px 2px;
    }
    
    .section-header {
        font-size: 13px;
        padding: 10px 6px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .schedule-table {
        font-size: 10px;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 6px 2px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* 动画效果 */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* 课程表单元格特殊状态 */
.schedule-table td.empty {
    color: #6c757d;
    font-style: italic;
}

.schedule-table td.selected {
    background-color: #667eea !important;
    color: white;
}

/* 科目颜色标识 */
.subject-chinese { background-color: #ffebee; }
.subject-math { background-color: #e8f5e8; }
.subject-english { background-color: #e3f2fd; }
.subject-physics { background-color: #fff3e0; }
.subject-chemistry { background-color: #f3e5f5; }
.subject-biology { background-color: #e0f2f1; }
.subject-history { background-color: #fce4ec; }
.subject-geography { background-color: #e1f5fe; }
.subject-politics { background-color: #fff8e1; }
.subject-pe { background-color: #f1f8e9; }
.subject-music { background-color: #fce4ec; }
.subject-art { background-color: #e8eaf6; }