/* ═══════════════════════════════════════════════════════════════
   LOTUS ACADEMY — Messages / Chat · Balance · Materials
   ═══════════════════════════════════════════════════════════════ */

/* ── Messages Container ──────────────────────────────────────── */
.messages-container {
  display: flex;
  height: calc(100vh - 105px);
  min-height: 540px;
  border-radius: var(--radius-lg, 16px);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

/* Messages Sidebar */
.messages-sidebar {
  width: 360px;
  min-width: 320px;
  max-width: 420px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-secondary, var(--bg-card));
  flex-shrink: 0;
  transition: width 0.2s ease;
}

body.lang-fr .messages-sidebar {
  border-left: none;
  border-right: 1px solid var(--border);
}

.messages-search {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  flex-shrink: 0;
}

.messages-contacts {
  flex: 1;
  height: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.35) transparent;
  padding: 4px 0;
}

.messages-contacts::-webkit-scrollbar {
  width: 6px;
}

.messages-contacts::-webkit-scrollbar-track {
  background: transparent;
}

.messages-contacts::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 6px;
}

.messages-contacts::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.6);
}

.msg-contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.18s ease;
  position: relative;
}

.msg-contact-item:hover {
  background: rgba(139, 92, 246, 0.08);
}

.msg-contact-item.active {
  background: rgba(123, 44, 191, 0.15);
  border-right: 3px solid var(--primary, #7B2CBF);
}

body.lang-fr .msg-contact-item.active {
  border-right: none;
  border-left: 3px solid var(--primary, #7B2CBF);
}

.msg-contact-avatar {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--brand-gradient, linear-gradient(135deg, #7B2CBF, #9D4EDD));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.92rem;
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(123, 44, 191, 0.3);
}

.msg-contact-info {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.msg-contact-name {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  color: var(--text-main);
  margin-bottom: 2px;
}

.msg-contact-last {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.msg-badge {
  background: var(--brand-gradient, linear-gradient(135deg, #7B2CBF, #9D4EDD));
  color: #fff;
  border-radius: var(--radius-pill, 20px);
  padding: 3px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(123, 44, 191, 0.4);
}

/* Chat Area */
.messages-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-card);
}

.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 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  font-weight: 700;
  gap: 12px;
}

.messages-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-body);
}

.messages-chat-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 18px;
  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: 11px 16px;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
}

.msg-bubble-wrap.sent .msg-bubble {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border);
  border-radius: 18px 18px 6px 18px;
  color: var(--text-main);
}

.msg-bubble-wrap.received .msg-bubble {
  background: var(--brand-gradient);
  border-radius: 18px 18px 18px 6px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(109, 40, 217, 0.35);
}

.msg-time {
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* Date Header in Chat */
.msg-date-header {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 5px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  margin: 12px auto;
  width: fit-content;
  border: 1px solid var(--border);
}

/* Online Status Dot */
.msg-online-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}



/* ══════════════════════════════════════════════════════════════
   BALANCE VIEW
   ══════════════════════════════════════════════════════════════ */
.balance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.balance-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--brand-gradient);
}

.balance-amount {
  font-family: 'Sora', sans-serif;
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.balance-amount.positive {
  background: linear-gradient(135deg, #10B981, #34D399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.balance-amount.negative { color: var(--danger-light); }
.balance-amount.zero     { color: var(--text-muted); }

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.18s ease;
}

.tx-item:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.tx-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.tx-icon.credit { background: rgba(16, 185, 129, 0.14); color: var(--success); }
.tx-icon.debit  { background: rgba(239, 68, 68, 0.12);  color: var(--danger-light); }

.tx-amount {
  font-weight: 700;
  font-size: 0.92rem;
}

.tx-amount.credit { color: var(--success); }
.tx-amount.debit  { color: var(--danger-light); }

/* ══════════════════════════════════════════════════════════════
   MATERIALS
   ══════════════════════════════════════════════════════════════ */
.materials-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  margin-bottom: 8px;
}

.materials-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.materials-tab-btn:hover {
  color: var(--text-main);
  background: rgba(139, 92, 246, 0.08);
}

.materials-tab-btn.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

/* Material Card */
.material-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--mat-color, var(--accent));
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.material-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lotus);
}

.material-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.material-type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.material-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.material-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
  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.8rem;
  font-weight: 700;
  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.7rem;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ── Mobile Chat Responsive Layout ────────────────────────── */
.msg-mobile-back {
  display: none;
  margin-inline-end: 8px;
  padding: 6px 8px;
  border-radius: 8px;
}

@media (max-width: 768px) {
  .messages-container {
    height: calc(100dvh - 100px);
    min-height: 480px;
    border-radius: var(--radius-sm, 12px);
    position: relative;
    overflow: hidden;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  .messages-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    border-left: none;
    border-right: none;
    height: 100% !important;
    flex: 1 1 100% !important;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
  }

  .messages-search {
    padding: 10px 12px 6px;
    flex-shrink: 0;
  }

  .messages-contacts {
    flex: 1 1 auto !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding-bottom: 24px;
  }

  .msg-contact-item {
    padding: 14px 14px;
    min-height: 68px;
    gap: 12px;
  }

  .msg-contact-avatar {
    width: 44px;
    height: 44px;
    font-size: 0.9rem;
    border-radius: 12px;
  }

  .messages-chat {
    width: 100% !important;
    min-width: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    z-index: 10;
    display: none !important;
    height: 100% !important;
    flex-direction: column;
  }

  .messages-container.chat-active .messages-sidebar {
    display: none !important;
  }

  .messages-container.chat-active .messages-chat {
    display: flex !important;
  }

  .msg-mobile-back {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
  }

  .messages-chat-header {
    padding: 10px 14px;
    min-height: 56px;
    flex-shrink: 0;
  }

  .messages-chat-body {
    flex: 1 1 auto;
    height: 0;
    min-height: 0;
    padding: 14px 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .messages-chat-input {
    padding: 10px 12px;
    flex-shrink: 0;
  }

  .msg-bubble {
    max-width: 85% !important;
    padding: 10px 14px !important;
    font-size: 0.88rem !important;
  }
}

