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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 50%, #90caf9 100%);
  min-height: 100vh;
  color: #263238;
  position: relative;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

/* 黒板と教壇 */
.classroom-front {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto 20px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.blackboard {
  background: linear-gradient(180deg, #2d5016 0%, #1a3d0a 100%);
  border: 8px solid #8B6914;
  border-radius: 8px;
  height: 90px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e8e8e8;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 2px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.podium {
  background: linear-gradient(180deg, #a0826d 0%, #8b6f5c 100%);
  border: 2px solid #6d5a4a;
  width: 100px;
  height: 70px;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  position: relative;
}

.podium::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 3px;
  background: #5a4a3a;
  border-radius: 2px;
}

.podium::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: #5a4a3a;
}

/* 凡例 */
.legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
  padding: 15px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #263238;
}

.legend-color {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid #ddd;
}

.legend-color.available {
  background: #e0e0e0;
  border-color: #bbb;
}

.legend-color.occupied {
  background: #ff9800;
  border-color: #ff9800;
}

.legend-color.my-seat {
  background: #4caf50;
  border-color: #4caf50;
}

/* ログインページ */
.login-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  max-width: 400px;
  margin: 100px auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-card h1 {
  margin-bottom: 10px;
  color: #1976d2;
}

.subtitle {
  color: #666;
  margin-bottom: 30px;
}

.error {
  background: #fee;
  color: #c33;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 20px;
}

.error.hidden {
  display: none;
}

.g_id_signin {
  margin: 20px auto;
  display: flex;
  justify-content: center;
  width: 100%;
}

.g_id_signin > div {
  width: 100% !important;
  max-width: 400px;
}

.g_id_signin iframe {
  width: 100% !important;
  min-width: 300px !important;
}

.info {
  margin-top: 20px;
  font-size: 14px;
  color: #666;
}

/* ダッシュボード */
header {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

#user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

#user-name {
  font-weight: 600;
  flex: 1;
}

#user-email {
  color: #666;
  font-size: 14px;
}

#logout-btn {
  background: #f44336;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#logout-btn:hover {
  background: #d32f2f;
}

main {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

h1 {
  color: #1976d2;
  margin-bottom: 10px;
}

.current-time {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: #1976d2;
  margin-bottom: 20px;
  padding: 12px;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-family: 'Courier New', Consolas, monospace;
  letter-spacing: 1px;
}

h2 {
  color: #555;
  margin-top: 30px;
  margin-bottom: 15px;
  font-size: 20px;
}

section {
  margin-bottom: 40px;
}

/* 講義情報 */
.lecture-info {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
}

#lecture-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

#lecture-date {
  color: #666;
  margin-top: 5px;
}

.current-registration {
  margin-top: 15px;
  padding: 15px;
  background: #e8f5e9;
  border-radius: 8px;
  border: 2px solid #4caf50;
}

.current-registration p {
  margin: 0 0 10px 0;
  color: #2e7d32;
  font-size: 16px;
}

#registered-seat {
  font-weight: 700;
  font-size: 18px;
  color: #1b5e20;
}

.cancel-btn {
  background: #f44336;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.cancel-btn:hover {
  background: #d32f2f;
}

/* 登録状況 */
.registration-status {
  margin-top: 15px;
  padding: 12px;
  border-radius: 6px;
  font-weight: 600;
  text-align: center;
}

.registration-status.available {
  background: #d4edda;
  color: #155724;
  border: 2px solid #28a745;
}

.registration-status.before {
  background: #fff3cd;
  color: #856404;
  border: 2px solid #ffc107;
}

.registration-status.closed {
  background: #f8d7da;
  color: #721c24;
  border: 2px solid #dc3545;
}

