/* =============================================
   MAGAZINE MANAGER — EDITORIAL DESIGN SYSTEM
   ============================================= */

:root {
  --bg:          #F5F0E8;
  --surface:     #FFFEFB;
  --surface-2:   #F0EAE0;
  --surface-3:   #E8E1D6;
  --text-1:      #1A1410;
  --text-2:      #5C5048;
  --text-3:      #9B8F82;
  --accent:      #B82D1A;
  --accent-h:    #961E0C;
  --accent-soft: #F7EAE7;
  --border:      #DDD4C5;
  --border-l:    #EBE5DA;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 48px rgba(0,0,0,.12), 0 4px 16px rgba(0,0,0,.06);
  --radius:      10px;
  --radius-lg:   16px;
  --sidebar-w:   260px;
  --header-h:    64px;
  --font-display:'Playfair Display', Georgia, serif;
  --font-body:   'DM Sans', system-ui, sans-serif;
  --ease:        cubic-bezier(.22,.68,0,1.2);
}

/* RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
input, select { outline: none; }
.hidden { display: none !important; }

/* =============================================
   HEADER
   ============================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.brand-mark {
  font-size: 26px;
  color: var(--accent);
  line-height: 1;
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.3px;
  line-height: 1.2;
}
.brand-tagline {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: .4px;
  text-transform: uppercase;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-stat {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .18s, color .18s, box-shadow .18s, transform .12s var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-h); box-shadow: 0 4px 14px rgba(184,45,26,.3); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); }

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}
.btn-full { width: 100%; justify-content: center; }

.btn-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* =============================================
   MOBILE GROUPS
   ============================================= */
.mobile-groups {
  display: none;
  padding: 10px 16px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border-l);
}
.mobile-groups::-webkit-scrollbar { display: none; }

/* =============================================
   LAYOUT
   ============================================= */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 32px;
  align-items: start;
  min-height: calc(100vh - var(--header-h));
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  padding-top: 28px;
  padding-bottom: 40px;
}
.sidebar-sticky {
  position: sticky;
  top: calc(var(--header-h) + 20px);
}
.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.group-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.group-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
  color: var(--text-2);
  font-size: 13.5px;
}
.group-btn:hover { background: var(--surface-2); color: var(--text-1); }
.group-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.group-btn-icon { font-size: 16px; flex-shrink: 0; line-height: 1; }
.group-btn-name { flex: 1; line-height: 1.3; }
.group-btn-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-3);
  border-radius: 20px;
  padding: 1px 7px;
  flex-shrink: 0;
}
.group-btn.active .group-btn-count {
  background: rgba(184,45,26,.12);
  color: var(--accent);
}
.sidebar-divider {
  height: 1px;
  background: var(--border-l);
  margin: 20px 0;
}
.sort-pills {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sort-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background .15s;
}
.sort-pill:hover { background: var(--surface-2); }
.sort-pill input[type=radio] { accent-color: var(--accent); cursor: pointer; }
.sort-pill input[type=radio]:checked + span { color: var(--accent); font-weight: 600; }

/* =============================================
   MAIN CONTENT
   ============================================= */
.main {
  padding: 28px 0 60px;
  min-width: 0;
}
.content-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.content-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
  letter-spacing: -.4px;
}
.content-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}
.result-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  padding-bottom: 4px;
}

/* =============================================
   MAGAZINE GRID
   ============================================= */
.magazine-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

/* =============================================
   MAGAZINE CARD
   ============================================= */
.mag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s, transform .2s var(--ease);
  animation: fadeUp .3s var(--ease) both;
}
.mag-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mag-card-top {
  height: 5px;
  flex-shrink: 0;
}
.mag-card-body {
  padding: 18px 20px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mag-card-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mag-group-tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  opacity: .9;
}
.mag-edition-badge {
  font-size: 10px;
  font-weight: 600;
  color: #16a34a;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 20px;
}
.mag-edition-date {
  font-size: 11px;
  color: var(--text-3);
}

.mag-title {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.3;
  letter-spacing: -.2px;
}
.mag-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  flex: 1;
}

