/* ═══════════════════════════════════════════════════════════
   INVERBOOKS - DESIGN SYSTEM v2
   Paleta més neutra, més serietat financera, menys saturació
   ═══════════════════════════════════════════════════════════ */

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

:root {
  /* Backgrounds - més neutres */
  --bg:        #0a0e17;
  --bg2:       #0c111c;
  --surface:   #10151f;
  --surface2:  #141a26;
  --edge:      #1c2536;
  --edge2:     #2a3447;

  /* Brand - menys saturat */
  --blue:    #3b82f6;
  --blue2:   #2563eb;
  --blue3:   #60a5fa;
  --cyan:    #06b6d4;

  /* Semantic */
  --red:    #ef4444;
  --green:  #10b981;
  --amber:  #f59e0b;

  /* Text - més contrast natural */
  --silver:  #6b7280;
  --slate:   #9ca3af;
  --light:   #d1d5db;
  --bright:  #f3f4f6;
  --border:  rgba(255,255,255,0.06);
}

html, body {
  background: var(--bg);
  color: var(--bright);
  font-family: 'Manrope', sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body { position: relative; }

/* Noise texture - menys agressiva */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}

/* ═══════════ NAV ═══════════ */
.ib-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 58px;
  background: rgba(10,14,23,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--edge);
  display: flex; align-items: center;
  /* No selectionable - més professional */
  user-select: none;
  -webkit-user-select: none;
}
.ib-nav-inner {
  max-width: 1100px; margin: 0 auto; width: 100%;
  padding: 0 24px;
  display: flex; align-items: center; gap: 4px;
}
.ib-logo {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; margin-right: 16px;
}
.ib-logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace; font-size: 11px; color: white;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.ib-logo-mark img {
  width: 100% !important; height: 100% !important;
  object-fit: cover; display: block;
}
.ib-logo-txt {
  font-family: 'DM Mono', monospace;
  font-size: 13px; letter-spacing: 2.5px;
  color: var(--bright);
}
.ib-logo-txt span { color: var(--blue); }

.ib-nav-link {
  padding: 6px 13px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--slate);
  text-decoration: none;
  transition: color 0.18s, background 0.18s;
  white-space: nowrap;
}
.ib-nav-link:hover { color: var(--bright); background: rgba(255,255,255,0.04); }
.ib-nav-link.active {
  color: var(--blue3);
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.18);
}
.ib-nav-spacer { flex: 1; }

/* ═══ Guest area (Iniciar sesión + Crear cuenta) ═══ */
.ib-nav-guest { display: none; align-items: center; gap: 8px; }

.ib-nav-login {
  display: inline-flex; align-items: center;
  font-family: 'Manrope', sans-serif;
  font-size: 13px; font-weight: 600;
  color: var(--slate);
  text-decoration: none !important; /* fix: stop underline */
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--edge2);
  transition: all 0.18s;
  background: transparent;
  cursor: pointer;
}
.ib-nav-login:hover {
  color: var(--bright);
  border-color: var(--slate);
  background: rgba(255,255,255,0.03);
  text-decoration: none !important;
}

.ib-nav-cta {
  display: inline-flex; align-items: center;
  padding: 7px 18px; border-radius: 9px;
  font-size: 13px; font-weight: 700;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  text-decoration: none !important;
  box-shadow: 0 2px 10px rgba(37,99,235,0.3);
  transition: all 0.18s;
  border: none; cursor: pointer;
  font-family: 'Manrope', sans-serif;
}
.ib-nav-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59,130,246,0.4);
  color: white;
}

/* ═══ User pill (logged in) ═══ */
.ib-user-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(20,26,38,0.7);
  border: 1px solid var(--edge);
  border-radius: 20px;
  padding: 5px 14px 5px 5px;
  font-size: 12.5px; font-weight: 600;
  color: var(--slate);
  text-decoration: none !important;
  cursor: pointer;
  transition: all 0.18s;
  font-family: 'Manrope', sans-serif;
}
.ib-user-pill:hover {
  border-color: rgba(59,130,246,0.3);
  color: var(--bright);
  background: rgba(20,26,38,0.9);
}
.ib-user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, #1e3050, #2d4a70);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--blue3);
  flex-shrink: 0;
}
.ib-credits-badge {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--cyan);
  padding-left: 8px; border-left: 1px solid var(--edge);
}

