/* ==========================================================================
   QueTogether — Återanvändbara komponenter
   Knappar, kort, badges, avatarer, formulär, chips, pills m.m.
   ========================================================================== */

/* ---------- Knappar ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 12px 22px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover { box-shadow: 0 10px 40px rgba(124, 58, 237, 0.5); transform: translateY(-1px); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline:hover { background: var(--surface-2); }

.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.btn-lg { padding: 15px 30px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; width: 42px; height: 42px; border-radius: var(--r-md); }

/* ---------- Kort ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
.card-hover:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  background: var(--surface-2);
}
.card-glass {
  background: rgba(20, 20, 28, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---------- Badges & pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: rgba(34, 197, 94, 0.14); color: var(--online); }
.badge-info { background: rgba(56, 189, 248, 0.14); color: var(--info); }
.badge-warn { background: rgba(245, 158, 11, 0.14); color: var(--away); }
.badge-neutral { background: var(--surface-3); color: var(--text-muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s ease;
  cursor: pointer;
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.is-active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* ---------- Avatarer ---------- */
.avatar {
  position: relative;
  border-radius: var(--r-full);
  overflow: visible;
  flex-shrink: 0;
  background: var(--gradient);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
}
.avatar img { width: 100%; height: 100%; border-radius: var(--r-full); object-fit: cover; }
.avatar-sm { width: 34px; height: 34px; font-size: 0.8rem; }
.avatar-md { width: 44px; height: 44px; font-size: 0.95rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-xl { width: 104px; height: 104px; font-size: 2rem; }
.avatar .status-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 30%;
  height: 30%;
  min-width: 9px;
  min-height: 9px;
  border-radius: var(--r-full);
  border: 2px solid var(--bg);
  background: var(--text-dim);
}
.status-dot.online { background: var(--online); }
.status-dot.away { background: var(--away); }
.status-dot.busy { background: var(--busy); }

/* ---------- Formulär ---------- */
.field { margin-bottom: var(--sp-4); }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.input,
.textarea,
.select {
  width: 100%;
  padding: 13px 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { resize: vertical; min-height: 110px; }

.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 14px;
}
.input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-group svg { width: 18px; height: 18px; color: var(--text-dim); flex-shrink: 0; }
.input-group input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 13px 0;
}

/* ---------- Sektionshuvud ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.section-head h2 { font-size: 1.6rem; }
.eyebrow {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.link-more {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}
.link-more:hover { color: var(--primary); }

/* ---------- Grid-hjälp ---------- */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Divider ---------- */
.divider { height: 1px; background: var(--border); margin: var(--sp-5) 0; border: none; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  min-width: 240px;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Språkväljare ---------- */
.lang-switch { position: relative; }
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}
.lang-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.lang-btn .lang-flag { font-size: 1.05rem; line-height: 1; }
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 300;
}
.lang-switch.open .lang-menu { display: block; }
.lang-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.lang-item:hover { background: var(--surface-hover); color: var(--text); }
.lang-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.lang-item .lang-flag { font-size: 1.15rem; line-height: 1; }
/* Flytande variant (auth/404 utan header) */
.lang-switch--floating { position: fixed; top: 20px; right: 20px; z-index: 400; }
:root.rtl .lang-switch--floating { right: auto; left: 20px; }
/* RTL: öppna menyn åt andra hållet */
:root.rtl .lang-menu { right: auto; left: 0; }

/* ==========================================================================
   RTL-stöd (arabiska)
   ========================================================================== */
:root.rtl body { direction: rtl; }
:root.rtl .sidebar { border-right: none; border-left: 1px solid var(--border); }
:root.rtl .sidebar-nav a .count { margin-left: 0; margin-right: auto; }
:root.rtl .site-nav a.is-active::after { left: 0; right: 0; }
:root.rtl .app-topbar .spacer { }
:root.rtl .icon-btn .dot { right: auto; left: 9px; }
:root.rtl .avatar .status-dot { right: auto; left: 0; }
:root.rtl .clip-rail { right: auto; left: 12px; }
:root.rtl .comment-drawer { right: auto; left: 0; border-left: none; border-right: 1px solid var(--border-strong); border-radius: var(--r-xl) 0 0 var(--r-xl); transform: translateX(-100%); }
:root.rtl .comment-drawer.open { transform: none; }
:root.rtl .conv { border-left: none; border-right: 3px solid transparent; }
:root.rtl .conv.is-active { border-right-color: var(--primary); }
:root.rtl .msg.out { border-bottom-right-radius: 16px; border-bottom-left-radius: 4px; }
:root.rtl .msg.in { border-bottom-left-radius: 16px; border-bottom-right-radius: 4px; }
:root.rtl .auth-visual { order: 2; }
:root.rtl .stat-tile .st-trend,
:root.rtl .list-row .lr-time { direction: ltr; }
/* Behåll ikonernas riktning vettig i RTL */
:root.rtl .btn svg,
:root.rtl .link-more { }
