/* ===================================
   PROFILE — Dashboard Layout + Mobile Native
   Complete Overhaul v2
   =================================== */

/* --- Auth Gate --- */
.auth-gate { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: var(--space-6); background: var(--color-bg); }
.auth-card { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-2xl); padding: var(--space-10); max-width: 440px; width: 100%; text-align: center; box-shadow: var(--shadow-xl); }
.auth-card__icon { width: 72px; height: 72px; margin: 0 auto var(--space-6); border-radius: var(--radius-xl); background: var(--color-accent-light); display: flex; align-items: center; justify-content: center; color: var(--color-accent); }
.auth-card__icon i { width: 32px; height: 32px; }
.auth-card h1 { font-size: var(--text-2xl); margin-bottom: var(--space-2); }
.auth-card .text-secondary { margin-bottom: var(--space-6); font-size: var(--text-sm); }
.auth-card .form-group { text-align: left; margin-bottom: var(--space-4); }
.auth-sent__icon { width: 72px; height: 72px; margin: 0 auto var(--space-4); border-radius: 50%; background: var(--color-success-light); display: flex; align-items: center; justify-content: center; color: var(--color-success); }
.auth-sent__icon i { width: 32px; height: 32px; }
.auth-sent h2 { margin-bottom: var(--space-2); }
.dev-link-box { margin-top: var(--space-4); padding: var(--space-4); background: var(--color-info-light); border-radius: var(--radius-md); font-size: var(--text-sm); text-align: left; word-break: break-all; }

/* --- Profile Layout --- */
.profile-body { background: var(--color-bg); }
.profile-layout { display: flex; min-height: 100vh; padding-top: var(--nav-height); }

/* --- Desktop Sidebar --- */
.profile-sidebar { width: var(--sidebar-width); background: var(--color-bg-card); border-right: 1px solid var(--color-border); display: flex; flex-direction: column; position: fixed; top: var(--nav-height); left: 0; bottom: 0; z-index: 10; overflow-y: auto; }
.profile-sidebar__user { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-6); border-bottom: 1px solid var(--color-border); }
.profile-sidebar__avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, var(--color-accent), #FF6B6B); display: flex; align-items: center; justify-content: center; color: white; flex-shrink: 0; font-weight: var(--weight-bold); font-size: var(--text-lg); }
.profile-sidebar__name { font-weight: var(--weight-semibold); font-size: var(--text-base); color: var(--color-text); }
.profile-sidebar__email { font-size: var(--text-xs); color: var(--color-text-muted); word-break: break-all; }
.profile-sidebar__nav { padding: var(--space-4); flex: 1; display: flex; flex-direction: column; gap: var(--space-1); }
.sidebar-tab { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: none; background: none; border-radius: var(--radius-lg); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-secondary); cursor: pointer; transition: all var(--transition-fast); text-align: left; width: 100%; font-family: var(--font-body); }
.sidebar-tab i { color: var(--color-text-muted); transition: color var(--transition-fast); }
.sidebar-tab:hover { background: var(--color-bg-alt); color: var(--color-text); }
.sidebar-tab:hover i { color: var(--color-text-secondary); }
.sidebar-tab--active { background: var(--color-accent-light); color: var(--color-accent); font-weight: var(--weight-semibold); }
.sidebar-tab--active i { color: var(--color-accent); }
.sidebar-tab span:first-of-type { flex: 1; }
.sidebar-tab__badge { padding: 1px 8px; background: var(--color-accent); color: white; border-radius: var(--radius-full); font-size: 0.65rem; font-weight: var(--weight-bold); min-width: 20px; text-align: center; }
.sidebar-tab__badge--notif { background: #EF4444; }
.profile-sidebar__footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border); }
.sidebar-link { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); text-decoration: none; transition: color var(--transition-fast); }
.sidebar-link:hover { color: var(--color-text); }

/* --- Main Content --- */
.profile-main { flex: 1; margin-left: var(--sidebar-width); padding: var(--space-8) var(--space-10); max-width: 900px; }
.profile-tab__header { margin-bottom: var(--space-6); }
.profile-tab__header h2 { font-size: var(--text-2xl); font-weight: var(--weight-bold); margin-bottom: var(--space-1); }
.mobile-header { display: none; }

