@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root { 
    --grid-size: 20px; 
    --primary-color: #6366f1; 
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --warning-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --danger-gradient: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    --neutral-gradient: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    --background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-gradient: linear-gradient(145deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.85) 100%);
    --glass-effect: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.18);
    --danger-color: #ff6b6b; 
    --danger-hover: #ee5a24;
    --success-color: #00f2fe; 
    --success-hover: #4facfe;
    --warning-color: #fee140;
    --warning-hover: #fa709a;
    --secondary-color: #74b9ff;
    --secondary-hover: #0984e3;
    --background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --surface: rgba(255, 255, 255, 0.95);
    --surface-elevated: rgba(255, 255, 255, 0.98);
    --border: rgba(99, 102, 241, 0.1);
    --border-light: rgba(99, 102, 241, 0.05);
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

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

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    padding: 20px; 
    min-height: 100vh;
}

.container { 
    max-width: 1400px; 
    margin: 0 auto; 
    background: var(--surface); 
    border-radius: var(--radius-xl); 
    box-shadow: var(--shadow-xl); 
    overflow: hidden;
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header {
    background: var(--primary-gradient);
    color: white;
    padding: 32px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="15" height="15" patternUnits="userSpaceOnUse"><path d="M 15 0 L 0 0 0 15" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.4;
}

.header::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: shimmer 8s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translateX(-50%) translateY(-50%) rotate(0deg); }
    50% { transform: translateX(-30%) translateY(-30%) rotate(180deg); }
}

.header > * {
    position: relative;
    z-index: 1;
}

.header h1 {
    font-size: 32px;
    font-weight: 800;
    text-align: center;
    flex-grow: 1;
    letter-spacing: -0.025em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#manualSaveBtn {
    background: var(--success-gradient);
    border: 1px solid rgba(255,255,255,0.3);
    font-weight: 600;
    padding: 14px 28px;
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#manualSaveBtn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-lg);
    border-color: rgba(255,255,255,0.5);
}

#saveStatus { 
    font-size: 13px; 
    font-weight: 600; 
    padding: 10px 20px; 
    border-radius: var(--radius-lg); 
    transition: all 0.3s ease; 
    border: 1px solid rgba(255,255,255,0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

#saveStatus.unsaved { background: var(--warning-gradient); color: white; }
#saveStatus.saving { background: var(--neutral-gradient); color: white; animation: pulse 1.5s infinite; }
#saveStatus.saved { background: var(--success-gradient); color: white; }

@keyframes pulse { 
    0% { opacity: 1; transform: scale(1); } 
    50% { opacity: 0.8; transform: scale(1.05); } 
    100% { opacity: 1; transform: scale(1); } 
}

.main-nav { 
    padding: 0; 
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,250,252,0.9) 100%); 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    position: relative;
    flex-wrap: wrap;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.nav-btn { 
    background: transparent; 
    color: var(--text-secondary); 
    font-weight: 600; 
    border: none;
    padding: 18px 28px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-size: 14px;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--primary-gradient);
    transition: left 0.3s ease;
    z-index: -1;
}

.nav-btn:hover {
    color: white;
    transform: translateY(-1px);
}

.nav-btn:hover::before {
    left: 0;
}

.nav-btn.active { 
    background: var(--primary-gradient); 
    color: white; 
    box-shadow: var(--shadow);
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
}

