:root {
  --img-size: 50px;
  --primary: #4338ca;
  --primary-hover: #3730a3;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-color: #eef2ff;
  --card-bg: rgba(255, 255, 255, 0.96);
  --border-color: #e0e7ff;
  --text-main: #1e293b;
}

* {
  box-sizing: border-box;
}

body { 
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
  background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
  color: var(--text-main); 
  margin: 0; 
  padding: 16px; 
  overflow-x: hidden; 
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.floating-code {
  position: absolute; 
  color: rgba(67, 56, 202, 0.12);
  font-family: 'Courier New', monospace; 
  font-size: 1rem;
  pointer-events: none; 
  z-index: 0; 
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 1; } 
  90% { opacity: 1; }
  100% { transform: translateY(-20vh) rotate(5deg); opacity: 0; }
}

.container { 
  max-width: 1300px; 
  margin: 0 auto; 
  position: relative; 
  z-index: 1; 
}

.card { 
  background: var(--card-bg); 
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px; 
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05); 
  padding: 24px; 
  margin-bottom: 24px; 
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.hidden { display: none !important; }

input, select, button { 
  padding: 10px 14px; 
  border: 1px solid var(--border-color); 
  border-radius: 8px; 
  font-size: 15px; 
  font-family: 'Prompt', sans-serif; 
  outline: none; 
  transition: all 0.25s ease;
}

input:focus, select:focus { 
  border-color: var(--primary); 
  box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15); 
}

