/* --------------------------------------------------------------------------
   IR Lens Global Styling & Reset
   -------------------------------------------------------------------------- */

:root {
  /* Color Palette - HSL Tailored */
  --bg-color: #0b0c10;
  --bg-card: rgba(18, 22, 33, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-main: #f0f2f5;
  --text-muted: #9fa6b2;
  
  /* Accent Colors */
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  
  /* Theory Specific Accent Colors */
  --color-realism: hsl(354, 75%, 56%);
  --color-realism-bg: rgba(239, 68, 68, 0.15);
  
  --color-liberalism: hsl(168, 76%, 42%);
  --color-liberalism-bg: rgba(16, 185, 129, 0.15);
  
  --color-constructivism: hsl(263, 70%, 63%);
  --color-constructivism-bg: rgba(168, 85, 247, 0.15);
  
  --color-structuralism: hsl(38, 92%, 52%);
  --color-structuralism-bg: rgba(245, 158, 11, 0.15);
  
  /* Layout Configurations */
  --max-width: 1400px;
  --border-radius-lg: 20px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: 'Noto Sans KR', 'Outfit', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* --------------------------------------------------------------------------
   Dynamic Glowing Backgrounds
   -------------------------------------------------------------------------- */

.glow-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.glow-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.15;
  animation: pulse-bg 15s infinite alternate ease-in-out;
}

.glow-circle.blue {
  top: -10%;
  right: 10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 80%);
}

.glow-circle.purple {
  bottom: -10%;
  left: 5%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 80%);
  animation-delay: 3s;
}

.glow-circle.orange {
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, var(--color-structuralism) 0%, transparent 80%);
  opacity: 0.08;
  animation-delay: 6s;
}

@keyframes pulse-bg {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(50px, 30px) scale(1.15);
  }
}

/* --------------------------------------------------------------------------
   Layout Structure
   -------------------------------------------------------------------------- */

.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 24px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Warning Config Banner */
.warning-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius-md);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  color: #fca5a5;
  font-size: 0.95rem;
  animation: slideDown 0.4s ease-out;
}

.warning-banner.hidden {
  display: none;
}

.warning-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.warning-content i {
  font-size: 1.25rem;
  color: #ef4444;
}

.btn-warning-action {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-warning-action:hover {
  background: #dc2626;
  transform: translateY(-2px);
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Header */
.main-header {
  margin-bottom: 12px;
  text-align: center;
  position: relative;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.icon-lens {
  font-size: 2.2rem;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rotateGlow 8s infinite linear;
}

.logo h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo h1 span {
  background: linear-gradient(135deg, #60a5fa, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 300;
  margin-bottom: 12px;
}

.header-badges {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 50px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@keyframes rotateGlow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Main Grid Layout */
.grid-content {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0; /* Important for scroll containers inside grid */
}

/* Glassmorphism Card Utility */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: transform 0.3s, border-color 0.3s;
}

/* --------------------------------------------------------------------------
   Left Panel: Theories & Cases
   -------------------------------------------------------------------------- */

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  padding-right: 4px;
  height: 100%;
  max-height: 100%;
}

.section-title {
  margin-bottom: 8px;
}

.section-title h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Lenses Grid */
.lenses-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.lens-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lens-card:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.card-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
}

.lens-card.active {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
}

/* Dynamic Borders per Theory Active state */
#card-realism.active { border-color: var(--color-realism); }
#card-realism.active .card-glow { background: var(--color-realism); }
#card-liberalism.active { border-color: var(--color-liberalism); }
#card-liberalism.active .card-glow { background: var(--color-liberalism); }
#card-constructivism.active { border-color: var(--color-constructivism); }
#card-constructivism.active .card-glow { background: var(--color-constructivism); }
#card-structuralism.active { border-color: var(--color-structuralism); }
#card-structuralism.active .card-glow { background: var(--color-structuralism); }

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

.lens-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

/* Colored Icons */
.lens-icon.realism { background: var(--color-realism-bg); color: var(--color-realism); }
.lens-icon.liberalism { background: var(--color-liberalism-bg); color: var(--color-liberalism); }
.lens-icon.constructivism { background: var(--color-constructivism-bg); color: var(--color-constructivism); }
.lens-icon.structuralism { background: var(--color-structuralism-bg); color: var(--color-structuralism); }

.lens-name-en {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lens-card h4 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.lens-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.lens-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 8px;
}

/* Case Study Selector Chips */
.cases-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.case-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 50px;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.case-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.case-chip.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(168, 85, 247, 0.2));
  border-color: rgba(168, 85, 247, 0.4);
  color: #e9d5ff;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.1);
}

