/* ============================================================
   FEMMA — Design System
   Exakt kopia av femma-styles.css med produktionsklar struktur
   ============================================================ */

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

/* ── Variables ── */
:root {
  --eclips: #462377;
  --eclips-light: #6B3FA0;
  --lavendel: #B39DDB;
  --lavendel-light: #D1C4E9;
  --lavendel-pale: #EDE7F6;
  --rose: #E8A0BF;
  --sage: #A8C5A0;
  --warm-white: #FAF8FF;
  --off-white: #F5F0FF;
  --surface: #FFFFFF;
  --surface-2: #F0EBF8;
  --text-primary: #1A1225;
  --text-secondary: #5C4E7A;
  --text-muted: #9E8FB5;
  --border: #E0D5F0;
  --border-light: #EDE7F6;
  --color-accent: var(--lavendel);
  --color-surface-2: var(--surface-2);

  --font-serif: 'Ovo', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 3px rgba(70, 35, 119, 0.08);
  --shadow-md: 0 4px 16px rgba(70, 35, 119, 0.12);
  --shadow-lg: 0 8px 32px rgba(70, 35, 119, 0.16);

  --nav-height: 60px;
  --bottom-nav-height: 64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--warm-white);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Auth Screen ── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--eclips) 0%, var(--eclips-light) 50%, var(--lavendel) 100%);
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-mark {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--eclips), var(--lavendel));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif);
  font-size: 28px; color: white;
  margin: 0 auto 12px;
}

.auth-logo h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--eclips);
  font-weight: 400;
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1; padding: 10px;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer; transition: all 0.2s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--eclips);
  box-shadow: var(--shadow-sm);
}

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }

input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans); font-size: 0.9rem;
  color: var(--text-primary); background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
input:focus {
  border-color: var(--lavendel);
  box-shadow: 0 0 0 3px rgba(179, 157, 219, 0.2);
}
input::placeholder { color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px;
  border: none; border-radius: var(--radius-md);
  font-family: var(--font-sans); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--eclips), var(--eclips-light));
  color: white; width: 100%;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary {
  background: var(--surface-2); color: var(--eclips);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--lavendel-pale); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--eclips); }
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.auth-error {
  background: #FFF0F0; border: 1px solid #FFD0D0;
  color: #C0392B; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 0.85rem;
  margin-bottom: 16px; display: none;
}
.auth-error.visible { display: block; }
.auth-error.success {
  background: #F0FFF4; border-color: #BBF7D0;
  color: #15803d;
}

/* ── App Shell ── */
.app-shell { display: none; flex-direction: column; height: 100vh; }
.app-shell.visible { display: flex; }

/* ── Top Nav ── */
.top-nav {
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 1.4rem; color: var(--eclips);
  font-weight: 400;
}

.nav-phase-badge {
  font-size: 0.75rem; color: var(--text-muted);
  background: var(--surface-2);
  padding: 4px 10px; border-radius: var(--radius-pill);
}

.nav-actions { display: flex; gap: 8px; }
.nav-icon-btn {
  width: 36px; height: 36px;
  background: transparent; border: none;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s;
}
.nav-icon-btn:hover { background: var(--surface-2); color: var(--eclips); }

/* ── Main Content ── */
.main-content {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
}

/* ── Bottom Nav ── */
.bottom-nav {
  height: var(--bottom-nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  display: flex; align-items: center;
  padding: 0 8px;
  flex-shrink: 0;
}

.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; padding: 8px 4px;
  background: none; border: none;
  cursor: pointer; border-radius: var(--radius-md);
  transition: all 0.2s;
  color: var(--text-muted);
  font-size: 0.7rem; font-family: var(--font-sans);
}
.bottom-nav-item svg { transition: transform 0.2s; }
.bottom-nav-item.active { color: var(--eclips); }
.bottom-nav-item.active svg { transform: scale(1.1); }
.bottom-nav-item:hover { background: var(--lavendel-pale); color: var(--eclips); }

/* ── Chat View ── */
.chat-view {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
}

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}

.chat-empty {
  flex: 1; display: flex;
  align-items: center; justify-content: center;
  min-height: 200px;
}
.chat-empty-inner { text-align: center; }
.femma-logo-mark {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--eclips), var(--lavendel));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 24px; color: white;
  margin: 0 auto 12px;
}
.chat-empty-inner p { color: var(--text-muted); font-size: 0.9rem; }