/* --- Notification Bell --- */
.notif-bell { position: relative; background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: var(--space-2); border-radius: var(--radius-md); transition: all var(--transition-fast); }
.notif-bell:hover { background: var(--color-bg-alt); color: var(--color-text); }
.notif-bell__badge { position: absolute; top: -2px; right: -4px; padding: 1px 5px; background: #EF4444; color: white; border-radius: var(--radius-full); font-size: 0.55rem; font-weight: var(--weight-bold); min-width: 16px; text-align: center; line-height: 1.4; }

/* --- Notifications Panel --- */
.notif-panel { position: absolute; top: 60px; right: var(--space-5); width: 380px; max-height: 420px; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); z-index: 100; overflow: hidden; animation: slideDown 0.2s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.notif-panel__header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.notif-panel__header h3 { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.notif-panel__close { background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: var(--space-1); border-radius: var(--radius-md); }
.notif-panel__close:hover { background: var(--color-bg-alt); }
.notif-panel__list { overflow-y: auto; max-height: 360px; }

.notif-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-bg-alt); cursor: default; transition: background var(--transition-fast); }
.notif-item:hover { background: var(--color-bg-alt); }
.notif-item:last-child { border-bottom: none; }
.notif-item__icon { width: 36px; height: 36px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-item__icon--info { background: var(--color-info-light); color: var(--color-info); }
.notif-item__icon--success { background: var(--color-success-light); color: var(--color-success); }
.notif-item__icon--warning { background: var(--color-warning-light); color: #92400E; }
.notif-item__icon--message { background: var(--color-accent-light); color: var(--color-accent); }
.notif-item__icon i { width: 16px; height: 16px; }
.notif-item__content { flex: 1; min-width: 0; }
.notif-item__text { font-size: var(--text-sm); color: var(--color-text); line-height: 1.4; }
.notif-item__time { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 2px; }

/* --- Loading & Empty States --- */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-16) 0; color: var(--color-text-muted); gap: var(--space-4); }
.loading-spinner { width: 36px; height: 36px; border: 3px solid var(--color-border); border-top-color: var(--color-accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: var(--space-16) var(--space-6); }
.empty-state__icon { width: 72px; height: 72px; margin: 0 auto var(--space-4); border-radius: 50%; background: var(--color-bg-alt); display: flex; align-items: center; justify-content: center; color: var(--color-text-muted); }
.empty-state__icon i { width: 32px; height: 32px; }
.empty-state__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin-bottom: var(--space-2); }
.empty-state__text { font-size: var(--text-sm); color: var(--color-text-muted); }

/* --- Transaction Cards --- */
.tx-card { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); margin-bottom: var(--space-4); overflow: hidden; transition: all var(--transition-base); }
.tx-card:hover { box-shadow: var(--shadow-md); }
.tx-card__header { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5); cursor: pointer; }
.tx-card__img { width: 72px; height: 54px; border-radius: var(--radius-md); overflow: hidden; background: var(--color-muted); flex-shrink: 0; }
.tx-card__img img { width: 100%; height: 100%; object-fit: cover; }
.tx-card__info { flex: 1; min-width: 0; }
.tx-card__title { font-weight: var(--weight-semibold); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-card__ref { font-size: var(--text-xs); color: var(--color-text-muted); font-family: monospace; }
.tx-card__right { text-align: right; flex-shrink: 0; }
.tx-card__amount { font-weight: var(--weight-bold); font-size: var(--text-lg); margin-bottom: 2px; }
.tx-card__date { font-size: var(--text-xs); color: var(--color-text-muted); }
.tx-card__toggle { color: var(--color-text-muted); transition: transform var(--transition-fast); flex-shrink: 0; padding: var(--space-2); }
.tx-card__toggle--open { transform: rotate(180deg); }
.tx-card__detail { display: none; border-top: 1px solid var(--color-border); }
.tx-card__detail--open { display: block; }
.tx-card__detail-inner { padding: var(--space-5); }

/* Timeline */
.timeline { position: relative; padding-left: var(--space-8); }
.timeline::before { content: ''; position: absolute; left: 11px; top: 4px; bottom: 4px; width: 2px; background: var(--color-border); }
.timeline__item { position: relative; padding-bottom: var(--space-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot { width: 24px; height: 24px; border-radius: 50%; background: var(--color-bg-alt); border: 2px solid var(--color-border); position: absolute; left: calc(-1 * var(--space-8)); top: 0; display: flex; align-items: center; justify-content: center; }
.timeline__dot--completed { background: var(--color-success); border-color: var(--color-success); }
.timeline__dot--completed::after { content: '✓'; color: white; font-size: 10px; font-weight: bold; }
.timeline__dot--pending { background: var(--color-warning); border-color: var(--color-warning); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); } 50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); } }
.timeline__title { font-size: var(--text-sm); font-weight: var(--weight-medium); margin-bottom: 2px; }
.timeline__date { font-size: var(--text-xs); color: var(--color-text-muted); }
.timeline__note { font-size: var(--text-xs); color: var(--color-text-secondary); margin-top: 2px; }

