@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg: #0a0a0f;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.16);
  --primary: #6c63ff;
  --primary-2: #a855f7;
  --grad: linear-gradient(135deg, #6c63ff, #a855f7);
  --text: #e2e8f0;
  --muted: #64748b;
  --success: #10b981;
  --error: #ef4444;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --r: 14px;
  --r-sm: 8px;
  --blur: blur(20px);
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --t: 0.18s ease;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── LOGIN ── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; overflow: hidden; position: relative;
}

.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: 0.25;
  animation: float 10s ease-in-out infinite;
}
.orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #6c63ff 0%, transparent 70%);
  top: -200px; left: -150px;
}
.orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #a855f7 0%, transparent 70%);
  bottom: -150px; right: -100px;
  animation-delay: -5s;
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-40px) scale(1.04); }
}

.login-wrap {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px; padding: 24px;
}

.login-card {
  background: rgba(255,255,255,0.04);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 52px 40px;
  box-shadow: var(--shadow);
}

.login-logo { text-align: center; margin-bottom: 44px; }
.logo-glyph {
  font-size: 52px; line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 14px; display: block;
}
.login-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.login-logo p { color: var(--muted); font-size: 13px; }

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.form-group input {
  width: 100%; padding: 13px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text); font-size: 14px; font-family: var(--font);
  outline: none; transition: border-color var(--t), background var(--t);
}
.form-group input:focus {
  border-color: var(--primary);
  background: rgba(108,99,255,0.07);
}
.form-group input::placeholder { color: var(--muted); }

.error-box {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5; padding: 11px 15px;
  border-radius: var(--r-sm); font-size: 13px; margin-bottom: 16px;
}

.btn-primary {
  width: 100%; padding: 14px;
  background: var(--grad); color: white; border: none;
  border-radius: var(--r-sm); font-size: 14px; font-weight: 600;
  font-family: var(--font); cursor: pointer;
  transition: opacity var(--t), transform var(--t);
  margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.spinner { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── APP LAYOUT ── */
.app-body { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 60px;
  background: rgba(10,10,15,0.85);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
}
.header-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700; letter-spacing: -0.3px;
}
.brand-glyph {
  font-size: 22px;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.header-right { display: flex; align-items: center; gap: 16px; }
.user-chip {
  font-size: 12px; color: var(--muted); font-weight: 500;
  padding: 5px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
}

.btn-ghost {
  padding: 7px 14px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all var(--t);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface); }

.app-main {
  flex: 1; max-width: 1200px; margin: 0 auto;
  width: 100%; padding: 40px 32px;
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 64px 40px; text-align: center;
  cursor: pointer; transition: all var(--t);
  position: relative; overflow: hidden; user-select: none;
}
.upload-zone:hover { border-color: rgba(108,99,255,0.5); background: rgba(108,99,255,0.04); }
.upload-zone.drag-over {
  border-color: var(--primary); border-style: solid;
  background: rgba(108,99,255,0.08);
  box-shadow: 0 0 0 4px rgba(108,99,255,0.1);
}
.upload-zone.drag-over .upload-arrow { transform: translateY(-6px); }

.upload-arrow {
  font-size: 52px; line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 18px; display: block; transition: transform var(--t);
}
.upload-zone h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; letter-spacing: -0.3px; }
.upload-zone p { color: var(--muted); font-size: 13px; }
.upload-hint { margin-top: 8px; font-size: 11px !important; opacity: 0.55; }
.pick-link { color: var(--primary); cursor: pointer; }
.pick-link:hover { color: var(--primary-2); }

/* ── PROGRESS ── */
.progress-wrap {
  margin-top: 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 16px 20px;
}
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 10px;
}
.progress-label { color: var(--muted); }
.progress-pct { font-weight: 600; color: var(--primary); }
.progress-track {
  height: 4px; background: rgba(255,255,255,0.07);
  border-radius: 2px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--grad);
  border-radius: 2px; width: 0%;
  transition: width 0.12s ease;
}

/* ── RESULT TOAST ── */
.result-toast {
  margin-top: 14px; padding: 12px 16px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
}
.result-toast.ok { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); color: #6ee7b7; }
.result-toast.fail { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }

