/* ==========================================================
   Grafix Wiki - APOrtha Design System
   Helles, modernes Theme basierend auf APOrtha Branding
   ========================================================== */

/* --- CSS Variables --- */
:root {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef1f6;
  --bg-input: #ffffff;
  --text-primary: #1a1f36;
  --text-secondary: #525f7f;
  --text-muted: #8898aa;
  --text-inverse: #ffffff;
  --accent: #0068a5;
  --accent-hover: #005489;
  --accent-light: rgba(0, 104, 165, 0.08);
  --accent-green: #7ab648;
  --accent-green-hover: #6a9e3e;
  --accent-green-light: rgba(122, 182, 72, 0.1);
  --user-msg-bg: #e3f0fa;
  --user-msg-border: #c4ddf0;
  --bot-msg-bg: #ffffff;
  --bot-msg-border: #e2e8f0;
  --error: #dc3545;
  --error-bg: rgba(220, 53, 69, 0.08);
  --warning: #f59e0b;
  --success: #22c55e;
  --border: #e2e8f0;
  --border-focus: var(--accent);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* --- Layout --- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
}

/* --- Header --- */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  height: 36px;
  width: auto;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  border: 1px solid transparent;
}

.header-nav-link:hover {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
  border-color: var(--border);
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-main);
  transition: all var(--transition);
}

.btn-logout:hover {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error);
}

/* --- Login Card --- */
.login-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
  padding: 20px;
}

.login-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  height: 48px;
  width: auto;
  margin-bottom: 24px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.login-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font-main);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.login-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.login-input::placeholder {
  color: var(--text-muted);
}

.login-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: -8px;
  margin-bottom: 12px;
  display: none;
}

.login-error.visible {
  display: block;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-green {
  background: var(--accent-green);
  color: var(--text-inverse);
}

.btn-green:hover {
  background: var(--accent-green-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-muted);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --- Chat Area --- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-area::-webkit-scrollbar {
  width: 6px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Messages --- */
.msg {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.65;
  animation: fadeInUp 0.3s ease;
}

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

.msg.user {
  align-self: flex-end;
  background: var(--user-msg-bg);
  border: 1px solid var(--user-msg-border);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bot-msg-bg);
  border: 1px solid var(--bot-msg-border);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 4px;
}

.msg.bot h1, .msg.bot h2, .msg.bot h3 {
  color: var(--accent);
  margin: 16px 0 8px;
  line-height: 1.3;
}

.msg.bot h1:first-child, .msg.bot h2:first-child, .msg.bot h3:first-child {
  margin-top: 0;
}

.msg.bot h1 { font-size: 1.15rem; }
.msg.bot h2 { font-size: 1.05rem; }
.msg.bot h3 { font-size: 0.95rem; }

.msg.bot p {
  margin: 8px 0;
}

.msg.bot ul, .msg.bot ol {
  padding-left: 20px;
  margin: 8px 0;
}

.msg.bot li {
  margin: 4px 0;
}

.msg.bot code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.msg.bot pre {
  background: var(--bg-tertiary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 10px 0;
}

.msg.bot pre code {
  background: none;
  padding: 0;
}

.msg.bot strong {
  color: var(--accent);
  font-weight: 600;
}

.msg.bot a {
  color: var(--accent);
  text-decoration: underline;
}

.msg.bot blockquote {
  border-left: 3px solid var(--accent-green);
  padding-left: 12px;
  margin: 10px 0;
  color: var(--text-secondary);
}

/* --- Message Meta --- */
.msg-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* --- Welcome Message --- */
.welcome-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.welcome-msg h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.welcome-msg p {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.welcome-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.welcome-tip {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.welcome-tip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* --- Loading Dots --- */
.loading-dots {
  display: flex;
  gap: 6px;
  padding: 14px 18px;
  align-self: flex-start;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.3;
  animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* --- Input Area --- */
.input-area {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-field {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font-main);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.input-field::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Admin Page Styles --- */
.admin-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.admin-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
}

.admin-section h2 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.admin-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-main);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.admin-form input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.admin-form input::placeholder {
  color: var(--text-muted);
}

/* --- Admin List Items --- */
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-list-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.admin-item:hover {
  border-color: var(--text-muted);
}

.admin-item-info {
  flex: 1;
  min-width: 0;
}

.admin-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-item-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.admin-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
  flex-shrink: 0;
}

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
}

.badge-no-transcript {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* --- Notification Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-inverse);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
  animation-fill-mode: forwards;
}

.toast-success { background: var(--accent-green); }
.toast-error { background: var(--error); }

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

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .header {
    padding: 10px 16px;
  }

  .header-logo {
    height: 28px;
  }

  .header-title {
    font-size: 0.95rem;
  }

  .header-subtitle {
    display: none;
  }

  .chat-area {
    padding: 16px;
  }

  .msg {
    max-width: 92%;
    padding: 12px 14px;
    font-size: 0.88rem;
  }

  .input-area {
    padding: 12px 16px;
  }

  .login-card {
    padding: 32px 24px;
  }

  .welcome-tips {
    flex-direction: column;
    align-items: center;
  }

  .admin-container {
    padding: 16px;
  }

  .admin-form {
    flex-direction: column;
  }

  .admin-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .admin-item-actions {
    margin-left: 0;
    align-self: flex-end;
  }
}

@media (min-width: 901px) {
  .app-container {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