/* TX Actions */
.tx-actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); flex-wrap: wrap; }
.tx-actions .btn { flex: 1; min-width: 140px; }

/* --- Admin Gating Lock --- */
.tx-gate-msg { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); margin-top: var(--space-4); background: var(--color-warning-light); border-radius: var(--radius-lg); font-size: var(--text-sm); color: #92400E; }
.tx-gate-msg i { width: 18px; height: 18px; flex-shrink: 0; }

/* --- Dispute Form --- */
.dispute-form { margin-top: var(--space-5); padding: var(--space-5); background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: var(--radius-xl); display: none; animation: slideDown 0.25s ease; }
.dispute-form--open { display: block; }
.dispute-form__title { font-size: var(--text-base); font-weight: var(--weight-semibold); margin-bottom: var(--space-4); color: #DC2626; display: flex; align-items: center; gap: var(--space-2); }
.dispute-form .form-group { margin-bottom: var(--space-4); }
.dispute-form .form-label { font-size: var(--text-sm); font-weight: var(--weight-medium); margin-bottom: var(--space-2); display: block; }
.dispute-form .form-input, .dispute-form .form-select, .dispute-form .form-textarea { width: 100%; padding: var(--space-3) var(--space-4); border: 1.5px solid var(--color-border); border-radius: var(--radius-md); font-size: var(--text-sm); font-family: var(--font-body); background: var(--color-bg-card); color: var(--color-text); transition: border-color var(--transition-fast); }
.dispute-form .form-input:focus, .dispute-form .form-select:focus, .dispute-form .form-textarea:focus { outline: none; border-color: var(--color-accent); }
.dispute-form .form-textarea { min-height: 100px; resize: vertical; }

/* --- Vehicle Link Button --- */
.tx-vehicle-link { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--color-accent-light); color: var(--color-accent); border-radius: var(--radius-md); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-decoration: none; transition: all var(--transition-fast); margin-top: var(--space-2); }
.tx-vehicle-link:hover { background: var(--color-accent); color: white; }
.tx-vehicle-link i { width: 14px; height: 14px; }

.tx-report-link { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--color-danger-light); color: var(--color-danger); border-radius: var(--radius-md); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-decoration: none; border: none; cursor: pointer; transition: all var(--transition-fast); margin-top: var(--space-2); margin-left: var(--space-2); }
.tx-report-link:hover { background: var(--color-danger); color: white; }
.tx-report-link i { width: 14px; height: 14px; }

