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

:root {
  --primary:   #4f46e5;
  --primary-h: #4338ca;
  --bg:        #f5f5f5;
  --card-bg:   #ffffff;
  --border:    #e0e0e0;
  --text:      #1f2937;
  --text-muted:#6b7280;
  --danger:    #ef4444;
  --success:   #22c55e;
  --radius:    12px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --transition:0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Navbar ────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 56px;
  box-shadow: var(--shadow);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -.3px;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .45rem 1rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--primary-h); }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: .9rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: .25rem .5rem;
  border-radius: 6px;
  transition: background var(--transition);
}
.btn-icon:hover { background: var(--bg); }

.btn-full { width: 100%; }

/* ── Main layout ───────────────────────────────────────────────── */
.main {
  max-width: 660px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ── SaaS Card ─────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.card-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .35rem;
}

.card-name a {
  color: var(--primary);
  text-decoration: none;
}
.card-name a:hover { text-decoration: underline; }

.card-desc {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.vote-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .3rem .8rem;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  color: var(--text);
}
.vote-btn:hover { border-color: var(--primary); color: var(--primary); }

.vote-btn.active-like {
  background: #ede9fe;
  border-color: var(--primary);
  color: var(--primary);
}
.vote-btn.active-dislike {
  background: #fee2e2;
  border-color: var(--danger);
  color: var(--danger);
}

.laugh-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .3rem .8rem;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  color: var(--text);
}
.laugh-btn:hover { border-color: #f59e0b; color: #f59e0b; }

.laugh-btn.active-laugh {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #f59e0b;
}

.comments-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .875rem;
  cursor: pointer;
  padding: .3rem .6rem;
  border-radius: 8px;
  margin-left: auto;
  transition: color var(--transition), background var(--transition);
}
.comments-btn:hover { color: var(--primary); background: var(--bg); }

/* ── Spinner ───────────────────────────────────────────────────── */
.spinner {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0;
}
.spinner-circle {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.end-message {
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
  padding: 1.5rem 0;
}

/* ── Comments panel ────────────────────────────────────────────── */
.comments-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 200;
}
.comments-panel.open { transform: translateX(0); }

.comments-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.comments-panel-title {
  font-weight: 700;
  font-size: .95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .875rem;
}

.comment-item {
  background: var(--bg);
  border-radius: 8px;
  padding: .75rem 1rem;
}
.comment-author {
  font-size: .8rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: .3rem;
}
.comment-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-left: .5rem;
  font-weight: 400;
}
.comment-text {
  font-size: .875rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.comments-empty {
  color: var(--text-muted);
  font-size: .875rem;
  text-align: center;
  margin-top: 1rem;
}

.comments-load-more {
  text-align: center;
  margin-top: .5rem;
}

.comments-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.comments-login-msg { font-size: .875rem; color: var(--text-muted); }

.comment-textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: .875rem;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  margin-bottom: .5rem;
  transition: border-color var(--transition);
}
.comment-textarea:focus { outline: none; border-color: var(--primary); }

/* ── Overlay ───────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 150;
  backdrop-filter: blur(2px);
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}

.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  position: relative;
}

.modal-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
}

.modal-box h2 {
  margin-bottom: 1.25rem;
  font-size: 1.25rem;
}

.modal-box p { margin-bottom: .75rem; line-height: 1.6; }

/* ── Form ──────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .875rem;
}
.form-group label { font-size: .875rem; font-weight: 600; }
.form-group input {
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
}
.form-group input:focus { outline: none; border-color: var(--primary); }

.form-error {
  color: var(--danger);
  font-size: .825rem;
  margin-bottom: .75rem;
}
.form-toggle {
  font-size: .875rem;
  text-align: center;
  margin-top: .75rem;
  color: var(--text-muted);
}

/* ── Misc ──────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.user-greeting { font-size: .9rem; font-weight: 600; color: var(--text); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .comments-panel { width: 100%; border-left: none; }
  .main { margin-top: 1rem; }
}
