/* =================================================================
   Fussball.de Chat – Stylesheet
   ================================================================= */

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

:root {
  /* SV Blau-Gelb Berlin — Blau & Gelb auf dunklem Grund */
  --bg:             #080e1c;
  --bg-card:        #0e1a30;
  --bg-input:       #152038;
  --border:         #1e3260;
  --accent:         #f5c400;   /* Vereinsgelb */
  --accent-hover:   #ffd433;
  --accent-dim:     #2a2000;
  --text:           #dde8f8;
  --text-muted:     #7a96c4;
  --text-subtle:    #3a5280;
  --user-bubble:    #0f3a8a;   /* Vereinsblau */
  --asst-bubble:    #0e1a30;
  --tool-badge-bg:  #152038;
  --tool-badge-fg:  #5a7ab0;
  --error-fg:       #f85149;
  --radius:         12px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --topbar-h:       52px;
  --inputbar-h:     80px;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); }

/* =================================================================
   App shell
   ================================================================= */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* =================================================================
   Top bar
   ================================================================= */

.topbar {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 30;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }

.logo { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--bg-input); color: var(--text); border-color: var(--text-subtle); }

/* =================================================================
   Sessions panel + overlay
   ================================================================= */

.sessions-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 40;
}
.sessions-overlay.open { display: block; }

.sessions-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.sessions-panel.open { transform: translateX(0); }

.sessions-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  flex-shrink: 0;
}

.sessions-list { flex: 1; overflow-y: auto; padding: 8px; }
.sessions-empty { font-size: 0.85rem; color: var(--text-muted); padding: 12px 8px; text-align: center; }

.session-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.session-item:hover { background: var(--bg-input); }
.session-item.active { background: var(--accent-dim); }

.session-label {
  flex: 1;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-delete {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: color 0.15s;
}
.session-delete:hover { color: var(--error-fg); }

/* =================================================================
   Main chat area
   ================================================================= */

.chat-main {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding-bottom: 8px;
}

/* =================================================================
   Welcome screen
   ================================================================= */

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--topbar-h) - var(--inputbar-h) - 16px);
  padding: 32px 16px;
  text-align: center;
}
.welcome-icon { font-size: 3.5rem; margin-bottom: 16px; }
.welcome-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.welcome-subtitle { font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 28px; }

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 640px;
}
.example-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 8px 16px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.example-btn:hover { background: var(--bg-input); color: var(--text); border-color: var(--accent); }

/* =================================================================
   Messages
   ================================================================= */

.messages { padding: 16px; max-width: 860px; margin: 0 auto; }

.message {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  animation: fadeSlideIn 0.2s ease;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.message-content { flex: 1; min-width: 0; }

.message-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 0.93rem;
  word-break: break-word;
}

.message.user { flex-direction: row-reverse; }
.message.user .message-content { display: flex; flex-direction: column; align-items: flex-end; }
.message.user .message-bubble {
  background: var(--user-bubble);
  color: #cde1ff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.message.assistant .message-bubble {
  background: var(--asst-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Markdown inside assistant bubbles */
.message-bubble h1, .message-bubble h2, .message-bubble h3 {
  margin: 0.6em 0 0.3em;
  font-size: 1em;
  font-weight: 700;
}
.message-bubble p { margin: 0.4em 0; }
.message-bubble ul, .message-bubble ol { padding-left: 1.2em; margin: 0.4em 0; }
.message-bubble li { margin-bottom: 0.25em; }
.message-bubble table { border-collapse: collapse; width: 100%; margin: 0.5em 0; font-size: 0.87rem; }
.message-bubble th, .message-bubble td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
}
.message-bubble th { background: var(--bg); font-weight: 600; }
.message-bubble code {
  background: var(--bg);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "Fira Code", "Cascadia Code", monospace;
  font-size: 0.88em;
}
.message-bubble pre { background: var(--bg); border-radius: 8px; padding: 10px; overflow-x: auto; margin: 0.5em 0; }
.message-bubble pre code { background: none; padding: 0; }
.message-bubble a { color: #7ab4ff; }

/* Tool badges */
.tools-used { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
.tool-badge {
  background: var(--tool-badge-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--tool-badge-fg);
  font-size: 0.72rem;
  padding: 2px 8px;
}

/* Error message */
.message-error {
  color: var(--error-fg);
  font-size: 0.85rem;
  padding: 8px 12px;
  background: rgba(248,81,73,0.1);
  border: 1px solid rgba(248,81,73,0.3);
  border-radius: 8px;
  margin-bottom: 16px;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

/* =================================================================
   Football loading animation
   ================================================================= */

.football-loader {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 40px;
  padding: 8px 14px;
}

.football-ball {
  font-size: 1.4rem;
  animation: ballBounce 0.7s ease-in-out infinite;
  transform-origin: bottom center;
}

@keyframes ballBounce {
  0%, 100% { transform: translateY(0) scaleY(1) scaleX(1); }
  40%       { transform: translateY(-18px) scaleY(1.05) scaleX(0.95); }
  70%       { transform: translateY(-4px) scaleY(0.95) scaleX(1.05); }
}

.football-shadow {
  width: 16px;
  height: 4px;
  background: var(--text-subtle);
  border-radius: 50%;
  animation: shadowPulse 0.7s ease-in-out infinite;
  align-self: flex-end;
  margin-left: -2px;
}

@keyframes shadowPulse {
  0%, 100% { transform: scaleX(1); opacity: 0.6; }
  40%       { transform: scaleX(0.5); opacity: 0.2; }
  70%       { transform: scaleX(0.9); opacity: 0.5; }
}

/* =================================================================
   Input bar
   ================================================================= */

.input-bar {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.input-wrap {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 8px 14px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: var(--accent); }

#input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.93rem;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}
#input::placeholder { color: var(--text-subtle); }

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  color: #080e1c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { background: var(--text-subtle); cursor: not-allowed; }

/* =================================================================
   Login page
   ================================================================= */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px;
  text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: 12px; }
.login-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 28px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.login-field label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.login-field input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--accent); }

.login-btn {
  margin-top: 4px;
  padding: 11px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #080e1c;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.login-btn:hover { background: var(--accent-hover); }

.login-error { margin-top: 12px; color: var(--error-fg); font-size: 0.85rem; }

/* =================================================================
   Scrollbar (Webkit)
   ================================================================= */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* =================================================================
   Responsive
   ================================================================= */

@media (max-width: 600px) {
  .welcome-subtitle br { display: none; }
  .examples { flex-direction: column; align-items: stretch; }
  .example-btn { text-align: left; border-radius: 10px; }
}