/* --- Report Form --- */
.report-form { margin-top: var(--space-5); padding: var(--space-5); background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: var(--radius-xl); display: none; animation: slideDown 0.25s ease; }
.report-form--open { display: block; }
.report-form__title { font-size: var(--text-base); font-weight: var(--weight-semibold); margin-bottom: var(--space-4); color: #B45309; display: flex; align-items: center; gap: var(--space-2); }
.report-form .form-group { margin-bottom: var(--space-4); }
.report-form .form-label { font-size: var(--text-sm); font-weight: var(--weight-medium); margin-bottom: var(--space-2); display: block; }
.report-form .form-input, .report-form .form-select, .report-form .form-textarea { width: 100%; padding: var(--space-3) var(--space-4); border: 1.5px solid var(--color-border); border-radius: var(--radius-md); font-size: var(--text-sm); font-family: var(--font-body); background: var(--color-bg-card); color: var(--color-text); transition: border-color var(--transition-fast); }
.report-form .form-input:focus, .report-form .form-select:focus, .report-form .form-textarea:focus { outline: none; border-color: var(--color-accent); }
.report-form .form-textarea { min-height: 80px; resize: vertical; }

/* --- Badge --- */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 3px 10px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-medium); flex-shrink: 0; }
.badge--warning { background: var(--color-warning-light); color: #92400E; }
.badge--info { background: var(--color-info-light); color: #1E40AF; }
.badge--success { background: var(--color-success-light); color: #166534; }
.badge--danger { background: var(--color-danger-light); color: #991B1B; }
.badge--neutral { background: var(--color-bg-alt); color: var(--color-text-muted); }

/* ===================================
   MESSAGES
   =================================== */

.conversations-list { display: flex; flex-direction: column; gap: var(--space-3); }

/* Support Pinned Card */
.conversation-card--support { border: 1.5px solid var(--color-accent); background: linear-gradient(135deg, rgba(212, 175, 55, 0.04), rgba(212, 175, 55, 0.01)); }
.conversation-card--support .conversation-card__avatar { background: linear-gradient(135deg, var(--color-accent), #C49B30); }
.conversation-card--support .conversation-card__name::after { content: 'Support'; margin-left: var(--space-2); padding: 1px 8px; background: var(--color-accent); color: white; border-radius: var(--radius-full); font-size: 0.6rem; font-weight: var(--weight-bold); vertical-align: middle; }

/* Conversation Card */
.conversation-card { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); cursor: pointer; transition: all var(--transition-fast); position: relative; }
.conversation-card:hover { box-shadow: var(--shadow-md); border-color: var(--color-border-hover); }
.conversation-card__avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, #334155, #475569); display: flex; align-items: center; justify-content: center; color: white; font-weight: var(--weight-bold); flex-shrink: 0; font-size: var(--text-sm); }
.conversation-card__info { flex: 1; min-width: 0; }
.conversation-card__name { font-weight: var(--weight-semibold); font-size: var(--text-sm); margin-bottom: 2px; }
.conversation-card__preview { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-card__meta { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.conversation-card__time { font-size: var(--text-xs); color: var(--color-text-muted); }
.conversation-card__unread { padding: 1px 6px; background: #EF4444; color: white; border-radius: var(--radius-full); font-size: 0.6rem; font-weight: var(--weight-bold); min-width: 18px; text-align: center; }

/* Conversation actions menu */
.conversation-card__actions { position: absolute; top: var(--space-3); right: var(--space-3); }
.conv-action-btn { background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: var(--space-1); border-radius: var(--radius-md); opacity: 0; transition: all var(--transition-fast); }
.conversation-card:hover .conv-action-btn { opacity: 1; }
.conv-action-btn:hover { background: var(--color-bg-alt); color: var(--color-text); }
.conv-action-menu { position: absolute; top: 100%; right: 0; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 50; min-width: 150px; display: none; overflow: hidden; }
.conv-action-menu--open { display: block; }
.conv-action-menu button { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: var(--space-3) var(--space-4); background: none; border: none; font-size: var(--text-sm); color: var(--color-text); cursor: pointer; font-family: var(--font-body); transition: background var(--transition-fast); }
.conv-action-menu button:hover { background: var(--color-bg-alt); }
.conv-action-menu button i { width: 14px; height: 14px; }
.conv-action-menu button.danger { color: #DC2626; }

/* Archive / Trash sections */
.conv-section-title { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) 0; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer; user-select: none; margin-top: var(--space-4); }
.conv-section-title i { width: 14px; height: 14px; transition: transform var(--transition-fast); }
.conv-section-title--open i { transform: rotate(90deg); }
.conv-section-content { display: none; }
.conv-section-content--open { display: flex; flex-direction: column; gap: var(--space-3); }
.conversation-card--archived { opacity: 0.6; }
.conversation-card--blocked { opacity: 0.4; border-style: dashed; }

/* Chat View */
.chat-view { display: none; flex-direction: column; height: calc(100vh - var(--nav-height) - 100px); }
.chat-view--open { display: flex; }

.chat-header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.chat-header__back { background: none; border: none; padding: var(--space-2); color: var(--color-text-muted); cursor: pointer; border-radius: var(--radius-md); transition: all var(--transition-fast); display: flex; align-items: center; justify-content: center; }
.chat-header__back:hover { background: var(--color-bg-alt); color: var(--color-text); }
.chat-header__name { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.chat-header__ref { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Chat Messages Container */
.chat-messages { flex: 1; overflow-y: auto; padding: var(--space-5); background: var(--color-bg-alt); border-left: 1px solid var(--color-border); border-right: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 2px; scroll-behavior: smooth; }
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }

/* ---- Bubble Groups ---- */
.chat-bubble-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.chat-bubble-group--buyer { align-items: flex-end; padding-right: 40px; position: relative; }
.chat-bubble-group--seller { align-items: flex-start; padding-left: 40px; position: relative; }

/* Avatar for received/sent messages */
.chat-group-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--color-primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  position: absolute; bottom: 0;
  flex-shrink: 0;
}
.chat-group-avatar--left { left: 0; background: var(--color-primary); }
.chat-group-avatar--right { right: 0; background: var(--color-bg-alt); color: var(--color-text); border: 1px solid var(--color-border); }

.chat-group-sender { font-size: 0.68rem; font-weight: 600; color: var(--color-text-muted); margin-bottom: 2px; }
.chat-bubble-group--buyer .chat-group-sender { padding-right: 2px; text-align: right; }
.chat-bubble-group--seller .chat-group-sender { padding-left: 2px; text-align: left; }

/* Group timestamp shown below last bubble */
.chat-group-time { font-size: 0.62rem; color: var(--color-text-muted); margin-top: 3px; padding: 0 2px; }
.chat-bubble-group--buyer .chat-group-time { text-align: right; }
.chat-bubble-group--seller .chat-group-time { text-align: left; }

/* ---- Message Bubbles ---- */
.chat-bubble {
  max-width: 72%; padding: 9px 14px; font-size: var(--text-sm); line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
  animation: bubbleIn 0.2s ease-out both;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Sent (buyer) */
.chat-bubble--buyer { background: var(--color-accent); color: white; align-self: flex-end; border-radius: 18px 18px 4px 18px; }
.chat-bubble--buyer.bubble-first  { border-radius: 18px 18px 4px 18px; }
.chat-bubble--buyer.bubble-middle { border-radius: 18px 4px 4px 18px; }
.chat-bubble--buyer.bubble-last   { border-radius: 18px 4px 18px 18px; }
.chat-bubble--buyer.bubble-single { border-radius: 18px 18px 4px 18px; }

/* Received (seller / support / admin) */
.chat-bubble--seller { background: var(--color-bg-card); color: var(--color-text); border: 1px solid var(--color-border); align-self: flex-start; border-radius: 18px 18px 18px 4px; }
.chat-bubble--seller.bubble-first  { border-radius: 18px 18px 18px 4px; }
.chat-bubble--seller.bubble-middle { border-radius: 4px 18px 18px 4px; }
.chat-bubble--seller.bubble-last   { border-radius: 4px 18px 18px 18px; }
.chat-bubble--seller.bubble-single { border-radius: 18px 18px 18px 4px; }

/* System / admin notification bubble */
.chat-bubble--admin { background: linear-gradient(135deg, rgba(212, 175, 55, 0.12), rgba(212, 175, 55, 0.05)); color: var(--color-text); align-self: center; border-radius: var(--radius-lg); font-size: var(--text-xs); text-align: center; max-width: 90%; border: 1px solid rgba(212, 175, 55, 0.25); padding: var(--space-4); }

/* ---- Attachments ---- */
.chat-attachment { margin-top: var(--space-2); }
.chat-attachment img { max-width: 240px; max-height: 200px; border-radius: var(--radius-md); cursor: pointer; transition: opacity var(--transition-fast); }
.chat-attachment img:hover { opacity: 0.85; }
.chat-attachment__file { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: rgba(255,255,255,0.15); border-radius: var(--radius-md); font-size: var(--text-xs); text-decoration: none; color: inherit; transition: background var(--transition-fast); }
.chat-bubble--seller .chat-attachment__file { background: var(--color-bg-alt); }
.chat-attachment__file:hover { background: rgba(255,255,255,0.25); }
.chat-attachment__file i { width: 14px; height: 14px; }

/* ---- Chat Input ---- */
.chat-input {
  display: flex; gap: var(--space-3); padding: var(--space-4) var(--space-5);
  background: var(--color-bg-card); border: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl); align-items: center;
}
.chat-input__field { flex: 1; padding: var(--space-3) var(--space-4); border: 1.5px solid var(--color-border); border-radius: var(--radius-full); font-size: var(--text-sm); font-family: var(--font-body); outline: none; transition: border-color var(--transition-fast); background: var(--color-bg-alt); }
.chat-input__field:focus { border-color: var(--color-accent); background: var(--color-bg-card); }
.chat-input__attach { width: 40px; height: 40px; border-radius: 50%; background: var(--color-bg-alt); color: var(--color-text-muted); border: 1px solid var(--color-border); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition-fast); flex-shrink: 0; }
.chat-input__attach:hover { background: var(--color-accent-light); color: var(--color-accent); border-color: var(--color-accent); }
.chat-input__attach i { width: 18px; height: 18px; }
.chat-input__send { width: 40px; height: 40px; border-radius: 50%; background: var(--color-accent); color: white; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition-fast); flex-shrink: 0; }
.chat-input__send:hover { background: var(--color-accent-hover); transform: scale(1.05); }
.chat-input__send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Attachment Preview */
.chat-attach-preview { display: none; padding: var(--space-3) var(--space-5); background: var(--color-bg-card); border-left: 1px solid var(--color-border); border-right: 1px solid var(--color-border); }
.chat-attach-preview--visible { display: flex; align-items: center; gap: var(--space-3); }
.chat-attach-preview img { width: 48px; height: 48px; border-radius: var(--radius-md); object-fit: cover; }
.chat-attach-preview__name { flex: 1; font-size: var(--text-xs); color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-attach-preview__remove { background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: var(--space-1); }

/* ===================================
   DOCUMENTS
   =================================== */

/* Reupload section */
.docs-reupload { margin-bottom: var(--space-6); padding: var(--space-5); background: var(--color-bg-card); border: 1.5px dashed var(--color-border); border-radius: var(--radius-xl); }
.docs-reupload__title { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); margin-bottom: var(--space-4); }
.docs-reupload__title i { width: 18px; height: 18px; color: var(--color-accent); }
.docs-reupload .form-group { margin-bottom: var(--space-4); }
.docs-reupload .form-label { font-size: var(--text-sm); font-weight: var(--weight-medium); margin-bottom: var(--space-2); display: block; }
.docs-reupload .form-select { width: 100%; padding: var(--space-3) var(--space-4); border: 1.5px solid var(--color-border); border-radius: var(--radius-md); font-size: var(--text-sm); font-family: var(--font-body); background: var(--color-bg); color: var(--color-text); }

.docs-dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-8) var(--space-4); border: 2px dashed var(--color-border); border-radius: var(--radius-lg); cursor: pointer; transition: all var(--transition-fast); text-align: center; }
.docs-dropzone:hover, .docs-dropzone--dragover { border-color: var(--color-accent); background: var(--color-accent-light); }
.docs-dropzone i { width: 32px; height: 32px; color: var(--color-text-muted); margin-bottom: var(--space-2); }
.docs-dropzone__text { font-size: var(--text-sm); color: var(--color-text-secondary); }
.docs-dropzone__hint { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }

/* Doc section headers */
.docs-section { margin-bottom: var(--space-6); }
.docs-section__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-secondary); margin-bottom: var(--space-3); display: flex; align-items: center; gap: var(--space-2); text-transform: uppercase; letter-spacing: 0.04em; font-size: var(--text-xs); }
.docs-section__title i { width: 14px; height: 14px; }

/* Document Cards */
.doc-card { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); margin-bottom: var(--space-3); transition: all var(--transition-fast); cursor: pointer; }
.doc-card:hover { box-shadow: var(--shadow-sm); border-color: var(--color-border-hover); }
.doc-card__icon { width: 48px; height: 48px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.doc-card__icon--proof { background: var(--color-info-light); color: var(--color-info); }
.doc-card__icon--receipt { background: var(--color-success-light); color: var(--color-success); }
.doc-card__icon--rejected { background: var(--color-danger-light); color: #DC2626; }
.doc-card__info { flex: 1; min-width: 0; }
.doc-card__name { font-weight: var(--weight-medium); font-size: var(--text-sm); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card__meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.doc-card__status { display: flex; align-items: center; gap: var(--space-1); padding: 3px 10px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-medium); flex-shrink: 0; white-space: nowrap; }
.doc-card__status--pending { background: var(--color-warning-light); color: #92400E; }
.doc-card__status--received { background: var(--color-info-light); color: #1E40AF; }
.doc-card__status--verified { background: var(--color-success-light); color: #166534; }
.doc-card__status--rejected { background: var(--color-danger-light); color: #991B1B; }
.doc-card__action { padding: var(--space-2); background: none; border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text-muted); cursor: pointer; transition: all var(--transition-fast); text-decoration: none; display: flex; align-items: center; }
.doc-card__action:hover { background: var(--color-bg-alt); color: var(--color-text); }

/* --- Suggestions --- */
.suggestions-section { margin-top: var(--space-8); padding-top: var(--space-6); border-top: 1px solid var(--color-border); }
.suggestions-section__title { font-size: var(--text-base); font-weight: var(--weight-semibold); margin-bottom: var(--space-4); }
.suggestions-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.suggestion-card { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); overflow: hidden; text-decoration: none; color: var(--color-text); transition: all var(--transition-fast); }
.suggestion-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.suggestion-card__img { width: 100%; height: 120px; object-fit: cover; }
.suggestion-card__body { padding: var(--space-3); }
.suggestion-card__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); margin-bottom: 2px; }
.suggestion-card__price { font-size: var(--text-sm); color: var(--color-accent); font-weight: var(--weight-bold); }

/* ===================================
   ACCOUNT / PROFILE
   =================================== */

.account-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.stat-card { text-align: center; padding: var(--space-5); background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); }
.stat-card__value { font-size: var(--text-3xl); font-weight: var(--weight-bold); color: var(--color-text); margin-bottom: var(--space-1); }
.stat-card__label { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.account-card { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: var(--space-6); margin-bottom: var(--space-5); }
.account-card__title { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-base); font-weight: var(--weight-semibold); margin-bottom: var(--space-5); padding-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); }
.account-card__title i { color: var(--color-text-muted); width: 18px; height: 18px; }
.account-row { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) 0; border-bottom: 1px solid var(--color-bg-alt); }
.account-row:last-child { border-bottom: none; }
.account-row__label { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: var(--weight-medium); }
.account-row__value { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text); }