/* 座席マップ */
.seat-map {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.section {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
}

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

.section-front {
  background: #f0f4ff;
}

.section-front .blocks-container {
  display: flex;
  justify-content: safe center;
  gap: 25px;
  overflow-x: auto;
  padding: 10px;
}

.section-rear {
  background: #fff4f0;
}

.section-rear .blocks-container {
  display: flex;
  justify-content: safe center;
  gap: 25px;
  overflow-x: auto;
  padding: 10px;
}

.block {
  margin-bottom: 0;
  min-width: 0;
  flex-shrink: 0;
}

.block h4 {
  color: #555;
  margin-bottom: 8px;
  font-size: 14px;
  text-align: center;
}

.seat-grid {
  display: grid;
  gap: 4px;
  width: 100%;
}

.seat {
  width: 38px;
  height: 38px;
  border: 2px solid #bbb;
  border-radius: 4px;
  background: #e0e0e0;
  color: #333;
  cursor: pointer;
  font-size: 8px;
  font-weight: 600;
  transition: all 0.2s;
  padding: 0;
  flex-shrink: 0;
}

.seat.available {
  background: #e0e0e0;
  color: #333;
  border-color: #bbb;
}

.seat.available:hover {
  background: #d0d0d0;
  border-color: #999;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.seat.occupied {
  background: #ff9800;
  color: white;
  border-color: #ff9800;
  cursor: not-allowed;
}

.seat.my-seat {
  background: #4caf50;
  color: white;
  border-color: #4caf50;
  cursor: pointer;
}

.seat.my-seat:hover {
  background: #45a049;
  border-color: #388e3c;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}

.seat.unavailable {
  background: #f5f5f5;
  color: #ccc;
  border-color: #e0e0e0;
  cursor: not-allowed;
}

/* 出席履歴 */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

thead {
  background: #1976d2;
  color: white;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

tbody tr:hover {
  background: #f8f9fa;
}

/* レスポンシブ */
@media (max-width: 1400px) {
  .section-front .blocks-container,
  .section-rear .blocks-container {
    gap: 10px;
  }

  .seat-grid {
    gap: 3px;
  }

  .seat {
    max-width: 38px;
    max-height: 38px;
    font-size: 8px;
  }
}

@media (max-width: 1200px) {
  .seat {
    max-width: 35px;
    max-height: 35px;
    font-size: 7px;
  }

  .block h4 {
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .login-card {
    padding: 20px;
    margin: 50px auto;
  }

  .user-info {
    flex-wrap: wrap;
  }

  .classroom-front {
    margin-bottom: 15px;
  }

  .blackboard {
    height: 70px;
    font-size: 16px;
    max-width: 400px;
  }

  .podium {
    width: 80px;
    height: 60px;
  }

  .legend {
    gap: 15px;
    padding: 12px;
  }

  .legend-item {
    font-size: 13px;
  }

  .legend-color {
    width: 20px;
    height: 20px;
  }

  .section-front .blocks-container,
  .section-rear .blocks-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  .seat {
    max-width: 40px;
    max-height: 40px;
    font-size: 9px;
  }

  table {
    font-size: 14px;
  }

  th, td {
    padding: 8px;
  }
}

/* モーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

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

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

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

.modal-overlay .modal,
.modal-content {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 450px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
  position: relative;
}

/* 座席配置図のモーダル用オーバーレイ */
#seat-info-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

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

.modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.modal-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #1976d2 0%, #42a5f5 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
  font-size: 32px;
  color: white;
}

.modal-title {
  font-size: 22px;
  font-weight: 600;
  color: #263238;
  margin: 0 0 8px 0;
}

.modal-subtitle {
  font-size: 14px;
  color: #666;
  margin: 0;
}

.modal-body {
  margin-bottom: 24px;
}

.modal-info {
  background: #f5f5f5;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.modal-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

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

.modal-info-label {
  font-size: 14px;
  color: #666;
}

.modal-info-value {
  font-size: 16px;
  font-weight: 600;
  color: #263238;
}

.modal-seat-code {
  display: inline-block;
  background: #1976d2;
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 18px;
}

.modal-warning {
  background: #fff3e0;
  border-left: 4px solid #ff9800;
  padding: 12px;
  border-radius: 4px;
  font-size: 14px;
  color: #e65100;
  margin-top: 16px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-secondary {
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.modal-btn {
  flex: 1;
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-btn-cancel {
  background: #f5f5f5;
  color: #666;
}

.modal-btn-cancel:hover {
  background: #e0e0e0;
}

.modal-btn-confirm {
  background: #1976d2;
  color: white;
}

.modal-btn-confirm:hover {
  background: #1565c0;
}

.modal-btn-change {
  background: #ff9800;
  color: white;
}

.modal-btn-change:hover {
  background: #f57c00;
}

/* 管理画面 */
.admin-stats, .admin-attendance {
  margin-bottom: 40px;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
}

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

.filter-controls select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  min-width: 200px;
}

.export-btn {
  background: #4caf50;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  margin-left: auto;
}

.export-btn:hover {
  background: #45a049;
}

#back-btn {
  background: #2196f3;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin-right: 10px;
}

#back-btn:hover {
  background: #1976d2;
}

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

.stat-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  transition: all 0.2s;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
  color: #1976d2;
  margin-bottom: 10px;
  font-size: 16px;
}

.stat-card .date {
  color: #666;
  font-size: 14px;
  margin-bottom: 10px;
}

.stat-card .count {
  font-size: 32px;
  font-weight: 700;
  color: #4caf50;
}

.stat-card .label {
  color: #888;
  font-size: 14px;
}

/* 座席配置図 */
.lecture-selector {
  margin-bottom: 30px;
}

#seat-view-section .container {
  max-width: 100%;
}

.seat-map-view {
  width: 100%;
  max-width: none;
}

.seat-map-view .seat {
  width: 38px;
  height: 38px;
  font-size: 10px;
  line-height: 1.3;
  padding: 4px 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

.seat-map-view .seat.occupied {
  background: #4caf50;
  color: white;
  border-color: #4caf50;
}

.seat-map-view .seat.occupied .seat-code {
  font-weight: bold;
  margin-bottom: 2px;
  font-size: 10px;
}

.seat-map-view .seat.occupied .student-id {
  font-size: 9px;
  opacity: 0.9;
  margin-bottom: 1px;
}

.seat-map-view .seat.occupied .student-name {
  font-size: 10px;
  opacity: 0.9;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.seat-map-view .seat.available {
  background: #e0e0e0;
  color: #999;
  border-color: #ccc;
}

.seat-map-view .seat.available .seat-code {
  font-size: 11px;
}

.seat-map-view .seat-grid {
  gap: 6px;
}

.seat-map-view .blocks-container {
  display: flex;
  justify-content: safe center;
  gap: 25px;
  overflow-x: auto;
  padding: 10px;
}

.seat-map-view .block {
  flex-shrink: 0;
}

/* 座席ホバー時のツールチップ */
.seat-map-view .seat {
  position: relative;
  cursor: pointer;
}

.seat-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.95);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  white-space: normal;
  line-height: 1.8;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, bottom 0.3s;
  z-index: 10000;
  min-width: 200px;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  font-weight: normal;
}

.seat-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.95);
}