/* Info Preview Panel */
.info-preview {
  padding: 20px;
}

.margin-top {
  margin-top: 12px;
}

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

.badge-accent {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 50px;
  font-weight: 600;
  background: var(--color-realism-bg);
  color: var(--color-realism);
}

.info-header h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.info-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.info-details {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.82rem;
}

.detail-item strong {
  color: var(--text-main);
  display: inline-block;
  width: 90px;
}

.detail-item span {
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Right Panel: Chat UI
   -------------------------------------------------------------------------- */

.right-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.active-lens-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
}

.indicator-dot.active {
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.lens-indicator-badge {
  background: var(--color-realism-bg);
  color: var(--color-realism);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 8px;
  transition: all 0.3s;
}

.case-indicator-badge {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 4px;
}

.case-indicator-badge.hidden {
  display: none;
}

.btn-clear-chat {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.05rem;
  padding: 6px;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s;
}

.btn-clear-chat:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

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

.message {
  display: flex;
  gap: 16px;
  max-width: 85%;
  animation: messageAppear 0.3s ease-out;
}

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 75%;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.message.user .message-avatar {
  background: #475569;
  box-shadow: none;
}

.message-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-sender {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.message.user .message-sender {
  text-align: right;
}

.message-content {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  border-radius: 0 16px 16px 16px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-main);
}

.message.user .message-content {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none;
  border-radius: 16px 0 16px 16px;
  color: #fff;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.2);
}

/* Markdown styling inside Bot Messages */
.message-content p {
  margin-bottom: 10px;
}
.message-content p:last-child {
  margin-bottom: 0;
}
.message-content ul, .message-content ol {
  margin-left: 20px;
  margin-bottom: 12px;
}
.message-content li {
  margin-bottom: 4px;
}
.message-content strong {
  color: #fff;
  font-weight: 600;
}
.message.user .message-content strong {
  color: #fff;
}
.message-content blockquote {
  border-left: 4px solid var(--accent-purple);
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 16px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.message-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 15px 0;
}

/* Suggested Follow-up clickables inside chat response */
.message-content ul.follow-up-list {
  list-style: none !important;
  margin-left: 0 !important;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  padding-top: 12px;
}

.message-content li.follow-up-item {
  color: #a78bfa;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  transition: all 0.2s;
  padding: 4px 0;
}

.message-content li.follow-up-item:hover {
  color: #c084fc;
  transform: translateX(4px);
}

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

/* Typing Indicator Loader */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 6px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingGlow 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingGlow {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Quick Prompt Suggestion Box */
.quick-prompts-container {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-prompts {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.quick-prompts::-webkit-scrollbar {
  height: 4px;
}
.quick-prompts::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.quick-prompt-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 50px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.quick-prompt-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-blue);
  color: #60a5fa;
  transform: translateY(-1px);
}

/* Chat Input Bar */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

#user-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 12px 16px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: all 0.2s;
}

#user-input:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

#btn-send {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-md);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

#btn-send:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

#btn-send:active {
  transform: scale(0.96);
}

/* --------------------------------------------------------------------------
   Footer & Misc
   -------------------------------------------------------------------------- */

.app-footer {
  margin-top: 12px;
  text-align: center;
  padding: 8px 0;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .app-container {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 12px 16px;
  }

  .grid-content {
    grid-template-columns: 1fr;
    height: auto;
    gap: 20px;
  }
  
  .left-panel {
    max-height: none;
    height: auto;
    overflow-y: visible;
  }

  .right-panel {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .chat-container {
    height: 600px;
    max-height: none;
    min-height: unset;
  }
}