.controls { 
    padding: 40px; 
    border-bottom: 1px solid var(--border); 
    background: linear-gradient(135deg, rgba(255,255,255,0.8) 0%, rgba(248,250,252,0.9) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.control-group { 
    margin-bottom: 24px; 
    display: flex; 
    align-items: center; 
    gap: 16px; 
    flex-wrap: wrap; 
}

.control-group label { 
    font-weight: 600; 
    min-width: 140px; 
    color: var(--text-primary);
    font-size: 15px;
}

button { 
    background: var(--primary-gradient); 
    color: white; 
    border: none; 
    padding: 12px 24px; 
    border-radius: var(--radius-lg); 
    cursor: pointer; 
    font-size: 14px; 
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.2);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

button:hover::before {
    width: 300px;
    height: 300px;
}

button:hover { 
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: translateY(0) scale(0.98);
}

button:disabled { 
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%); 
    cursor: not-allowed; 
    transform: none;
    box-shadow: var(--shadow-sm);
}

.secondary-btn { 
    background: var(--neutral-gradient); 
}

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

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

.warning-btn {
    background: var(--warning-gradient);
}

input[type="file"], input[type="text"], input[type="number"], select, textarea { 
    border: 2px solid var(--border); 
    border-radius: var(--radius-lg); 
    padding: 12px 16px; 
    font-size: 14px; 
    background: rgba(255,255,255,0.9);
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

input[type="file"]:focus, input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    background: rgba(255,255,255,0.95);
    transform: translateY(-1px);
}

.view-container { display: block; }
.view-container.hidden { display: none; }

.classroom { 
    position: relative; 
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,250,252,0.95) 100%); 
    min-height: 900px; 
    margin: 40px; 
    border: 3px dashed var(--primary-color); 
    border-radius: var(--radius-xl); 
    overflow: auto; /* Changed from hidden to auto for mobile scrolling */
    background-size: var(--grid-size) var(--grid-size); 
    background-image: 
        linear-gradient(to right, rgba(99, 102, 241, 0.1) 1px, transparent 1px), 
        linear-gradient(to bottom, rgba(99, 102, 241, 0.1) 1px, transparent 1px); 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.seat { 
    position: absolute; 
    width: 100px; 
    height: 100px; 
    background: var(--card-gradient); 
    border: 2px solid var(--glass-border); 
    border-radius: var(--radius-lg); 
    cursor: grab; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 12px; 
    font-weight: 600; 
    text-align: center; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    user-select: none; 
    padding: 10px; 
    word-wrap: break-word; 
    overflow: hidden; 
    box-shadow: var(--shadow);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.seat.occupied { cursor: pointer; }

.seat:not(.dragging):hover { 
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2), 
                0 10px 20px rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.5);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.95) 100%);
}

.seat.dragging { 
    cursor: grabbing; 
    transform: rotate(8deg) scale(1.1); 
    z-index: 1000; 
    opacity: 0.9; 
    box-shadow: var(--shadow-xl);
    transition: none;
}

.seat.occupied { 
    background: linear-gradient(145deg, #e0f2fe 0%, #f0f9ff 100%); 
    border-color: #7dd3fc; 
    color: #0369a1; 
}

.seat.male { 
    background: linear-gradient(145deg, #dbeafe 0%, #eff6ff 100%); 
    border-color: #93c5fd; 
    color: #1d4ed8;
}

.seat.female { 
    background: linear-gradient(145deg, #fce7f3 0%, #fdf2f8 100%); 
    border-color: #f9a8d4; 
    color: #be185d;
}

.student-name { 
    font-weight: 700; 
    font-size: 13px; 
    padding: 8px 10px; 
    border-radius: var(--radius); 
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.student-name::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -100%;
    width: 100%;
    height: calc(100% + 4px);
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.6),
        transparent
    );
    transition: left 0.6s ease;
}

.student-name:hover {
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.98) 0%,
        rgba(248, 250, 252, 0.95) 100%);
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.9) inset;
    border: 1px solid rgba(255, 255, 255, 0.8);
    transform: translateY(-2px) scale(1.05);
}

.student-name:hover::before {
    left: 100%;
}

.student-name[contenteditable="true"]:focus { 
    background: rgba(255, 255, 255, 0.98); 
    outline: 3px solid var(--primary-color); 
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.1); 
    transform: none;
}

.behavior-display { 
    display: flex; 
    justify-content: space-around; 
    width: 100%; 
    font-size: 11px; 
    gap: 4px;
}

.behavior-item { 
    display: flex; 
    align-items: center; 
    gap: 2px; 
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    color: inherit;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.toast { 
    position: fixed; 
    top: 30px; 
    left: 50%; 
    transform: translateX(-50%); 
    background: var(--success-gradient); 
    color: white; 
    padding: 16px 28px; 
    border-radius: var(--radius-xl); 
    z-index: 2000; 
    display: none; 
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    font-weight: 600;
}

.toast.error { 
    background: var(--danger-gradient); 
}

.modal-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.4); 
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none; 
    justify-content: center; 
    align-items: center; 
    z-index: 1500; 
}

