/* AZ-Finanzen Bot — Stil angelehnt an az-finanzen.de Design-System */
:root {
  --az-primary: #3567A7;
  --az-primary-dark: #2A5690;
  --az-dark: #0D2137;
  --az-text: #333;
  --az-text-light: #4A5568;
  --az-accent: #D4A44C;
  --az-accent-hover: #C09438;
  --az-light: #F7F3ED;
  --az-beige: #E3DAC9;
  --az-border: #E2E8F0;
  --az-radius: 12px;
  --az-shadow: 0 4px 24px rgba(0,0,0,0.08);
  --az-shadow-soft: 0 2px 12px rgba(0,0,0,0.06);
  --az-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--az-font);
  color: var(--az-text);
  background: var(--az-light);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: 2px solid transparent;
  border-radius: 50px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
}
.btn-primary { background: var(--az-primary); color: #fff; border-color: var(--az-primary); }
.btn-primary:hover { background: var(--az-primary-dark); border-color: var(--az-primary-dark); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(53,103,167,0.25); }
.btn-block { width: 100%; }
.btn-send { padding: 0; width: 44px; height: 44px; font-size: 20px; flex: 0 0 44px; align-self: flex-end; }

/* --- Flash messages --- */
.flash-area { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1000; }
.flash { padding: 12px 20px; border-radius: var(--az-radius); margin-bottom: 8px; box-shadow: var(--az-shadow); font-size: 14px; }
.flash-error { background: #fff0f0; color: #b32424; border: 1px solid #f5c6c6; }
.flash-info { background: #eef4fb; color: var(--az-primary-dark); border: 1px solid #c8d8e9; }

/* --- Login --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: linear-gradient(135deg, var(--az-light) 0%, var(--az-beige) 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--az-radius);
  box-shadow: var(--az-shadow);
  padding: 40px 36px;
  text-align: center;
}
.login-logo { display: inline-block; margin-bottom: 24px; }
.login-logo img { height: 56px; width: auto; }
.login-card h1 { color: var(--az-dark); font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.login-sub { color: var(--az-text-light); font-size: 14px; margin: 0 0 28px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--az-dark); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--az-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  color: var(--az-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus { outline: 0; border-color: var(--az-primary); box-shadow: 0 0 0 3px rgba(53,103,167,0.15); }

/* --- Topbar (chat) --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--az-border);
  box-shadow: var(--az-shadow-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo { display: flex; align-items: center; }
.topbar-logo img { height: 40px; width: auto; max-width: 160px; object-fit: contain; }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--az-dark); padding-left: 16px; border-left: 1px solid var(--az-border); }
.topbar-logout { margin-left: auto; font-size: 14px; font-weight: 500; color: var(--az-text-light); text-decoration: none; padding: 8px 14px; border-radius: 8px; transition: all 0.2s; }
.topbar-logout:hover { color: var(--az-primary); background: #F4F7FA; }

/* --- Chat layout --- */
.layout { display: flex; height: calc(100vh - 64px); }
.sidebar {
  width: 280px;
  flex: 0 0 280px;
  background: #fff;
  border-right: 1px solid var(--az-border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.session-list { list-style: none; padding: 0; margin: 8px 0 0; flex: 1; overflow-y: auto; }
.session-list li { padding: 0; border-radius: 8px; transition: background 0.15s; margin-bottom: 2px; position: relative; display: flex; align-items: center; }
.session-list li .session-link { flex: 1; min-width: 0; padding: 10px 12px; color: var(--az-text); text-decoration: none; font-size: 14px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-list li:hover { background: var(--az-light); }
.session-list li.active { background: rgba(53,103,167,0.1); }
.session-list li.active .session-link { color: var(--az-primary); font-weight: 600; }
.session-menu-btn {
  background: none; border: 0; padding: 4px 8px; margin-right: 4px;
  font-size: 18px; line-height: 1; cursor: pointer; color: var(--az-text-light);
  border-radius: 4px; opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.session-list li:hover .session-menu-btn,
.session-list li.active .session-menu-btn { opacity: 0.7; }
.session-menu-btn:hover { opacity: 1 !important; background: rgba(0,0,0,0.05); }
.session-menu {
  position: absolute; top: 100%; right: 4px; z-index: 100;
  background: #fff; border: 1px solid var(--az-border); border-radius: 8px;
  box-shadow: var(--az-shadow); padding: 4px; min-width: 140px;
  display: flex; flex-direction: column; gap: 2px;
}
.session-menu[hidden] { display: none; }
.session-menu button {
  background: none; border: 0; padding: 8px 12px; text-align: left; font: inherit;
  font-size: 13px; color: var(--az-text); border-radius: 6px; cursor: pointer;
}
.session-menu button:hover { background: var(--az-light); }
.session-menu .session-action-delete { color: #b32424; }
.session-menu .session-action-delete:hover { background: #fff0f0; }

/* --- Main pane --- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--az-light);
  min-width: 0;
}
.main-header {
  padding: 16px 28px;
  border-bottom: 1px solid var(--az-border);
  background: #fff;
  font-size: 16px;
  font-weight: 600;
  color: var(--az-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}
.main-header .session-title { flex: 1; }
.rename-btn {
  background: none;
  border: 0;
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s;
}
.rename-btn:hover { opacity: 1; background: var(--az-light); }
.messages {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 14px;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.55;
  box-shadow: var(--az-shadow-soft);
}
.msg-user {
  align-self: flex-end;
  background: var(--az-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--az-text);
  border: 1px solid var(--az-border);
  border-bottom-left-radius: 4px;
}
.msg-assistant a { color: var(--az-primary); }
.msg-assistant code { background: var(--az-light); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.msg-assistant pre { background: var(--az-dark); color: #fff; padding: 12px 16px; border-radius: 8px; overflow-x: auto; }
.msg-assistant pre code { background: transparent; color: inherit; padding: 0; }
.msg-assistant img { max-width: 100%; max-height: 360px; border-radius: 8px; margin: 6px 0; box-shadow: var(--az-shadow-soft); display: block; cursor: zoom-in; transition: transform 0.15s ease; }
.msg-assistant img:hover { transform: scale(1.02); }

/* Lightbox-Overlay zum Vergrößern */
.lightbox { position: fixed; inset: 0; background: rgba(13,33,55,0.92); display: flex; align-items: center; justify-content: center; z-index: 1000; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 20px 80px rgba(0,0,0,0.6); }
.lightbox-close { position: absolute; top: 16px; right: 24px; color: #fff; font-size: 32px; font-weight: 300; line-height: 1; cursor: pointer; opacity: 0.7; transition: opacity 0.15s; user-select: none; }
.lightbox-close:hover { opacity: 1; }
.msg-status {
  align-self: flex-start;
  background: #FFF6E1;
  color: #876008;
  border: 1px solid #F0DCA0;
  font-size: 13px;
  font-weight: 500;
}
.msg-tool {
  align-self: flex-start;
  background: #ECF8F0;
  color: #1E6B36;
  border: 1px solid #BFE2C9;
  font-size: 13px;
}

.composer {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--az-border);
  background: #fff;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--az-border);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--az-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer textarea:focus { outline: 0; border-color: var(--az-primary); box-shadow: 0 0 0 3px rgba(53,103,167,0.12); }
.composer textarea.drag { background: #FFF8E6; border-color: var(--az-accent); box-shadow: 0 0 0 3px rgba(212,164,76,0.18); }

/* Upload-Button (Büroklammer) */
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 8px;
  cursor: pointer;
  align-self: flex-end;
  font-size: 20px;
  color: var(--az-text-light);
  transition: all 0.15s;
  user-select: none;
}
.upload-btn:hover { background: var(--az-light); color: var(--az-primary); }

/* --- Empty state --- */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--az-text-light);
}
.empty h2 { color: var(--az-dark); font-size: 26px; font-weight: 700; margin: 0 0 8px; }
.empty p { font-size: 16px; max-width: 480px; margin: 0; }
.empty strong { color: var(--az-primary); }

/* --- Mobile --- */
@media (max-width: 720px) {
  .topbar-title { display: none; }
  .layout { flex-direction: column; height: calc(100vh - 64px); }
  .sidebar { width: 100%; flex: 0 0 auto; max-height: 200px; border-right: 0; border-bottom: 1px solid var(--az-border); }
  .messages { padding: 16px; }
  .composer { padding: 12px 16px; }
  .msg { max-width: 90%; }
  .login-card { padding: 32px 24px; }
}
