/* ========== CSS Variables & Reset ========== */
:root {
  --primary: #4F46E5;
  --primary-light: #818CF8;
  --primary-dark: #3730A3;
  --primary-bg: #EEF2FF;
  --accent: #F59E0B;
  --accent-light: #FEF3C7;
  --success: #10B981;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-light: #94A3B8;
  --bg: #F1F5F9;
  --card-bg: #FFFFFF;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 25px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --transition: all 0.25s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  line-height: 1.6;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ========== Header ========== */
.header {
  height: 56px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 10px; }

.header-logo {
  width: 32px; height: 32px;
  display: flex;
  align-items: center; justify-content: center;
}
.header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header-title {
  font-size: 16px; font-weight: 700;
  color: var(--text);
}

.header-subtitle {
  font-size: 12px; color: var(--text-light);
  margin-left: 10px; padding-left: 10px;
  border-left: 1px solid var(--border);
}

.header-right {
  display: flex; align-items: center; gap: 12px;
  font-size: 12px; color: var(--text-secondary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--primary-bg);
  border-radius: 20px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.user-name {
  font-weight: 500;
  color: var(--text);
}

.header-badge {
  padding: 3px 10px; background: var(--primary-bg);
  color: var(--primary); border-radius: 12px;
  font-weight: 600; font-size: 11px;
}

/* ========== Main Layout ========== */
.app-container {
  display: flex;
  height: calc(100vh - 56px);
}

/* ========== Left Panel ========== */
.left-panel {
  width: 560px;
  min-width: 560px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 14px; font-weight: 700;
  color: var(--text);
}

.panel-header p {
  font-size: 11px; color: var(--text-light);
  margin-top: 2px;
}

/* Chat Messages Area */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F8FAFC;
}

.chat-message {
  display: flex;
  gap: 8px;
  max-width: 100%;
  animation: msgIn 0.3s ease-out;
}

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

.chat-message.bot { align-self: flex-start; }
.chat-message.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.chat-avatar.bot {
  background: var(--primary);
  color: white;
}

.chat-avatar.user {
  background: #94A3B8;
  color: white;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.65;
  max-width: calc(100% - 42px);
}

.chat-message.bot .chat-bubble {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

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

.chat-bubble h2 { font-size: 14px; margin: 6px 0 3px; }
.chat-bubble h3 { font-size: 13px; margin: 5px 0 2px; }
.chat-bubble p { margin: 3px 0; }
.chat-bubble hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.chat-bubble strong { font-weight: 600; }
.chat-bubble blockquote {
  border-left: 3px solid var(--primary-light);
  padding-left: 10px; margin: 6px 0; color: var(--text-secondary);
  font-size: 12px;
}

/* Quick reply buttons */
.quick-replies {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 2px 0;
}

.quick-reply-btn {
  padding: 6px 14px; border: 1.5px solid var(--primary-light);
  background: white; color: var(--primary);
  border-radius: 16px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}

.quick-reply-btn:hover {
  background: var(--primary); color: white; border-color: var(--primary);
}

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 3px; padding: 4px 0;
}
.typing-indicator span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-light);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Chat Input */
.chat-input-area {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex; gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  background: #F8FAFC;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.chat-input:focus {
  border-color: var(--primary-light);
  background: white;
}

.chat-send-btn {
  width: 34px; height: 34px;
  border: none; background: var(--primary);
  color: white; border-radius: 50%;
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--primary-dark); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Chat status bar */
.chat-status {
  font-size: 11px; color: var(--text-light);
  text-align: center; padding: 4px 0 2px;
}

