/* ========================================
   IdeenInbox — Styles (Dark Mode, PWA)
   ======================================== */

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #e0e0e0;
  background: #121212;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* --- CSS Variables --- */
:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --accent: #f84a00;
  --accent-hover: #ff6a2a;
  --text: #e0e0e0;
  --muted: #888;
  --error: #cf6679;
  --success: #4caf50;
  --recording: #f44336;
  --radius: 12px;
  --transition: 200ms ease;
}

.hidden {
  display: none !important;
}

/* --- PIN Screen --- */
.pin-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.pin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  width: 100%;
  max-width: 320px;
}

.pin-icon {
  margin-bottom: 8px;
}

.pin-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.pin-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.pin-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 8px;
  color: var(--text);
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
}

.pin-input:focus {
  border-color: var(--accent);
}

.pin-error {
  font-size: 14px;
  color: var(--error);
  min-height: 21px;
}

.pin-btn {
  width: 100%;
}

/* --- Buttons --- */
.btn-primary {
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  min-height: 48px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.97);
}

/* --- Onboarding Overlay --- */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  padding: 24px;
}

.onboarding-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px 24px;
  max-width: 340px;
  text-align: center;
}

.onboarding-card h2 {
  font-size: 22px;
  margin-bottom: 12px;
  color: var(--text);
}

.onboarding-card p {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.onboarding-card .btn-primary {
  width: 100%;
}

/* --- App Layout --- */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

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

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background var(--transition);
}

.connection-dot.online {
  background: var(--success);
}

.connection-dot.offline {
  background: var(--error);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 32px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  background: rgba(248, 74, 0, 0.15);
}

/* --- Views --- */
.view {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* --- Erfassen View --- */
.view-erfassen {
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.idea-textarea {
  flex: 1;
  width: 100%;
  padding: 16px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  outline: none;
  resize: none;
  transition: border-color var(--transition);
}

.idea-textarea:focus {
  border-color: var(--accent);
}

.idea-textarea::placeholder {
  color: var(--muted);
}

.idea-textarea.interim {
  color: var(--muted);
  font-style: italic;
}

/* --- Success Overlay --- */
.success-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 18, 18, 0.8);
  animation: fade-in-out 0.5s ease forwards;
  pointer-events: none;
}

/* --- Button Bar --- */
.button-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 16px;
  height: 64px;
  flex-shrink: 0;
}

/* Sekundär-Button (Verwerfen) */
.btn-secondary {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid #333;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  border-color: var(--recording);
  color: var(--recording);
}

/* Hauptbutton — kontextabhängig */
.btn-main {
  position: relative;
  height: 56px;
  min-width: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 2px solid #333;
  border-radius: 28px;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-main:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Mic-Modus (default, rund) */
.btn-main[data-mode="mic"] {
  width: 56px;
  border-radius: 50%;
}

/* Stop-Modus (Aufnahme, rot, rund) */
.btn-main[data-mode="stop"] {
  width: 56px;
  border-radius: 50%;
  background: var(--recording);
  border-color: var(--recording);
  color: #fff;
}

/* Send-Modus (breit, orange) */
.btn-main[data-mode="send"] {
  padding: 0 24px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  gap: 8px;
}

.btn-main[data-mode="send"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-main:active {
  transform: scale(0.93);
}

.icon-send {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--recording);
  animation: pulse-ring 1.5s ease-out infinite;
  pointer-events: none;
}

.speech-unavailable {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Privacy Footer --- */
.privacy-footer {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  flex-shrink: 0;
}
.version-info {
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.5;
}

/* --- Inbox View --- */
.view-inbox {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.inbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 80px;
  -webkit-overflow-scrolling: touch;
}

.inbox-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.inbox-empty p {
  font-size: 15px;
  line-height: 1.6;
}

/* --- Idea Card --- */
.idea-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: all var(--transition);
}

.idea-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.idea-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  word-break: break-word;
}
.btn-delete-idea {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
}
.btn-delete-idea:hover, .btn-delete-idea:active {
  opacity: 1;
  color: #ef4444;
}

.idea-raw {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.idea-full {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.idea-card { cursor: pointer; }

.idea-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  cursor: default;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-status {
  cursor: pointer;
  min-height: 28px;
}

.badge-status:hover {
  filter: brightness(1.2);
}

/* Status Colors */
.badge-neu {
  background: rgba(248, 74, 0, 0.2);
  color: #f84a00;
}

.badge-vorgelegt {
  background: rgba(66, 165, 245, 0.2);
  color: #42a5f5;
}

.badge-umgesetzt {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
}

.badge-verworfen {
  background: rgba(136, 136, 136, 0.2);
  color: #888;
}

.badge-kategorie {
  background: rgba(171, 71, 188, 0.15);
  color: #ab47bc;
}

.badge-projekt {
  background: rgba(255, 183, 77, 0.15);
  color: #ffb74d;
}

.idea-date {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

/* --- Inbox Refresh Button --- */
.inbox-refresh-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all var(--transition);
}

.inbox-refresh-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.inbox-refresh-btn:active {
  transform: scale(0.95);
}

.inbox-refresh-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

/* --- Status Picker --- */
.status-picker {
  position: absolute;
  background: var(--surface);
  border: 1px solid #333;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 50;
  animation: scale-in 150ms ease;
}

.status-picker-option {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
  min-height: 40px;
}

.status-picker-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 14px 18px;
  font-size: 14px;
  border-radius: var(--radius);
  pointer-events: auto;
  animation: slide-up 300ms ease;
}

.toast.toast-error {
  background: var(--error);
  color: #fff;
}

.toast.toast-success {
  background: var(--success);
  color: #fff;
}

.toast.toast-out {
  animation: slide-down 300ms ease forwards;
}

/* --- Animations --- */
@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fade-in-out {
  0% { opacity: 0; transform: scale(0.8); }
  20% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.8); }
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slide-down {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

@keyframes scale-in {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* --- Scrollbar (Webkit) --- */
.inbox-list::-webkit-scrollbar {
  width: 4px;
}

.inbox-list::-webkit-scrollbar-track {
  background: transparent;
}

.inbox-list::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

/* --- Safe Area (Notch) --- */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: env(safe-area-inset-top);
    height: calc(48px + env(safe-area-inset-top));
  }

  .button-bar {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(64px + env(safe-area-inset-bottom));
  }

  .privacy-footer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}