/* ── FILES ── */
.files-section { margin-top: 44px; }
.files-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.files-head h3 { font-size: 16px; font-weight: 600; }
.count-badge { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 8px; }

.btn-icon {
  width: 34px; height: 34px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--muted);
  font-size: 17px; cursor: pointer; transition: all var(--t);
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface-hover); }
.btn-icon.spinning { animation: spin 0.7s linear infinite; }

.placeholder-msg {
  text-align: center; padding: 64px 20px;
  color: var(--muted); font-size: 14px;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

/* ── FILE CARD ── */
.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
  transition: all var(--t); animation: fadeUp 0.2s ease both;
}
.file-card:hover {
  border-color: var(--border-hover); background: var(--surface-hover);
  transform: translateY(-2px); box-shadow: 0 4px 24px rgba(0,0,0,0.35);
}

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

.type-badge {
  width: 50px; height: 50px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.5px;
  text-transform: uppercase; flex-shrink: 0;
}
.t-img { background: rgba(59,130,246,0.18); color: #60a5fa; }
.t-vid { background: rgba(239,68,68,0.18); color: #f87171; }
.t-aud { background: rgba(16,185,129,0.18); color: #34d399; }
.t-arc { background: rgba(245,158,11,0.18); color: #fbbf24; }
.t-exe { background: rgba(239,68,68,0.14); color: #ef4444; }
.t-pdf { background: rgba(239,68,68,0.18); color: #f87171; }
.t-doc { background: rgba(99,102,241,0.18); color: #818cf8; }
.t-cod { background: rgba(20,184,166,0.18); color: #2dd4bf; }
.t-def { background: rgba(100,116,139,0.18); color: #94a3b8; }

.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 13px; font-weight: 500; line-height: 1.4;
  word-break: break-all; margin-bottom: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.file-meta { font-size: 11px; color: var(--muted); }
.meta-self { color: var(--muted); }
.meta-other { color: var(--primary); font-weight: 600; }
.file-card.from-other {
  border-color: rgba(108,99,255,0.3);
  background: rgba(108,99,255,0.04);
}
.file-card.from-other:hover {
  border-color: rgba(108,99,255,0.5);
}

.file-actions { display: flex; gap: 8px; }
.btn-file {
  flex: 1; padding: 8px 4px; border-radius: var(--r-sm);
  border: 1px solid; font-size: 11px; font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: all var(--t);
  letter-spacing: 0.4px;
}
.btn-dl {
  background: rgba(108,99,255,0.1); color: var(--primary);
  border-color: rgba(108,99,255,0.25);
}
.btn-dl:hover { background: rgba(108,99,255,0.2); border-color: var(--primary); }
.btn-rm {
  background: rgba(239,68,68,0.08); color: #f87171;
  border-color: rgba(239,68,68,0.2);
}
.btn-rm:hover { background: rgba(239,68,68,0.18); border-color: #ef4444; }

/* ── MODAL ── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #12121a; border: 1px solid var(--border);
  border-radius: var(--r); padding: 32px;
  max-width: 400px; width: calc(100% - 48px);
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.modal-file {
  color: var(--muted); font-size: 13px; word-break: break-all;
  margin-bottom: 24px; padding: 10px 14px;
  background: var(--surface); border-radius: var(--r-sm); border: 1px solid var(--border);
}
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
.btn-danger {
  padding: 10px 24px;
  background: rgba(239,68,68,0.85); color: white; border: none;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: all var(--t);
}
.btn-danger:hover { background: var(--error); }

/* ── CHAT TOGGLE (Header) ── */
.chat-toggle { position: relative; }
.chat-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  background: var(--grad); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 1;
}

/* ── APP SHELL (Main + Chat nebeneinander) ── */
.app-shell { flex: 1; display: flex; align-items: flex-start; min-height: 0; }
.app-shell .app-main { margin: 0 auto; }

/* ── CHAT PANEL ── */
.chat-panel {
  width: 360px; flex-shrink: 0; align-self: stretch;
  position: sticky; top: 60px;
  height: calc(100vh - 60px);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
body.chat-hidden .chat-panel { display: none; }

.chat-head {
  flex-shrink: 0; padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-title { font-size: 14px; font-weight: 600; }
.chat-presence { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chat-presence .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0;
}
.chat-presence.online .dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.chat-presence.online { color: #6ee7b7; }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-empty { margin: auto; color: var(--muted); font-size: 13px; text-align: center; }

.chat-sep {
  align-self: center; margin: 8px 0 2px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.5px;
  color: var(--muted); text-transform: uppercase;
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 12px; border-radius: 999px;
}
.chat-newline {
  display: flex; align-items: center; gap: 10px;
  margin: 6px 2px; color: var(--primary); font-size: 10px;
  font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
}
.chat-newline::before, .chat-newline::after {
  content: ''; flex: 1; height: 1px; background: rgba(108,99,255,0.35);
}

.chat-row { display: flex; flex-direction: column; max-width: 82%; }
.chat-row.me { align-self: flex-end; align-items: flex-end; }
.chat-row.other { align-self: flex-start; align-items: flex-start; }

.chat-sender { font-size: 10px; font-weight: 600; color: var(--primary); margin: 0 4px 3px; }
.chat-bubble {
  padding: 9px 13px; border-radius: 14px;
  font-size: 13px; line-height: 1.45; word-break: break-word;
  white-space: pre-wrap;
}
.chat-row.other .chat-bubble {
  background: var(--surface); border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-row.me .chat-bubble {
  background: var(--grad); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-time { font-size: 9.5px; color: var(--muted); margin: 3px 4px 0; }

.chat-input-row {
  flex-shrink: 0; display: flex; gap: 8px; align-items: flex-end;
  padding: 12px; border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1; resize: none; max-height: 120px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-size: 13px; font-family: var(--font);
  outline: none; transition: border-color var(--t);
}
.chat-input:focus { border-color: var(--primary); }
.chat-input::placeholder { color: var(--muted); }
.chat-send {
  flex-shrink: 0; width: 38px; height: 38px;
  background: var(--grad); color: #fff; border: none;
  border-radius: var(--r-sm); font-size: 15px; cursor: pointer;
  transition: opacity var(--t); display: flex; align-items: center; justify-content: center;
}
.chat-send:hover:not(:disabled) { opacity: 0.88; }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-foot {
  flex-shrink: 0; padding: 8px 14px; text-align: center;
  font-size: 10px; color: var(--muted); opacity: 0.7;
  border-top: 1px solid var(--border);
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .app-header { padding: 0 16px; }
  .app-main { padding: 24px 16px; }
  .upload-zone { padding: 44px 20px; }
  .files-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
  .login-card { padding: 36px 24px; }

  .chat-panel {
    position: fixed; top: 60px; right: 0; bottom: 0; height: auto;
    width: min(360px, 100%); z-index: 200;
    box-shadow: -8px 0 32px rgba(0,0,0,0.5);
    background: #0e0e16;
    transition: transform 0.2s ease;
  }
  body.chat-hidden .chat-panel { display: flex; transform: translateX(110%); }
}


/* ---- Kopier-Knopf an Chat-Nachrichten ----
   Der Chat zeichnet sich regelmäßig neu; Text zu markieren war deshalb kaum
   möglich. Der Knopf kopiert die Nachricht mit einem Klick. Er bleibt dezent
   und wird erst beim Überfahren der Blase deutlich sichtbar. */
.chat-bubble{ position:relative; }
.chat-copy{
    position:absolute; top:4px; right:4px;
    width:24px; height:24px; padding:0; line-height:1;
    display:flex; align-items:center; justify-content:center;
    background:rgba(0,0,0,.28); border:0; border-radius:6px;
    color:inherit; font-size:.82rem; cursor:pointer;
    opacity:0; transition:opacity .18s, background .18s;
}
.chat-bubble:hover .chat-copy,
.chat-copy:focus-visible{ opacity:.75; }
.chat-copy:hover{ opacity:1; background:rgba(0,0,0,.45); }
.chat-copy--ok{ opacity:1; background:#2e7d32; color:#fff; }

/* Platz für den Knopf, damit er keinen Text überdeckt */
.chat-text{ display:block; padding-right:22px; }

/* Auf Touch-Geräten gibt es kein Überfahren — dort dauerhaft sichtbar */
@media (hover:none){
    .chat-copy{ opacity:.6; }
}
