/* ============================================================
   MITRA — Reusable Components
   ============================================================ */

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  overflow: hidden;
  flex-shrink: 0;
  font-weight: var(--font-weight-semibold);
  color: #fff;
  background: var(--brand-gradient);
  user-select: none;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.avatar-xs  { width: 28px; height: 28px; font-size: 11px; }
.avatar-sm  { width: 36px; height: 36px; font-size: 13px; }
.avatar-md  { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg  { width: 56px; height: 56px; font-size: 20px; }
.avatar-xl  { width: 72px; height: 72px; font-size: 26px; }
.avatar-2xl { width: 90px; height: 90px; font-size: 32px; }

/* Story ring */
.avatar-story {
  padding: 2px;
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888, #0068FF);
}
.avatar-story::before {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--bg-primary);
  border-radius: inherit;
  z-index: 0;
}
.avatar-story img,
.avatar-story span {
  position: relative;
  z-index: 1;
  border-radius: var(--radius-full);
}

/* Online indicator */
.avatar-online::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: var(--color-online);
  border: 2px solid var(--bg-primary);
  border-radius: var(--radius-full);
}

/* ── Badge ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-full);
  line-height: 1;
}
.badge-brand { background: var(--brand-primary); }
.badge-lg { min-width: 22px; height: 22px; font-size: 11px; }

/* ── Button ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  user-select: none;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  border-radius: inherit;
  transition: background var(--transition-fast);
}
.btn:hover::after { background: rgba(255,255,255,0.1); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(0, 104, 255, 0.5); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-sm { padding: 6px 14px; font-size: var(--font-size-sm); }
.btn-lg { padding: 14px var(--space-8); font-size: var(--font-size-lg); }
.btn-icon {
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}
.btn-icon-sm { width: 32px; height: 32px; }
.btn-icon-lg { width: 48px; height: 48px; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Input ────────────────────────────────────────────────── */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-field {
  width: 100%;
  padding: 12px var(--space-4);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--font-size-md);
  font-family: inherit;
  transition: all var(--transition-base);
}
.input-field:focus {
  border-color: var(--brand-primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-alpha);
}
.input-field::placeholder { color: var(--text-tertiary); }
.input-field.has-icon { padding-left: 44px; }
.input-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
}

/* Search input */
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-secondary);
  border: 1.5px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: inherit;
  transition: all var(--transition-base);
}
.search-input:focus {
  border-color: var(--brand-primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-alpha);
}
.search-input::placeholder { color: var(--text-tertiary); }
.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-tertiary);
  font-size: var(--font-size-sm);
}
.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* ── Icon Button ──────────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn.active {
  color: var(--brand-primary);
  background: var(--brand-primary-alpha);
}

/* ── Toast / Notification ─────────────────────────────────── */
#toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px var(--space-4);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 320px;
  animation: fadeInRight 300ms ease both;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}
.toast.removing {
  animation: fadeInRight 250ms ease reverse both;
}
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-weight: var(--font-weight-semibold); margin-bottom: 2px; }
.toast-msg   { color: var(--text-secondary); font-size: 12px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 200ms ease both;
}
.modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 400px;
  animation: scaleIn 220ms ease both;
  overflow: hidden;
}
.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}
.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ── Shimmer skeleton ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-tertiary) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}

/* ── Tooltip ──────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-dropdown);
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Emoji Picker ─────────────────────────────────────────── */
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-3);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: 280px;
  animation: scaleIn 180ms ease both;
  transform-origin: bottom left;
  z-index: var(--z-dropdown);
}
.emoji-picker button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  cursor: pointer;
}
.emoji-picker button:hover { background: var(--bg-hover); }

/* ── Context Menu ─────────────────────────────────────────── */
.context-menu {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-2);
  min-width: 180px;
  z-index: var(--z-dropdown);
  animation: scaleIn 150ms ease both;
}
.context-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.context-menu-item:hover { background: var(--bg-hover); }
.context-menu-item.danger { color: var(--color-danger); }
.context-menu-divider { height: 1px; background: var(--border-color); margin: var(--space-1) 0; }
