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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

h1 {
    color: #333;
    margin-bottom: 30px;
    text-align: center;
    font-size: 2em;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

label {
    font-weight: 600;
    color: #555;
}

input[type="number"], input[type="file"], select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-success {
    background: #48bb78;
    color: white;
}

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

.btn-danger {
    background: #f56565;
    color: white;
}

.main-content {
    display: flex;
    gap: 30px;
}

.student-list {
    flex: 0 0 250px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    max-height: 600px;
    overflow-y: auto;
    transition: all 0.3s;
}

.student-list.drag-target {
    background: #e6f7ff;
    border: 3px dashed #1890ff;
    box-shadow: 0 0 20px rgba(24, 144, 255, 0.3);
}

.student-list h3 {
    margin-bottom: 15px;
    color: #333;
}

.student-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: move;
    transition: all 0.3s;
}

.student-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.student-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.student-item.assigned {
    display: none;
}

.gender-icon {
    font-size: 18px;
}

.seating-area {
    flex: 1;
    position: relative;
}

.view-indicator {
    text-align: center;
    padding: 10px;
    margin-bottom: 10px;
    background: #fff7e6;
    border: 2px solid #ffa940;
    border-radius: 8px;
    font-weight: 600;
    color: #d46b08;
}

.seats-container {
    position: relative;
}

.blackboard {
    text-align: center;
    padding: 20px;
    margin: 15px 0;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border: 4px solid #1a252f;
    border-radius: 10px;
    color: #ecf0f1;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    letter-spacing: 2px;
}

.blackboard::before {
    content: '📋';
    margin-right: 10px;
    font-size: 24px;
}

.row-labels {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

.row-labels.top {
    margin-bottom: 15px;
    margin-top: 0;
}

.row-labels.bottom {
    margin-top: 15px;
    margin-bottom: 0;
}

.row-label {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: linear-gradient(135deg, #e6f7ff 0%, #bae7ff 100%);
    border: 2px solid #1890ff;
    border-radius: 8px;
    font-weight: 700;
    color: #0050b3;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.2);
    position: relative;
}

.row-label::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

/* 黑板在下時的箭頭（向上指） */
.row-labels.bottom .row-label::after {
    bottom: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 0 6px 8px 6px;
    border-color: transparent transparent #1890ff transparent;
}

/* 黑板在上時的箭頭（向下指） */
.row-labels.top .row-label::after {
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 8px 6px 0 6px;
    border-color: #1890ff transparent transparent transparent;
}

.seats-grid {
    display: grid;
    gap: 10px;
    margin: 0;
}

.seat {
    position: relative;
    background: #fff;
    border: 3px solid #ddd;
    border-radius: 12px;
    padding: 15px;
    min-height: 100px;
    cursor: move;
    transition: all 0.3s;
}

.seat:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.seat.occupied {
    background: #e6f7ff;
    border-color: #91d5ff;
}

.seat.occupied.male {
    background: #e6f7ff;
    border-color: #1890ff;
}

.seat.occupied.female {
    background: #fff0f6;
    border-color: #ff85c0;
}

.seat.fixed {
    border-color: #ffa940;
    border-width: 4px;
    background: #fff7e6;
}

.seat.disabled {
    background: #f5f5f5;
    border-color: #d9d9d9;
    cursor: not-allowed;
    opacity: 0.6;
}

.seat.drag-over {
    background: #fffbe6;
    border-color: #fadb14;
    transform: scale(1.08);
}

.seat.can-drop {
    background: #f6ffed;
    border-color: #52c41a;
    border-width: 3px;
}

.seat.cannot-drop {
    background: #fff1f0;
    border-color: #ff4d4f;
    border-width: 3px;
}

.seat-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
}

.seat-actions button {
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid #ddd;
}

.seat-actions button:hover {
    transform: scale(1.2);
}

.seat-actions button.active {
    background: #ffa940;
    border-color: #ffa940;
}

.seat-actions button.ban-active {
    background: #ff4d4f;
    border-color: #ff4d4f;
}

.seat-content {
    text-align: center;
    margin-top: 25px;
}

.seat-number {
    font-size: 12px;
    color: #999;
    margin-bottom: 5px;
}

.student-info {
    font-weight: 600;
    color: #333;
}

.student-id {
    font-size: 14px;
    color: #666;
}

.message {
    padding: 15px;
    margin: 15px 0;
    border-radius: 8px;
    display: none;
}

.message.show {
    display: block;
}

.message.info {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
    color: #0050b3;
}

.message.warning {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    color: #ad6800;
}

.message.error {
    background: #fff1f0;
    border: 1px solid #ffccc7;
    color: #cf1322;
}