/* ── Messages / Chat UI ─────────────────────────────── */
.messages-container {
  display: flex;
  height: calc(100vh - 120px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

/* Sidebar */
.messages-sidebar {
  width: 300px;
  min-width: 240px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary, var(--bg-card));
  flex-shrink: 0;
}

.messages-search {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.messages-contacts {
  flex: 1;
  overflow-y: auto;
}

.msg-contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  position: relative;
}

.msg-contact-item:hover {
  background: rgba(255,255,255,0.04);
}

.msg-contact-item.active {
  background: rgba(var(--primary-rgb, 99,102,241), 0.12);
}

.msg-contact-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent, #8b5cf6));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.msg-contact-info {
  flex: 1;
  overflow: hidden;
}

.msg-contact-name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-contact-last {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.msg-badge {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Chat area */
.messages-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.messages-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.messages-chat-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  font-weight: 600;
}

.messages-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-primary, var(--bg-secondary));
}

.messages-chat-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

/* Message bubbles */
.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.msg-bubble-wrap.sent {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble-wrap.received {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.msg-bubble-wrap.sent .msg-bubble {
  background: var(--bg-secondary, rgba(255,255,255,0.06));
  border-radius: 16px 16px 4px 16px;
  color: var(--text-primary);
}

.msg-bubble-wrap.received .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--accent, #8b5cf6));
  border-radius: 16px 16px 16px 4px;
  color: #fff;
}

.msg-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* Balance view */
.balance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.balance-amount {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.balance-amount.positive { color: #22c55e; }
.balance-amount.negative { color: #ef4444; }
.balance-amount.zero     { color: var(--text-muted); }

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--bg-secondary, rgba(255,255,255,0.03));
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.tx-icon.credit { background: rgba(34,197,94,0.15); }
.tx-icon.debit  { background: rgba(239,68,68,0.15); }

.tx-amount {
  font-weight: 700;
  font-size: 0.95rem;
}

.tx-amount.credit { color: #22c55e; }
.tx-amount.debit  { color: #ef4444; }

/* Responsive */
@media (max-width: 640px) {
  .messages-container { flex-direction: column; height: auto; }
  .messages-sidebar { width: 100%; border-left: none; border-bottom: 1px solid var(--border); max-height: 220px; }
  .messages-chat { height: 60vh; }
  .msg-bubble-wrap { max-width: 90%; }
}

/* ── Date header in chat ──────────────────────────────── */
.msg-date-header {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 6px 12px;
  background: var(--bg-card);
  border-radius: 20px;
  margin: 10px auto;
  width: fit-content;
  border: 1px solid var(--border);
}

/* ── Online status dot ───────────────────────────────── */
.msg-online-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.6);
}

/* ══════════════════════════════════════════════════════════
   MATERIALS (دروسي) 
   ══════════════════════════════════════════════════════════ */

/* Tabs */
.materials-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
  margin-bottom: 4px;
}

.materials-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  border-radius: 8px 8px 0 0;
}

.materials-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255,255,255,0.04);
}

.materials-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Material Card */
.material-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--mat-color, var(--primary));
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.material-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.material-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.material-type-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.material-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
}

.material-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.material-card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 6px 0;
  margin-top: auto;
  transition: opacity 0.2s;
}
.material-card-link:hover { opacity: 0.75; text-decoration: underline; }

.material-card-footer {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