.modal-content { 
    background: var(--card-gradient); 
    padding: 40px 48px 48px 48px; 
    border-radius: var(--radius-xl); 
    text-align: center; 
    box-shadow: var(--shadow-xl); 
    border: 1px solid var(--glass-border);
    max-width: 90vw;
    width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

#customModal .modal-content {
    text-align: left;
}

#customModalMessage {
     margin: 16px 0; 
     color: var(--text-secondary);
     line-height: 1.6;
     font-size: 15px;
}

#customModalInput {
    display: none; 
    width: 100%; 
    margin-top: 12px;
}

.modal-content h3 { 
    margin-bottom: 28px; 
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-behavior-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 18px 24px; 
    border-bottom: 1px solid var(--border-light); 
    width: 380px; 
    transition: all 0.3s ease;
    border-radius: var(--radius);
    margin-bottom: 4px;
}

.modal-behavior-row:hover {
    background: rgba(99, 102, 241, 0.05);
    transform: translateX(4px);
}

.modal-behavior-name { 
    font-size: 16px; 
    font-weight: 600; 
    flex-grow: 1; 
    text-align: left; 
    color: var(--text-primary);
}

.modal-behavior-actions { 
    display: flex; 
    align-items: center; 
    gap: 16px; 
}

.modal-behavior-actions button { 
    width: 40px; 
    height: 40px; 
    font-size: 18px; 
    line-height: 1; 
    padding: 0; 
    border-radius: 50%; 
    font-weight: 700;
}

.modal-behavior-count { 
    font-size: 18px; 
    font-weight: 700; 
    min-width: 50px; 
    text-align: center; 
    color: var(--text-primary);
}

#deleteZone { 
    position: fixed; 
    bottom: -150px; 
    left: 0; 
    width: 100%; 
    height: 60px; 
    background: var(--danger-gradient); 
    border-top: 4px dashed rgba(255,255,255,0.8); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 999; 
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
    pointer-events: none; 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#deleteZone.active { 
    bottom: 0; 
    pointer-events: all; 
    box-shadow: var(--shadow-xl);
}

#deleteZone.hover { 
    background: linear-gradient(135deg, #ff4757 0%, #c44569 100%); 
    transform: scale(1.02);
}

#deleteZone::after { 
    content: '🗑️ Drag here to delete seat'; 
    font-size: 28px; 
    color: white; 
    font-weight: 700; 
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#dashboardContainer { padding: 40px; }

#dashboardHeader { 
    font-size: 32px; 
    font-weight: 800; 
    color: var(--text-primary); 
    margin-bottom: 32px; 
    border-bottom: 3px solid var(--primary-color); 
    padding-bottom: 20px; 
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); 
    gap: 28px; 
}