/* ── Messages ── */
.msg { display: flex; max-width: 85%; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-assistant { align-self: flex-start; }

.msg-content {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.925rem; line-height: 1.65;
}
.msg-user .msg-content {
  background: linear-gradient(135deg, var(--eclips), var(--eclips-light));
  color: white;
  border-bottom-right-radius: var(--radius-sm);
}
.msg-assistant .msg-content {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-bottom-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.msg-content p { margin: 0 0 8px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-error { color: #C0392B; font-size: 0.85rem; }

/* ── Thinking dots ── */
.chat-thinking {
  padding: 8px 20px;
  display: flex; align-items: center; gap: 6px;
}
.thinking-dot {
  width: 8px; height: 8px;
  background: var(--lavendel);
  border-radius: 50%;
  animation: thinking-bounce 1.2s infinite ease-in-out;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Chat Input ── */
.chat-input-area {
  padding: 12px 16px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}
.chat-input-wrap {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input-wrap:focus-within {
  border-color: var(--lavendel);
  box-shadow: 0 0 0 3px rgba(179, 157, 219, 0.15);
}
#chat-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--font-sans); font-size: 0.925rem;
  color: var(--text-primary); resize: none;
  min-height: 24px; max-height: 160px;
  line-height: 1.5; padding: 4px 0;
}
#chat-input::placeholder { color: var(--text-muted); }

.btn-send {
  width: 40px; height: 40px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--eclips), var(--eclips-light));
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: white;
  transition: opacity 0.2s, transform 0.2s;
}
.btn-send:hover { opacity: 0.9; transform: scale(1.05); }

/* ── Profile View ── */
.profile-view, .memory-view {
  padding: 20px 16px;
  overflow-y: auto; height: 100%;
}

.profile-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px;
}
.profile-avatar {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--eclips), var(--lavendel));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 28px; color: white;
  flex-shrink: 0;
}
.profile-header-info h2 { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 400; color: var(--eclips); }

.profile-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.profile-section-title {
  font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 16px;
}

/* ── Cycle Display ── */
.cycle-display { display: flex; align-items: center; gap: 20px; margin-bottom: 16px; }
.cycle-ring { width: 100px; height: 100px; flex-shrink: 0; }
.cycle-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.cycle-day-text { font-family: var(--font-serif); font-size: 22px; fill: var(--eclips); transform: rotate(90deg); transform-origin: 50% 50%; font-weight: 400; }
.cycle-sub-text { font-size: 10px; fill: var(--text-muted); transform: rotate(90deg); transform-origin: 50% 50%; }
.cycle-phase { font-size: 1rem; font-weight: 500; color: var(--eclips); margin-bottom: 4px; }
.cycle-detail { font-size: 0.85rem; color: var(--text-muted); }
.period-tracker { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Life Areas Grid ── */
.life-areas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.life-area-item {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.life-area-label { display: block; font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.04em; }
.life-area-value { font-size: 0.875rem; color: var(--text-primary); font-weight: 500; }

/* ── Memory View ── */
.memory-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.memory-section h3 { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 12px; }
.memory-core { font-family: var(--font-serif); font-size: 1rem; color: var(--eclips); line-height: 1.6; }
.memory-age { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.75rem; }

.memory-people { display: flex; flex-direction: column; gap: 8px; }
.memory-person { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-md); }
.memory-person strong { font-size: 0.875rem; color: var(--eclips); }
.memory-person span { font-size: 0.825rem; color: var(--text-secondary); }
.memory-person-high { border-left: 3px solid var(--eclips); }
.memory-person-low { opacity: 0.7; }

.memory-topic { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--lavendel-pale); border-radius: var(--radius-md); margin-bottom: 8px; }
.memory-topic strong { font-size: 0.875rem; color: var(--eclips); }
.memory-topic span { font-size: 0.825rem; color: var(--text-secondary); }

.memory-pattern { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.memory-pattern:last-child { border-bottom: none; }
.memory-pattern span { font-size: 0.875rem; color: var(--text-primary); flex: 1; }
.conf-bars { display: flex; gap: 3px; flex-shrink: 0; }
.conf-bar { width: 6px; height: 16px; background: var(--border); border-radius: 3px; }
.conf-bar-filled { background: var(--lavendel); }

.memory-strengths { display: flex; flex-wrap: wrap; gap: 8px; }
.memory-strength-tag { background: var(--lavendel-pale); color: var(--eclips); padding: 6px 14px; border-radius: var(--radius-pill); font-size: 0.825rem; font-weight: 500; }

.memory-meta { text-align: center; font-size: 0.8rem; color: var(--text-muted); padding: 16px 0 8px; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 500; }
.badge-success { background: #E8F5E9; color: #2E7D32; }
.badge-warning { background: var(--lavendel-pale); color: var(--eclips); }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state p { font-size: 0.9rem; line-height: 1.6; }

/* ── Loading ── */
.loading-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: var(--warm-white);
}
.loading-inner { text-align: center; }
.loading-inner .femma-logo-mark { margin: 0 auto 16px; }
.loading-inner p { color: var(--text-muted); font-size: 0.9rem; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .auth-card { padding: 36px 24px; }
  .life-areas-grid { grid-template-columns: 1fr; }
}