/* ═══════════ USER DROPDOWN ═══════════ */
#ib-user-dropdown {
  background: rgba(16,21,31,0.98);
  backdrop-filter: blur(20px);
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(59,130,246,0.05);
  animation: dropdownIn 0.18s cubic-bezier(0.16,1,0.3,1);
  user-select: none;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ibd-header {
  padding: 10px 12px 12px;
}
.ibd-email {
  font-size: 12px; font-weight: 600;
  color: var(--bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ibd-credits {
  margin-top: 6px;
  display: flex; align-items: baseline; gap: 6px;
}
.ibd-credits-num {
  font-family: 'DM Mono', monospace;
  font-size: 18px; font-weight: 600;
  color: var(--cyan);
}
.ibd-credits-label {
  font-size: 11px; color: var(--silver);
}
.ibd-divider {
  height: 1px; background: var(--edge);
  margin: 6px 0;
}
.ibd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--light);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.ibd-item:hover {
  background: rgba(59,130,246,0.08);
  color: var(--blue3);
}
.ibd-item svg { color: var(--silver); flex-shrink: 0; }
.ibd-item:hover svg { color: var(--blue3); }
.ibd-item.ibd-logout { color: var(--red); }
.ibd-item.ibd-logout svg { color: var(--red); }
.ibd-item.ibd-logout:hover { background: rgba(239,68,68,0.08); color: var(--red); }
.ibd-item.ibd-logout:hover svg { color: var(--red); }

/* ═══════════ BUTTONS ═══════════ */
.ib-btn-primary {
  display: inline-flex; align-items: center; gap: 9px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white; font-weight: 700; font-size: 14px;
  padding: 13px 28px; border-radius: 12px;
  text-decoration: none !important; border: none; cursor: pointer;
  font-family: 'Manrope', sans-serif;
  box-shadow: 0 4px 20px rgba(37,99,235,0.35);
  transition: transform 0.18s, box-shadow 0.2s;
}
.ib-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(59,130,246,0.45);
  color: white;
}
.ib-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.ib-btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent;
  border: 1px solid var(--edge2);
  color: var(--slate); font-weight: 600; font-size: 13.5px;
  padding: 12px 24px; border-radius: 11px;
  text-decoration: none !important; cursor: pointer;
  font-family: 'Manrope', sans-serif;
  transition: all 0.2s;
}
.ib-btn-secondary:hover {
  border-color: rgba(59,130,246,0.4);
  color: var(--blue3);
  background: rgba(59,130,246,0.05);
}

/* ═══════════ CARDS ═══════════ */
.ib-card {
  background: rgba(16,21,31,0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 18px;
  position: relative; overflow: hidden;
}
.ib-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59,130,246,0.4), transparent);
  opacity: 0.5;
}

/* ═══════════ KICKER PILL ═══════════ */
.ib-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--blue3);
  background: rgba(59,130,246,0.06);
  border: 1px solid rgba(59,130,246,0.18);
  padding: 4px 13px; border-radius: 20px;
  user-select: none;
}

/* ═══════════ TOAST ═══════════ */
.ib-toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  display: flex; align-items: center; gap: 12px;
  background: rgba(16,21,31,0.97);
  border: 1px solid var(--edge);
  border-radius: 12px; padding: 12px 20px;
  box-shadow: 0 8px 36px rgba(0,0,0,0.5);
  z-index: 9999;
  backdrop-filter: blur(16px);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 92vw;
  font-size: 13px;
}
.ib-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.ib-toast.error { border-color: rgba(239,68,68,0.4); }
.ib-toast.success { border-color: rgba(16,185,129,0.4); }