/* Toggle switches */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) 0; border-bottom: 1px solid var(--color-bg-alt); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row__info { flex: 1; }
.toggle-row__label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text); }
.toggle-row__desc { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 2px; }
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch__slider { position: absolute; inset: 0; background: var(--color-border); border-radius: var(--radius-full); cursor: pointer; transition: all var(--transition-fast); }
.toggle-switch__slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: all var(--transition-fast); }
.toggle-switch input:checked + .toggle-switch__slider { background: var(--color-accent); }
.toggle-switch input:checked + .toggle-switch__slider::before { transform: translateX(20px); }

/* Danger zone */
.danger-zone { margin-top: var(--space-6); padding: var(--space-5); background: rgba(220, 38, 38, 0.04); border: 1px solid rgba(220, 38, 38, 0.2); border-radius: var(--radius-xl); }
.danger-zone__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: #DC2626; margin-bottom: var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.danger-zone__title i { width: 16px; height: 16px; }
.danger-zone__text { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: var(--space-4); }

/* Lightbox */
.lightbox-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); z-index: 1000; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; padding: var(--space-6); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox-content { position: relative; max-width: 90vw; max-height: 90vh; }
.lightbox-content img { max-width: 100%; max-height: 85vh; object-fit: contain; border-radius: var(--radius-lg); }
.lightbox-close { position: absolute; top: -40px; right: 0; background: rgba(255,255,255,0.15); border: none; color: white; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background var(--transition-fast); }
.lightbox-close:hover { background: rgba(255,255,255,0.3); }
.lightbox-close i { width: 20px; height: 20px; }