.seat-tooltip.show {
  opacity: 1;
  visibility: visible;
  bottom: calc(100% + 8px);
}

.seat-tooltip-row {
  margin-bottom: 4px;
}

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

.seat-tooltip-label {
  color: #aaa;
  font-size: 11px;
  margin-right: 8px;
}

.seat-tooltip-value {
  color: white;
  font-weight: 500;
}

/* レスポンシブ対応（座席配置図） */
@media (max-width: 1400px) {
  .seat-map-view .seat {
    min-width: 45px;
    min-height: 45px;
    max-width: 60px;
    max-height: 60px;
  }

  .seat-map-view .seat.occupied .seat-code {
    font-size: 9px;
  }

  .seat-map-view .seat.occupied .student-id {
    font-size: 8px;
  }

  .seat-map-view .seat.occupied .student-name {
    font-size: 9px;
  }
}

@media (max-width: 1200px) {
  .seat-map-view .blocks-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .seat-map-view .seat {
    min-width: 50px;
    min-height: 50px;
    max-width: 65px;
    max-height: 65px;
  }
}

@media (max-width: 768px) {
  .seat-map-view .blocks-container {
    grid-template-columns: 1fr;
  }

  .seat-map-view .seat {
    min-width: 45px;
    min-height: 45px;
    max-width: 60px;
    max-height: 60px;
  }

  .seat-map-view .seat.occupied::after {
    font-size: 12px;
    padding: 10px 14px;
    min-width: 180px;
  }
}

@media (max-width: 480px) {
  .blackboard {
    height: 60px;
    font-size: 14px;
    max-width: 300px;
  }

  .podium {
    width: 60px;
    height: 50px;
  }

  .legend {
    gap: 10px;
    padding: 10px;
  }

  .legend-item {
    font-size: 12px;
    gap: 6px;
  }

  .legend-color {
    width: 18px;
    height: 18px;
  }

  .section-front .blocks-container,
  .section-rear .blocks-container {
    grid-template-columns: 1fr;
  }

  header {
    padding: 15px;
  }

  main {
    padding: 20px;
  }

  .modal {
    padding: 24px;
    width: 95%;
  }

  .modal-icon {
    width: 56px;
    height: 56px;
    font-size: 28px;
  }

  .modal-title {
    font-size: 20px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-btn {
    width: 100%;
  }
}