/* ═══════════ FOOTER ═══════════ */
.ib-footer {
  border-top: 1px solid var(--edge);
  padding: 28px 24px;
  margin-top: auto;
  user-select: none;
}
.ib-footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 24px;
  justify-content: space-between; align-items: center;
}
.ib-footer-link {
  font-size: 12.5px; color: var(--silver);
  text-decoration: none; transition: color 0.18s;
}
.ib-footer-link:hover { color: var(--blue3); }
.ib-social { display: flex; gap: 8px; }
.ib-social-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--edge);
  display: flex; align-items: center; justify-content: center;
  color: var(--silver); text-decoration: none;
  transition: all 0.18s;
}
.ib-social-btn:hover {
  border-color: rgba(59,130,246,0.3);
  color: var(--blue3);
  background: rgba(59,130,246,0.05);
}
.ib-social-btn svg { width: 13px; height: 13px; fill: currentColor; }

/* ═══════════ AFFILIATE CTAs ═══════════ */
.ib-aff-cta {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, rgba(37,99,235,0.06), rgba(6,182,212,0.04));
  border: 1px solid rgba(59,130,246,0.18);
  border-radius: 12px;
  padding: 13px 16px;
  text-decoration: none !important;
  color: inherit;
  transition: all 0.18s;
  margin: 6px 0;
}
.ib-aff-cta:hover {
  border-color: rgba(59,130,246,0.4);
  background: linear-gradient(135deg, rgba(37,99,235,0.1), rgba(6,182,212,0.06));
  transform: translateY(-1px);
}
.ib-aff-logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--surface2);
  border: 1px solid var(--edge);
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 11px; font-weight: 600;
  color: var(--blue3);
  flex-shrink: 0;
}
.ib-aff-body { flex: 1; min-width: 0; }
.ib-aff-name {
  font-size: 13px; font-weight: 700;
  color: var(--bright); margin-bottom: 2px;
}
.ib-aff-benefit {
  font-size: 11.5px;
  color: var(--blue3);
  font-weight: 500;
}
.ib-aff-arrow {
  color: var(--blue3); flex-shrink: 0;
  font-size: 16px;
  transition: transform 0.18s;
}
.ib-aff-cta:hover .ib-aff-arrow { transform: translateX(3px); }

.ib-aff-cta.featured {
  background: linear-gradient(135deg, rgba(245,158,11,0.05), rgba(37,99,235,0.04));
  border-color: rgba(245,158,11,0.22);
}
.ib-aff-cta.featured .ib-aff-benefit { color: var(--amber); }
.ib-aff-cta.featured .ib-aff-arrow { color: var(--amber); }

/* ═══════════ DISCLAIMER ═══════════ */
.ib-disclaimer {
  font-size: 11px;
  color: var(--silver);
  background: rgba(245,158,11,0.03);
  border: 1px solid rgba(245,158,11,0.12);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 12px;
  line-height: 1.55;
}
.ib-disclaimer strong { color: var(--amber); }

/* ═══════════ UTILS ═══════════ */
.ib-mono { font-family: 'DM Mono', monospace; }
.ib-ok { color: var(--green); }
.ib-err { color: var(--red); }
.ib-muted { color: var(--silver); }
.ib-noselect { user-select: none; -webkit-user-select: none; }

/* Headers no seleccionables per defecte */
nav, .ib-footer, .ib-kicker, h1, h2, h3 {
  user-select: none;
  -webkit-user-select: none;
}

/* Mobile */
@media (max-width: 720px) {
  .ib-nav-link { display: none; }
  .ib-nav-login { padding: 6px 11px; font-size: 12px; }
  .ib-nav-cta { padding: 6px 14px; font-size: 12px; }
  .ib-user-pill span:not(#nav-credits):not(.ib-credits-badge) {
    display: none;
  }
  .ib-user-pill { padding: 5px 10px 5px 5px; }
  .ib-credits-badge { padding-left: 6px; }
}