button { 
  background-color: var(--primary); 
  color: white; 
  border: none; 
  cursor: pointer; 
  font-weight: 600; 
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:hover { 
  background-color: var(--primary-hover); 
  transform: translateY(-1px); 
}

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

button:disabled { 
  background-color: #cbd5e1; 
  cursor: not-allowed; 
  transform: none; 
}

.btn-success { background-color: var(--success); }
.btn-success:hover { background-color: #059669; }
.btn-warning { background-color: var(--warning); color: #fff; }
.btn-warning:hover { background-color: #d97706; }
.btn-danger { background-color: var(--danger); }
.btn-danger:hover { background-color: #dc2626; }

.login-tabs { 
  display: flex; 
  gap: 10px; 
  margin-bottom: 25px; 
  justify-content: center; 
}

.tab-btn { 
  background: #e2e8f0; 
  color: #475569; 
  border-radius: 30px; 
  padding: 10px 24px; 
}

.tab-btn.active { 
  background: var(--primary); 
  color: white; 
  box-shadow: 0 4px 10px rgba(67, 56, 202, 0.2); 
}

.landing-grid { 
  display: grid; 
  grid-template-columns: 1.15fr 1fr; 
  gap: 24px; 
  max-width: 1050px; 
  margin: 0 auto 25px auto; 
  align-items: stretch; 
}

@media (max-width: 860px) {
  .landing-grid { 
    grid-template-columns: 1fr; 
    gap: 20px; 
  }
}

.login-box { 
  max-width: 420px; 
  margin: 0 auto; 
  text-align: center; 
}

.login-box input { 
  width: 90%; 
  margin-bottom: 15px; 
}

.error-msg { 
  color: var(--danger); 
  font-size: 14px; 
  margin-bottom: 10px; 
  min-height: 21px; 
}

.admin-controls { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 15px; 
  align-items: center; 
  background: rgba(248, 250, 252, 0.85); 
  padding: 16px 20px; 
  border-radius: 12px; 
  border: 1px solid var(--border-color); 
  margin-bottom: 20px; 
}

.workspace { 
  display: flex; 
  gap: 20px; 
  align-items: flex-start; 
}

.student-list { 
  flex: 0 0 270px; 
  background: white; 
  border: 1px solid var(--border-color); 
  border-radius: 12px; 
  max-height: 650px; 
  overflow-y: auto; 
  padding: 12px; 
}

.student-item { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  padding: 10px 12px; 
  background: #eef2ff; 
  border-left: 5px solid #4338ca; 
  margin-bottom: 8px; 
  cursor: pointer; 
  border-radius: 8px; 
  transition: all 0.2s; 
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.student-item:hover { 
  background: #e0e7ff; 
  transform: translateX(3px); 
}

.student-item.selected { 
  background: #dbeafe; 
  border-left-color: #2563eb; 
}

.student-item img { 
  width: 50px; 
  height: 50px; 
  border-radius: 50%; 
  object-fit: cover; 
  border: 2px solid white; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

.seating-area { 
  flex: 1; 
  background: white; 
  border: 1px solid var(--border-color); 
  border-radius: 12px; 
  padding: 25px; 
  overflow-x: auto; 
}

#birthdayAlert { 
  padding: 12px 20px; 
  border-radius: 8px; 
  margin-bottom: 20px; 
  font-size: 15px; 
  display: none; 
}
#birthdayAlert.active { 
  background: #fdf2f8; 
  color: #db2777; 
  border: 1px solid #fbcfe8; 
}
#birthdayAlert.none { 
  background: #f8fafc; 
  color: #64748b; 
  border: 1px dashed #e2e8f0; 
}

/* Seating grid */
.room-front { 
  display: grid; 
  grid-template-columns: 2fr 5fr 2fr; 
  gap: 15px; 
  margin-bottom: 25px; 
}
.front-box { 
  background: #e2e8f0; 
  color: #475569; 
  font-weight: 600; 
  padding: 12px; 
  border-radius: 8px; 
  text-align: center; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}

.seating-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); 
  gap: 15px; 
  margin-top: 20px; 
}

.layout-426 { 
  display: grid; 
  grid-template-columns: 1fr 1fr 30px 1fr 1fr 30px 1fr 1fr 30px 1fr 1fr; 
  gap: 12px; 
}

.aisle-text { 
  writing-mode: vertical-rl; 
  text-align: center; 
  color: #94a3b8; 
  font-size: 13px; 
  letter-spacing: 4px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  background: #f8fafc; 
  border-radius: 6px; 
}

.seat { 
  background: #f8fafc; 
  border: 2px dashed #cbd5e1; 
  border-radius: 12px; 
  min-height: 130px; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer; 
  text-align: center; 
  padding: 8px; 
  transition: all 0.2s;
}

.seat:hover { 
  border-color: var(--primary); 
  background: #f1f5f9; 
}

.seat.occupied { 
  border: 2px solid var(--border-color); 
  background: white; 
}

.seat img { 
  width: var(--img-size); 
  height: var(--img-size); 
  border-radius: 50%; 
  object-fit: cover; 
  margin-bottom: 8px; 
}

.seat-status { 
  font-size: 12px; 
  font-weight: 600; 
  padding: 3px 8px; 
  border-radius: 20px; 
  margin-top: 6px; 
}

.layout-rinthong1 { 
  display: grid; 
  grid-template-columns: repeat(6, 1fr) 30px repeat(3, 1fr); 
  gap: 12px; 
}

.room-bottom-rinthong1 { 
  grid-column: 1 / -1; 
  display: grid; 
  grid-template-columns: repeat(6, 1fr) 30px repeat(3, 1fr); 
  gap: 12px; 
  margin-top: 15px; 
  padding-top: 15px; 
  border-top: 2px dashed #cbd5e1; 
}

.teacher-desk-rinthong { 
  grid-column: 3 / 5; 
  background: #e2e8f0; 
  padding: 12px; 
  border-radius: 8px; 
  text-align: center; 
  font-weight: 600; 
  color: #475569; 
}

.door-rinthong { 
  grid-column: 10 / 11; 
  background: #e2e8f0; 
  padding: 12px; 
  border-radius: 8px; 
  text-align: center; 
  font-weight: 600; 
  color: #475569; 
  border: 2px dashed #cbd5e1; 
}

.room-bottom-426 { 
  grid-column: 1 / -1; 
  display: grid; 
  grid-template-columns: 2fr 5fr 2fr; 
  gap: 15px; 
  margin-top: 15px; 
  padding-top: 15px; 
  border-top: 2px dashed #cbd5e1; 
}

.front-box-426 { 
  background: #e2e8f0; 
  color: #475569; 
  font-weight: 600; 
  padding: 12px; 
  border-radius: 8px; 
  text-align: center; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}

.history-badge { 
  background: #e0e7ff; 
  color: #3730a3; 
  border: 1px solid #c7d2fe; 
  padding: 5px 12px; 
  border-radius: 20px; 
  font-size: 13px; 
  cursor: pointer; 
  transition: all 0.2s; 
}

.history-badge:hover { 
  background: #c7d2fe; 
  transform: translateY(-2px); 
}

/* Privacy mode */
body.privacy-mode .student-item img, 
body.privacy-mode .seat img { 
  display: none !important; 
}

body.privacy-mode .seat { 
  min-height: 80px; 
  justify-content: center; 
}

#printReportHeader, #printSignature { display: none; }

/* =================== PWA Install Banner & Toast =================== */
.pwa-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 16px 32px rgba(30, 41, 59, 0.15), 0 4px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid #c7d2fe;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 9999;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 30px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.pwa-banner-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 4px 6px rgba(67, 56, 202, 0.2);
}

.pwa-banner-info {
  flex: 1;
}

.pwa-banner-title {
  font-weight: 600;
  font-size: 15px;
  color: #1e293b;
  margin: 0 0 2px 0;
}

.pwa-banner-desc {
  font-size: 12px;
  color: #64748b;
  margin: 0;
}

.pwa-banner-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pwa-btn-install {
  background: #4338ca;
  color: white;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 20px;
  font-weight: 600;
}

.pwa-btn-close {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 18px;
  padding: 4px;
  cursor: pointer;
}

/* iOS instructions sheet */
.ios-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.ios-sheet {
  background: white;
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 24px;
  box-shadow: 0 -10px 25px rgba(0,0,0,0.1);
  text-align: center;
  animation: slideSheetUp 0.3s ease-out;
}

@keyframes slideSheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.ios-step {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 10px;
  text-align: left;
}

.ios-step-num {
  width: 28px;
  height: 28px;
  background: #4338ca;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

/* =================== 📱 Mobile Responsive =================== */
@media (max-width: 768px) {
  body { padding: 10px; }
  .workspace { flex-direction: column; }
  .student-list { flex: 1 1 100%; width: 100%; max-height: 250px; }
  .seating-area { flex: 1 1 100%; width: 100%; overflow-x: auto; }
  .layout-426, .layout-rinthong1, .room-front, .room-bottom-426, .room-bottom-rinthong1 { min-width: 750px; }
  .admin-controls { flex-direction: column; align-items: stretch; }
  .admin-controls > div { display: flex; flex-direction: column; width: 100%; align-items: flex-start; }
  .admin-controls > div input, .admin-controls > div select { width: 100% !important; margin-top: 5px; }
  .admin-controls > button, .admin-controls > div.button-group button { width: 100%; margin-left: 0 !important; margin-top: 8px; }
}

/* =================== A4 Print =================== */
@media print {
  @page { size: A4 landscape; margin: 6mm 8mm; }
  body { background: white !important; color: #000 !important; padding: 0 !important; margin: 0 !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  #bg-animations, #loginWrapper, .admin-controls, .student-list, h1, p.main-subtitle, button, .login-tabs, #birthdayAlert, ::-webkit-scrollbar, .pwa-banner { display: none !important; }
  .container, .card, .workspace, .seating-area { max-width: 100% !important; width: 100% !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; border: none !important; background: transparent !important; }
  #printReportHeader { display: block !important; text-align: center; margin-bottom: 12px !important; border-bottom: 2px solid #334155 !important; padding-bottom: 6px !important; }
  #printReportHeader h2 { font-size: 16pt !important; margin: 0 0 4px 0 !important; color: #1e293b !important; }
  #printReportHeader p { font-size: 12pt !important; margin: 0 !important; color: #475569 !important; }
  #printSignature { display: flex !important; justify-content: flex-end; width: 100%; margin-top: 15px !important; page-break-inside: avoid !important; }
  .seat img { display: none !important; }
  .seating-grid, .layout-426, .layout-rinthong1 { gap: 6px !important; }
  .seat { background: #ffffff !important; border: 1px solid #475569 !important; height: 20mm !important; min-height: unset !important; padding: 4px !important; border-radius: 6px !important; display: flex !important; flex-direction: column !important; justify-content: center !important; page-break-inside: avoid !important; }
  .seat div { font-size: 9pt !important; line-height: 1.2 !important; margin: 0 !important; }
  .seat-status { font-size: 8pt !important; padding: 2px 6px !important; margin-top: 2px !important; border-radius: 10px !important; }
  .aisle-text { font-size: 9pt !important; letter-spacing: 2px !important; background: #f1f5f9 !important; }
  .room-bottom-426, .room-bottom-rinthong1 { margin-top: 6px !important; padding-top: 6px !important; gap: 8px !important; }
  .front-box-426, .teacher-desk-rinthong, .door-rinthong { padding: 4px !important; font-size: 9.5pt !important; height: unset !important; }
}