.student-card { 
    background: var(--card-gradient); 
    border-radius: var(--radius-xl); 
    box-shadow: var(--shadow-md); 
    border: 1px solid var(--glass-border); 
    display: flex; 
    flex-direction: column; 
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
    overflow: hidden;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.student-card:hover { 
    transform: translateY(-8px) scale(1.02); 
    box-shadow: var(--shadow-xl); 
    border-color: var(--primary-color);
}

.card-header { 
    padding: 24px; 
    border-bottom: 1px solid var(--border); 
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
}

.card-header h3 { 
    font-size: 20px; 
    color: var(--text-primary); 
    font-weight: 700;
}

.card-body { 
    padding: 24px; 
    flex-grow: 1; 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 24px; 
}

.behavior-section h4 { 
    font-size: 13px; 
    text-transform: uppercase; 
    letter-spacing: 0.1em; 
    color: var(--text-muted); 
    margin-bottom: 16px; 
    font-weight: 700;
}

.behavior-list { 
    list-style: none; 
    padding: 0; 
}

.behavior-list li { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 14px; 
    padding: 8px 0; 
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.behavior-list li:hover {
    background: rgba(99, 102, 241, 0.05);
    padding-left: 8px;
    padding-right: 8px;
}

.behavior-list .count { 
    font-weight: 800; 
    font-size: 18px; 
}

.behavior-list .positive .count { color: var(--success-color); }
.behavior-list .negative .count { color: var(--danger-color); }

.card-footer { 
    padding: 24px; 
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(139, 92, 246, 0.02) 100%); 
    border-top: 1px solid var(--border); 
    text-align: center; 
}

.net-score-label { 
    font-size: 14px; 
    font-weight: 600; 
    color: var(--text-secondary); 
    margin-bottom: 8px;
}

.net-score-display { 
    font-size: 42px; 
    font-weight: 900; 
    line-height: 1;
}

.net-score-positive { 
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.net-score-negative { 
    background: var(--danger-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.net-score-neutral { color: var(--text-muted); }

#groupingControls { 
    padding: 40px; 
    border-bottom: 1px solid var(--border); 
    background: linear-gradient(135deg, rgba(255,255,255,0.8) 0%, rgba(248,250,252,0.9) 100%);
    display: flex; 
    align-items: center; 
    gap: 20px; 
    flex-wrap: wrap; 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#groupingResults { padding: 40px; }

.grouping-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); 
    gap: 28px; 
}

.group-card { 
    background: var(--card-gradient); 
    border-radius: var(--radius-xl); 
    box-shadow: var(--shadow-md); 
    border: 1px solid var(--glass-border); 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.group-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.group-card-header { 
    padding: 20px 24px; 
    background: var(--primary-gradient); 
    color: white;
    font-weight: 700; 
    font-size: 16px;
}

.group-card-body { padding: 24px; }
.group-card-body ul { list-style: none; padding: 0; }
.group-card-body li { 
    padding: 10px 0; 
    display: flex; 
    align-items: center; 
    font-weight: 500;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.group-card-body li:hover {
    background: rgba(99, 102, 241, 0.05);
    padding-left: 8px;
    border-radius: var(--radius-sm);
}

#gradesTableContainer {
    padding: 0 40px 40px 40px;
    overflow-x: auto;
}

.grades-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 24px;
    white-space: nowrap;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.grades-table th, .grades-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border-light);
    background: var(--surface);
}

.grades-table th:first-child, .grades-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--card-gradient);
    border-right: 2px solid var(--border);
    z-index: 2;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.grades-table th {
    background: var(--primary-gradient);
    color: white;
    font-weight: 700;
    position: sticky;
    top: 0;
    cursor: grab;
    z-index: 1;
}

.grades-table th:first-child {
    background: var(--primary-gradient);
    color: white;
}

.grades-table .assessment-header[contenteditable="true"]:focus {
    outline: 2px solid rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.2);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.grades-table tbody tr {
    cursor: grab;
    transition: all 0.2s ease;
}

.grades-table tbody tr:hover td {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
}

.grades-table .grade-input {
    width: 100%;
    min-width: 120px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    background: rgba(255,255,255,0.9);
    transition: all 0.3s ease;
}

.grades-table .grade-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: white;
}

.grades-table .dragging {
    opacity: 0.6;
    background: var(--primary-light);
}

.grades-table .drag-over {
    border-bottom: 4px solid var(--primary-color);
}

.grades-table th.drag-over-col {
    border-right: 4px solid var(--primary-color);
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: 8px;
    border: 2px solid var(--border-light);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

#confetti-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 9999; overflow: hidden;
}

.confetti {
    position: absolute; width: 12px; height: 12px;
    top: -20px; opacity: 0; border-radius: 50%; 
    animation: fall 4s linear forwards;
}

@keyframes fall {
    0% { transform: translateY(0vh) rotateZ(0deg); opacity: 1; }
    100% { transform: translateY(105vh) rotateZ(720deg); opacity: 0; }
}

#aiPromptInput {
    width: 100%;
    min-height: 120px;
    resize: vertical;
}

#aiOutputContainer {
    margin-top: 24px;
    padding: 24px;
    background: var(--surface-elevated);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    min-height: 100px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    line-height: 1.6;
    cursor: pointer;
}

.llm-selector {
    width: 200px;
    margin-right: 12px;
}

.feature-card {
    padding: 20px; 
    border-radius: var(--radius-lg); 
    border: 2px solid var(--border); 
    box-shadow: var(--shadow-md); 
    margin-bottom: 20px;
}