.mag-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.mag-pill {
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-3);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.mag-pill-type {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
}
.type-online  { background: #eff6ff; color: #2563eb; }
.type-both    { background: #fef3c7; color: #92400e; }
.type-fysiek  { background: #f0fdf4; color: #166534; }

.mag-popularity {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mag-pop-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mag-pop-label {
  font-size: 10.5px;
  color: var(--text-3);
  font-weight: 500;
}
.mag-pop-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
}
.mag-pop-bar {
  height: 5px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.mag-pop-fill {
  height: 100%;
  border-radius: 99px;
  width: 0;
  transition: width .8s cubic-bezier(.22,1,.36,1) .1s;
}

.mag-price {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.mag-price-val {
  font-weight: 600;
  color: var(--text-2);
}

.mag-card-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border-l);
  display: flex;
  gap: 8px;
}

/* Subscribe button states */
.btn-subscribe {
  flex: 1;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s, transform .12s;
}
.btn-subscribe:active { transform: scale(.96); }
.btn-subscribe.state-default {
  background: var(--accent);
  color: #fff;
}
.btn-subscribe.state-default:hover {
  background: var(--accent-h);
  box-shadow: 0 4px 12px rgba(184,45,26,.25);
}
.btn-subscribe.state-subscribed {
  background: #16a34a;
  color: #fff;
}
.btn-subscribe.state-subscribed:hover {
  background: #dc2626;
}

.btn-interest {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s, transform .12s;
  white-space: nowrap;
}
.btn-interest:hover { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.btn-interest.state-interested {
  background: #fffbeb;
  color: #d97706;
  border-color: #fde68a;
  font-weight: 600;
}
.btn-interest.state-interested:hover {
  background: #fef3c7;
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-3);
}
.empty-icon { font-size: 40px; display: block; margin-bottom: 12px; }

/* =============================================
   PROFILE DRAWER
   ============================================= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,20,16,.45);
  z-index: 200;
  backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 95vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex;
  flex-direction: column;
  animation: slideIn .25s var(--ease);
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.drawer-head {
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border-l);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.drawer-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
}
.drawer-email {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}
.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.drawer-close:hover { background: var(--surface-2); color: var(--text-1); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 24px;
}
.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.drawer-section {
  padding: 20px 24px 0;
}
.drawer-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.drawer-section-title .badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
}
.drawer-divider {
  height: 1px;
  background: var(--border-l);
  margin: 20px 24px 0;
}

.drawer-mag-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-l);
}
.drawer-mag-item:last-child { border-bottom: none; }
.drawer-mag-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.drawer-mag-info { flex: 1; min-width: 0; }
.drawer-mag-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
}
.drawer-mag-group {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.drawer-mag-btn {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
}
.drawer-mag-btn:active { transform: scale(.95); }
.drawer-btn-unsub {
  background: #fee2e2;
  color: #b91c1c;
}
.drawer-btn-unsub:hover { background: #fecaca; }
.drawer-btn-remove-interest {
  background: var(--surface-2);
  color: var(--text-3);
}
.drawer-btn-remove-interest:hover { background: var(--surface-3); color: var(--text-2); }

.drawer-empty {
  font-size: 13px;
  color: var(--text-3);
  padding: 8px 0;
  font-style: italic;
}
.drawer-suggest-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.drawer-suggest-btn:hover { background: var(--accent-h); }

/* =============================================
   AUTH MODAL
   ============================================= */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  width: 420px;
  max-width: 95vw;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  animation: popIn .25s var(--ease);
}
@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.95); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--surface-2); color: var(--text-1); }

.modal-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 28px;
}
.modal-tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.modal-tab.active {
  background: var(--surface);
  color: var(--text-1);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-head { margin-bottom: 4px; }
.auth-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}
.auth-head p { font-size: 13px; color: var(--text-3); }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.form-field input,
.form-field select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text-1);
  transition: border-color .15s, box-shadow .15s;
}
.form-field input:focus,
.form-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184,45,26,.08);
}
.form-field select { cursor: pointer; }
.optional { font-weight: 400; color: var(--text-3); }

.form-error {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
}
.form-switch {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}
.form-switch a {
  color: var(--accent);
  font-weight: 600;
}
.form-switch a:hover { text-decoration: underline; }

/* =============================================
   TOAST
   ============================================= */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-1);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  transition: opacity .25s, transform .25s var(--ease);
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: #15803d; }
.toast.error   { background: #b91c1c; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1100px) {
  .magazine-grid { grid-template-columns: repeat(2, 1fr); }
  :root { --sidebar-w: 220px; }
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }
  .sidebar { display: none; }
  .mobile-groups { display: flex; }
  .magazine-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .header-stat { display: none; }
  .brand-tagline { display: none; }
  .content-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 540px) {
  .magazine-grid { grid-template-columns: 1fr; }
  .modal { padding: 24px 20px; }
  .drawer { width: 100%; }
}

/* Mobile group chips */
.mobile-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.mobile-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Stagger animation for cards */
.mag-card:nth-child(1)  { animation-delay: .03s; }
.mag-card:nth-child(2)  { animation-delay: .06s; }
.mag-card:nth-child(3)  { animation-delay: .09s; }
.mag-card:nth-child(4)  { animation-delay: .12s; }
.mag-card:nth-child(5)  { animation-delay: .15s; }
.mag-card:nth-child(6)  { animation-delay: .18s; }
.mag-card:nth-child(7)  { animation-delay: .21s; }
.mag-card:nth-child(8)  { animation-delay: .24s; }
.mag-card:nth-child(9)  { animation-delay: .27s; }
.mag-card:nth-child(10) { animation-delay: .30s; }