/* ========== Right Panel ========== */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== Right Top - Document Viewer ========== */
.right-top {
  flex: 0.7;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 10px 22px 6px;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.doc-header h2 {
  font-size: 15px; font-weight: 700;
  color: var(--text);
}

.doc-counter {
  font-size: 12px; color: var(--text-light);
}

.doc-layout {
  display: flex;
  gap: 14px;
  flex: 1;
  overflow: hidden;
}

/* Document sidebar - school list */
.doc-sidebar {
  width: 130px;
  min-width: 130px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.doc-item:hover {
  background: var(--primary-bg);
}

.doc-item.active {
  background: var(--primary-bg);
  border-left-color: var(--primary);
}

.doc-item-name {
  font-size: 12px; font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.doc-item-meta {
  font-size: 10px; color: var(--text-light);
  margin-top: 2px;
}

.doc-item-score {
  font-size: 10px; color: var(--text-secondary);
  margin-top: 2px;
}

/* Document content area */
.doc-content {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
}

.doc-school-name {
  font-size: 20px; font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.doc-school-sub {
  font-size: 13px; color: var(--text-light);
  margin-bottom: 12px;
}

.doc-tags {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 14px;
}

.doc-tag {
  font-size: 11px; background: var(--primary-bg);
  color: var(--primary); padding: 2px 10px;
  border-radius: 10px; font-weight: 500;
}

.doc-ratings {
  display: flex; gap: 20px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #F8FAFC;
  border-radius: var(--radius-sm);
}

.doc-rating-item {
  font-size: 13px;
}

.doc-rating-item .label {
  color: var(--text-secondary);
  font-weight: 500;
}

.doc-rating-item .stars {
  color: var(--accent);
  letter-spacing: -1px;
}

.doc-rating-item .num {
  color: var(--text-secondary);
  font-size: 12px;
}

.doc-section {
  margin-bottom: 18px;
}

.doc-section:last-child { margin-bottom: 0; }

.doc-section-title {
  font-size: 14px; font-weight: 700;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-bg);
}

.doc-section p {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.8;
}

.doc-score-box {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px;
  padding: 8px 16px;
  background: #F0FDF4;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  color: #166534;
}

.doc-score-box .badge {
  background: white; padding: 1px 10px;
  border-radius: 8px; color: var(--primary);
  font-weight: 700;
}

.doc-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; color: var(--text-light);
  font-size: 14px; gap: 10px;
}

.doc-empty-icon { font-size: 40px; opacity: 0.4; }

/* ========== Right Bottom - Carousel ========== */
.right-bottom {
  flex: 1.8;
  border-top: 1px solid var(--border);
  padding: 10px 22px 12px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
}

.carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.carousel-header-left {
  display: flex; align-items: center; gap: 12px;
}

.carousel-header h3 {
  font-size: 13px; font-weight: 600;
  color: var(--text);
}

.carousel-tabs {
  display: flex; gap: 4px;
  background: var(--bg);
  border-radius: 16px;
  padding: 2px;
}

.carousel-tab {
  padding: 4px 12px;
  border: none; background: transparent;
  border-radius: 14px; font-size: 11px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  color: var(--text-secondary);
}

.carousel-tab.active {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.carousel-indicators {
  display: flex; gap: 5px;
}

.carousel-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer; transition: var(--transition);
}

.carousel-dot.active {
  background: var(--primary);
  width: 18px;
  border-radius: 3px;
}

.carousel-viewport {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  flex: 1;
  min-height: 0;
}

.carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-slide {
  min-width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
}

.carousel-slide.hero-layout {
  grid-template-rows: 1fr 1fr;
}

.carousel-slide.hero-layout .carousel-image.hero-image {
  grid-column: 1 / -1;
}

.carousel-slide.single-image {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.carousel-image {
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 500;
  font-size: 13px;
  color: white;
  position: relative;
  transition: var(--transition);
}

.carousel-image:hover {
  transform: scale(1.02);
}

.carousel-image.has-bg {
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff;
  position: relative;
}
.carousel-image.has-bg .img-label,
.carousel-image.has-bg .img-sub {
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
  color: #fff;
}
.carousel-image.has-bg .img-label {
  font-size: 14px;
  font-weight: 600;
}
.carousel-img-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 55%, rgba(0,0,0,0.65));
  z-index: 1;
  pointer-events: none;
  border-radius: var(--radius-sm);
}

.carousel-image .img-icon { font-size: 28px; opacity: 0.9; }
.carousel-image .img-sub { font-size: 10px; opacity: 0.8; font-weight: 400; }

.carousel-image.c1 { background: linear-gradient(135deg, #4F46E5, #7C3AED); }
.carousel-image.c2 { background: linear-gradient(135deg, #0891B2, #06B6D4); }
.carousel-image.c3 { background: linear-gradient(135deg, #059669, #10B981); }
.carousel-image.c4 { background: linear-gradient(135deg, #D97706, #F59E0B); }
.carousel-image.c5 { background: linear-gradient(135deg, #DC2626, #F97316); }
.carousel-image.c6 { background: linear-gradient(135deg, #7C3AED, #A855F7); }
.carousel-image.c7 { background: linear-gradient(135deg, #0369A1, #0EA5E9); }
.carousel-image.c8 { background: linear-gradient(135deg, #BE185D, #EC4899); }

.carousel-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: none;
  background: rgba(255,255,255,0.85);
  border-radius: 50%; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); box-shadow: var(--shadow);
  transition: var(--transition); z-index: 5;
  opacity: 0;
}

.carousel-viewport:hover .carousel-btn { opacity: 1; }
.carousel-btn:hover { background: white; transform: translateY(-50%) scale(1.08); }
.carousel-btn.prev { left: 8px; }
.carousel-btn.next { right: 8px; }

/* ========== Lightbox (Fullscreen Image Viewer) ========== */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}
.lightbox-overlay.active {
  opacity: 1;
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 36px;
  color: #fff;
  cursor: pointer;
  z-index: 10;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  transition: background 0.2s;
  line-height: 1;
}
.lightbox-close:hover {
  background: rgba(255,255,255,0.2);
}
.lightbox-image {
  max-width: 92vw;
  max-height: 84vh;
  width: 100%;
  height: 100%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  cursor: default;
}
.lightbox-label {
  color: #fff;
  font-size: 15px;
  margin-top: 16px;
  opacity: 0.8;
  font-weight: 500;
}

/* ========== Responsive ========== */
@media (max-width: 900px) {
  .app-container { flex-direction: column; overflow-y: auto; }
  .left-panel { width: 100%; min-width: auto; max-height: 400px; }
  .right-panel { height: auto; }
  .doc-layout { flex-direction: column; }
  .doc-sidebar { width: 100%; min-width: auto; flex-direction: row; overflow-x: auto; }
  .doc-sidebar .doc-item { min-width: 120px; }
}
