/* -------------------------------------------------------
   Grundlayout & Reset
------------------------------------------------------- */

* {
  box-sizing: border-box;
}
html, body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

/* -------------------------------------------------------
   App-Container
------------------------------------------------------- */

.app {
  max-width: 900px;
  margin: 0 auto;
  
  height: 100dvh;
  min-height: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* -------------------------------------------------------
   Header
------------------------------------------------------- */

.app-header {
  text-align: center;
  padding-bottom: .25rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 600;
}

.subtitle {
  margin: .25rem 0 0;
  font-size: .9rem;
  color: #9ca3af;
}

/* -------------------------------------------------------
   Upload-Bereich
------------------------------------------------------- */

.upload-section {
  background: #020617;
  border-radius: .9rem;
  padding: 1rem;
}

.upload-grid {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 1rem;
  align-items: center;
}

.upload-left {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.upload-left h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.hint {
  margin: 0;
  font-size: .9rem;
  color: #cbd5f5;
}

.upload-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

#pdfInput {
  flex: 1;
  padding: .4rem;
  font-size: .85rem;
  color: #e5e7eb;
}

#uploadButton {
  border: none;
  border-radius: 999px;
  padding: .55rem 1.2rem;
  background: #22c55e;
  color: #022c22;
  font-weight: 600;
  cursor: pointer;
}

#uploadButton:disabled {
  opacity: .6;
  cursor: default;
}

/* Ergänzung: Infotext unter Upload */
.upload-info {
  margin: 0;
  font-size: .8rem;
  color: #94a3b8;
}

/* -------------------------------------------------------
   Upload-Bild
------------------------------------------------------- */

.upload-right {
  display: flex;
  justify-content: flex-end;
  padding-right: .75rem;
}

.upload-image {
  width: 100%;
  max-width: 300px;
  height: auto;
  border-radius: .8rem;
  background: #0b1220;
  object-fit: cover;
}

/* -------------------------------------------------------
   Chat-Bereich
------------------------------------------------------- */

.chat-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.chat-window {
  flex: 1;
  min-height: 0;  
  overflow-y: auto;
  overflow-x: hidden;
  padding: .75rem;
  border-radius: .9rem;
  background: #020617;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

/* -------------------------------------------------------
   Chat-Nachrichten
------------------------------------------------------- */

.message {
  max-width: 78%;
  padding: .55rem .75rem;
  border-radius: .75rem;
  font-size: .9rem;
  line-height: 1.4;
}

.message.user {
  align-self: flex-end;
  background: #3b82f6;
  color: #eff6ff;
  border-bottom-right-radius: .15rem;
}

.message.bot {
  align-self: flex-start;
  background: #111827;
  color: #e5e7eb;
  border-bottom-left-radius: .15rem;
}

/* -------------------------------------------------------
   Eingabezeile
------------------------------------------------------- */

.chat-input-row {
  display: flex;
  gap: .5rem;
}

#messageInput {
  flex: 1;
  padding: .65rem .8rem;
  border-radius: 999px;
  border: none;
  background: #020617;
  color: #e5e7eb;
  font-size: .9rem;
}

#messageInput::placeholder {
  color: #94a3b8;
}

#sendButton {
  border: none;
  border-radius: 999px;
  padding: .65rem 1.3rem;
  background: #22c55e;
  color: #022c22;
  font-weight: 600;
  cursor: pointer;
}

#sendButton:disabled {
  opacity: .6;
  cursor: default;
}

/* -------------------------------------------------------
   Responsive Anpassungen
------------------------------------------------------- */
@media (max-width: 700px) {
  body {
    overflow: auto;     /* Mobile: Seite darf scrollen */
  }

  .app {
    height: auto;       /* nicht mehr fest einklemmen */
    min-height: 100dvh; /* aber mindestens Bildschirmhöhe */
  }
}

@media (max-width: 700px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .upload-right {
    justify-content: flex-start;
  }

  .upload-image {
    max-width: 100%;
  }

  .message {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  .app {
    padding: .75rem;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }

  .hint {
    font-size: .85rem;
  }
}

/* -------------------------------------------------------
   Drag & Drop Upload
------------------------------------------------------- */

.drop-zone {
  transition: border-color .2s ease, background .2s ease;
}

.drop-zone.dragover {
  border: 2px dashed #22c55e;
  background: rgba(34, 197, 94, 0.05);
}

/* Anzeige des topic */
.topic-badge{
  margin: .25rem 0 0;
  padding: .4rem .65rem;
  border-radius: 999px;
  display: inline-block;
  font-size: .8rem;
  color: #dbeafe;
  background: rgba(59,130,246,0.18);
  border: 1px solid rgba(59,130,246,0.35);
}
.topic-badge span{
  font-weight: 600;
}

/* -------------------------------------------------------
   Header Status + Reset Button
------------------------------------------------------- */

.header-row {
  margin-top: .5rem;
  display: flex;
  gap: .5rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .65rem;
  border-radius: 999px;
  font-size: .8rem;
  color: #e5e7eb;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.status-badge.done {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #dcfce7;
}

.secondary-btn {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.08);
  color: #e5e7eb;
  border-radius: 999px;
  padding: .5rem .9rem;
  cursor: pointer;
  font-weight: 600;
}

.secondary-btn:hover {
  background: rgba(148, 163, 184, 0.14);
}

#messageInput.locked {
  opacity: .7;
}