.feature-card h3 {
    font-weight: 700; 
    color: var(--text-primary); 
    margin-bottom: 16px;
}

.feature-card p {
    color: var(--text-secondary); 
    margin-bottom: 16px; 
    font-size: 14px;
}

.feature-card.igcse {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
}

.feature-card.ib {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
}

.feature-card.ib-achievement {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.feature-card.tutor {
    background: linear-gradient(135deg, rgba(245, 101, 101, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
}


/* --- FAQ Section Styles --- */
#faqView {
    padding: 40px;
    background: linear-gradient(135deg, rgba(255,255,255,0.8) 0%, rgba(248,250,252,0.9) 100%);
}

.faq-container {
    max-width: 900px;
    margin: 0 auto;
}

.faq-container h2 {
    font-size: 32px; 
    font-weight: 800; 
    color: var(--text-primary); 
    margin-bottom: 32px; 
    border-bottom: 3px solid var(--primary-color); 
    padding-bottom: 20px; 
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.faq-item {
    background: var(--card-gradient);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(99, 102, 241, 0.2);
}

.faq-question {
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 20px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
}

.faq-question:hover {
    background: rgba(99, 102, 241, 0.05);
}

.faq-question::after {
    content: '▼';
    font-size: 14px;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

.faq-question.active::after {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.7);
}

.faq-answer-content {
    padding: 0 24px 24px 24px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.faq-answer-content p {
    margin-bottom: 1em;
}

.faq-answer-content ul {
    list-style-position: inside;
    padding-left: 10px;
    margin-bottom: 1em;
}

.faq-answer-content li {
    margin-bottom: 0.5em;
}

.faq-answer-content code {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}


/* --- Responsive Styles for Mobile --- */
@media (max-width: 768px) { 
    body { 
        padding: 0; /* Remove body padding for edge-to-edge container */
        font-size: 15px; /* Slightly larger base font for readability */
    }
    .container { 
        border-radius: 0; /* Full-width container on mobile */
        border: none;
        min-height: 100vh;
    }
    .header { 
        flex-direction: column; /* Stack header items vertically */
        gap: 16px;
        padding: 24px; 
        text-align: center;
    }
    .header h1 { 
        font-size: 26px; 
        order: -1; /* Ensure title is first */
    }
    .main-nav {
        flex-direction: column; /* Stack nav buttons */
    }
    .nav-btn {
        text-align: center;
        border-bottom: 1px solid var(--border-light);
        padding: 16px;
    }
    .nav-btn:last-child {
        border-bottom: none;
    }
    .controls { 
        padding: 24px; 
    }
    .classroom { 
        margin: 24px; 
        min-height: 60vh; /* Reduce min-height */
    }
    .control-group { 
        flex-direction: column; 
        align-items: stretch; /* Stretch items to full width */
        gap: 12px; 
    }
    .control-group label { 
        min-width: auto; 
        text-align: left;
        margin-bottom: 4px;
    }
    /* Make all form elements and buttons in control groups full-width */
    .control-group button,
    .control-group input,
    .control-group select {
        width: 100%;
        margin-right: 0;
    }
    #groupingControls {
        flex-direction: column;
        align-items: stretch;
    }
    .seat {
        width: 80px;
        height: 80px;
        font-size: 10px;
        padding: 8px;
    }
    .student-name {
        font-size: 11px;
        padding: 5px 6px;
    }
    .dashboard-grid, .grouping-grid { 
        grid-template-columns: 1fr; 
    }
    #dashboardContainer, #groupingResults, #gradesTableContainer, #aiAssistantView > div, #faqView { 
        padding: 24px; 
    }
    #gradesTableContainer {
        padding: 0 24px 24px 24px;
    }
    .modal-content {
        width: 90vw;
        padding: 24px;
        max-height: 85vh;
    }
    .modal-behavior-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
        width: auto;
    }
    .modal-behavior-name {
        text-align: center;
    }
    #deleteZone::after {
        font-size: 18px;
        content: '🗑️ Drag to delete';
    }
    .feature-card div[style*="display: flex"] {
        flex-direction: column;
        align-items: stretch;
        gap: 12px !important; /* Use important to override inline style */
    }
    .feature-card .llm-selector {
        width: 100%;
    }
}