/* ===================================
   BOTTOM NAVIGATION (Mobile)
   =================================== */

.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-height); background: var(--color-bg-card); border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-around; z-index: var(--z-sticky); padding-bottom: env(safe-area-inset-bottom, 0); box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06); }
.bottom-nav__item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space-2) var(--space-3); background: none; border: none; color: var(--color-text-muted); font-size: 0.625rem; font-weight: var(--weight-medium); cursor: pointer; transition: color var(--transition-fast); font-family: var(--font-body); position: relative; }
.bottom-nav__icon { position: relative; }
.bottom-nav__icon i { width: 22px; height: 22px; }
.bottom-nav__item--active { color: var(--color-accent); }
.bottom-nav__item--active .bottom-nav__icon::after { content: ''; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--color-accent); }
.bottom-nav__badge { position: absolute; top: -4px; right: -8px; padding: 1px 5px; background: #EF4444; color: white; border-radius: var(--radius-full); font-size: 0.55rem; font-weight: var(--weight-bold); min-width: 16px; text-align: center; line-height: 1.4; }

/* ===================================
   RESPONSIVE — Mobile Overrides
   =================================== */

@media (max-width: 768px) {
  body.profile-body {
    position: fixed;
    inset: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
  }

  .profile-nav { display: none !important; }
  .profile-sidebar { display: none !important; }
  
  .profile-layout {
    padding-top: 0;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--bottom-nav-height) - env(safe-area-inset-bottom, 0px));
    min-height: 0;
    width: 100%;
    overflow: hidden;
  }
  
  .profile-main {
    margin-left: 0;
    padding: 0;
    max-width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-3) var(--space-3);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
  }
  .mobile-header__title { font-size: var(--text-xl); font-weight: var(--weight-bold); }

  /* Hide all tabs by default on mobile */
  .profile-tab {
    display: none !important;
  }

  /* Active tab becomes a flex column that fills remaining space */
  .profile-tab.profile-tab--active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }

  /* Tab header stays fixed at top of each tab */
  .profile-tab__header {
    background: var(--color-bg);
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
  }
  .profile-tab__header h2 { display: none; }
  
  /* Tab content scrolls independently */
  .tab-content {
    padding: var(--space-4) var(--space-3);
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }

  /* ---- Messages Tab: conversations list scrolls, chat has fixed header/input ---- */
  #tab-messages .tab-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    padding: var(--space-3);
  }

  /* Security banner stays fixed */
  #chat-security-banner-static {
    flex-shrink: 0;
  }

  /* Conversations list scrolls */
  #conversations-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .tx-card__header { flex-wrap: wrap; gap: var(--space-3); }
  .tx-card__img { width: 56px; height: 42px; }
  .tx-actions { flex-direction: column; }
  .tx-actions .btn { min-width: auto; }

  .account-stats { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: var(--space-4); }
  .stat-card__value { font-size: var(--text-2xl); }

  /* ---- Chat View: header and input fixed, messages scroll ---- */
  .chat-view {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  .chat-header {
    flex-shrink: 0;
  }
  .chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }
  .chat-input {
    flex-shrink: 0;
  }
  #attachment-preview {
    flex-shrink: 0;
  }

  /* ---- When chat is open: hide mobile header, tab header, bottom nav for full-screen chat ---- */
  body.chat-open .mobile-header {
    display: none !important;
  }
  body.chat-open #tab-messages .profile-tab__header {
    display: none !important;
  }
  body.chat-open .bottom-nav {
    display: none !important;
  }
  body.chat-open .profile-layout {
    height: 100dvh;
  }
  .chat-bubble { max-width: 85%; }

  /* ---- Auth Gate ---- */
  .auth-gate {
    min-height: 100%;
    width: 100%;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
  }
  .auth-card { padding: var(--space-6); margin: var(--space-4); }

  .account-card { margin-left: 0; margin-right: 0; }
  .account-row { flex-direction: column; align-items: flex-start; gap: var(--space-1); }

  .notif-panel { right: var(--space-2); left: var(--space-2); width: auto; }

  .suggestions-grid { grid-template-columns: 1fr; }

  .docs-reupload { margin-left: 0; margin-right: 0; }

  /* Hide button text on mobile to avoid squishing the chat header */
  #chat-header-actions .btn-text { display: none; }
  #chat-header-actions .btn {
    padding: var(--space-2) !important;
    border-radius: var(--radius-md) !important;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
  .mobile-header { display: none !important; }
}
