/* ===== SCHOOL PORTAL STYLES ===== */

/* Variables (same as lp.css) */
:root {
  --orange: #ff5d00;
  --orange-light: #ff8945;
  --orange-pale: #fff4ed;
  --dark: #1a1a1a;
  --gray: #666;
  --gray-light: #999;
  --gray-bg: #f7f7f7;
  --white: #fff;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.12);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== BASE ===== */
.school-body {
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--dark);
  line-height: 1.8;
  background: var(--gray-bg);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ===== SCHOOL HEADER ===== */
.school-header {
  background: var(--white);
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 100;
}

.school-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.school-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.school-logo .logo-text {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--dark);
}

.school-logo .logo-text .dot {
  color: var(--orange);
}

.school-logo .logo-badge {
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--orange);
  color: var(--white);
  padding: 3px 10px;
  border-radius: 4px;
}

.school-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.school-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--dark);
}

.school-logout-btn {
  font-size: 13px;
  color: var(--gray);
  text-decoration: none;
  padding: 6px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  transition: var(--transition);
}

.school-logout-btn:hover {
  color: var(--orange);
  border-color: var(--orange);
}

/* ===== SCHOOL MAIN ===== */
.school-main {
  padding: 40px 0 80px;
}

.school-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== WELCOME SECTION ===== */
.school-welcome {
  margin-bottom: 48px;
}

.school-welcome h1 {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 8px;
}

.school-welcome p {
  font-size: 15px;
  color: var(--gray);
  max-width: 640px;
}

/* ===== SECTION TITLE ===== */
.school-section-title {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 32px;
}

.school-section-label {
  display: block;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--orange);
  margin-bottom: 4px;
}

/* ===== LESSON GRID (DASHBOARD) ===== */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.lesson-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-decoration: none;
  color: var(--dark);
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
}

.lesson-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--orange);
}

.lesson-card-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.lesson-card-day {
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--orange);
  margin-bottom: 6px;
}

.lesson-card-title {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 6px;
  line-height: 1.4;
}

.lesson-card-desc {
  font-size: 13px;
  color: var(--gray);
  line-height: 1.6;
  flex: 1;
}

.lesson-card-arrow {
  position: absolute;
  top: 28px;
  right: 24px;
  font-size: 18px;
  color: var(--gray-light);
  transition: var(--transition);
}

.lesson-card:hover .lesson-card-arrow {
  color: var(--orange);
  transform: translateX(4px);
}

/* ===== LESSON PAGE ===== */
.lesson-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Breadcrumb */
.lesson-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-light);
  margin-bottom: 32px;
}

.lesson-breadcrumb a {
  color: var(--gray);
  text-decoration: none;
  transition: var(--transition);
}

.lesson-breadcrumb a:hover {
  color: var(--orange);
}

.lesson-breadcrumb-sep {
  color: #ddd;
}

/* Lesson Header */
.lesson-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 40px;
  padding: 32px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.lesson-header-icon {
  font-size: 48px;
  line-height: 1;
}

.lesson-header-day {
  display: inline-block;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--orange);
  background: var(--orange-pale);
  padding: 4px 12px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.lesson-header-title {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 6px;
  line-height: 1.4;
}

.lesson-header-desc {
  font-size: 14px;
  color: var(--gray);
  margin: 0;
}

/* Lesson Article */
.lesson-article {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  box-shadow: var(--shadow);
  margin-bottom: 40px;
}

.lesson-content h2 {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--orange-pale);
}

.lesson-content h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 32px 0 12px;
  padding-left: 12px;
  border-left: 4px solid var(--orange);
}

.lesson-content p {
  font-size: 15px;
  color: var(--gray);
  line-height: 1.9;
  margin-bottom: 16px;
}

.lesson-content ul,
.lesson-content ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.lesson-content li {
  font-size: 15px;
  color: var(--gray);
  line-height: 1.9;
  margin-bottom: 6px;
  list-style: disc;
}

.lesson-content ol li {
  list-style: decimal;
}

.lesson-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 24px 0;
}

.lesson-content code {
  background: var(--gray-bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 14px;
}

.lesson-content pre {
  background: var(--dark);
  color: #e0e0e0;
  padding: 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 24px 0;
}

.lesson-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.lesson-content blockquote {
  border-left: 4px solid var(--orange);
  padding: 16px 20px;
  background: var(--orange-pale);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 24px 0;
}

.lesson-content blockquote p {
  color: var(--dark);
  margin: 0;
}

/* Lesson Navigation */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.lesson-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--dark);
  transition: var(--transition);
  max-width: 48%;
}

.lesson-nav-btn:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.lesson-nav-prev {
  text-align: left;
}

.lesson-nav-next {
  text-align: right;
  margin-left: auto;
}

.lesson-nav-arrow {
  font-size: 20px;
  color: var(--orange);
  font-weight: 700;
}

.lesson-nav-label {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.lesson-nav-label small {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-light);
  letter-spacing: 0.02em;
}

/* Back link */
.lesson-back {
  text-align: center;
  padding-top: 16px;
}

.lesson-back a {
  font-size: 14px;
  color: var(--gray);
  text-decoration: none;
  transition: var(--transition);
}

.lesson-back a:hover {
  color: var(--orange);
}

/* ===== CHAT WIDGET ===== */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  color: var(--white);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 93, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 200;
}

.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(255, 93, 0, 0.5);
}

.chat-fab.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Chat Panel */
.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 201;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  color: var(--white);
}

.chat-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}

.chat-panel-title small {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.8;
}

.chat-ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: chatPulse 2s infinite;
}

@keyframes chatPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chat-panel-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.chat-panel-close:hover {
  opacity: 1;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  display: flex;
  max-width: 85%;
}

.chat-message--ai {
  align-self: flex-start;
}

.chat-message--user {
  align-self: flex-end;
}

.chat-message-content {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.chat-message--ai .chat-message-content {
  background: var(--gray-bg);
  color: var(--dark);
  border-bottom-left-radius: 4px;
}

.chat-message--user .chat-message-content {
  background: var(--orange);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--gray-bg);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.chat-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-light);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Form */
.chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Noto Sans JP', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: var(--orange);
}

.chat-input::placeholder {
  color: #bbb;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 8px;
  background: var(--orange);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.chat-send-btn:hover {
  background: var(--orange-light);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .school-welcome h1 {
    font-size: 22px;
  }

  .school-user-name {
    display: none;
  }

  .lesson-header {
    flex-direction: column;
    padding: 24px;
  }

  .lesson-header-title {
    font-size: 22px;
  }

  .lesson-article {
    padding: 32px 20px;
  }

  .lesson-nav {
    flex-direction: column;
  }

  .lesson-nav-btn {
    max-width: 100%;
  }

  .lesson-nav-next {
    margin-left: 0;
  }

  /* Chat panel mobile */
  .chat-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 70vh;
    border-radius: 16px 16px 0 0;
  }
}

@media (max-width: 480px) {
  .school-header-inner {
    padding: 0 16px;
  }

  .school-container,
  .lesson-container {
    padding: 0 16px;
  }

  .lesson-card {
    padding: 20px 18px;
  }

  .lesson-card-title {
    font-size: 16px;
  }

  .school-section-title {
    font-size: 20px;
  }

  .lesson-header-icon {
    font-size: 36px;
  }

  .lesson-content h2 {
    font-size: 19px;
  }
}
