﻿/* ux-smart.css — Yallabni UX Intelligente */

/* ── DRAFT BANNER ───────────────────────────────────────────────────── */
#draft-banner {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--amber-b, #FEF3DC);
  border: 1px solid var(--gold, #c9963a);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--amber, #8B5E0A);
  animation: slideDown .25s ease;
}
#draft-banner.visible { display: flex; }
#draft-banner .draft-msg { flex: 1; font-weight: 500; }
#draft-banner .draft-actions { display: flex; gap: 8px; }
#draft-banner button {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
#draft-banner .btn-resume {
  background: var(--gold, #c9963a);
  color: var(--ink, #0F1D36);
}
#draft-banner .btn-discard {
  background: transparent;
  color: var(--amber, #8B5E0A);
  text-decoration: underline;
  font-weight: 400;
}

#draft-saved-indicator {
  display: none;
  font-size: 11px;
  color: var(--clay-l, #1D9E75);
  text-align: right;
  margin-top: -8px;
  margin-bottom: 8px;
}
#draft-saved-indicator.visible { display: block; }

@keyframes slideDown {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── QUICK TILE SELECTOR ─────────────────────────────────────────────── */
.quick-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

/* ── ux-tile (classe JS) + quick-tile (classe legacy) ── */
.quick-tile, .ux-tile {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--border, rgba(15,29,54,.1));
  background: var(--white, #fff);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .1s;
  user-select: none;
  font-family: inherit;
}
.quick-tile:hover, .ux-tile:hover {
  border-color: var(--gold, #c9963a);
  background: var(--gold-b, rgba(201,150,58,.12));
  transform: translateY(-1px);
}
.quick-tile.selected, .quick-tile.active,
.ux-tile.selected, .ux-tile.active {
  border-color: var(--clay, #1D5FA6);
  background: var(--clay-p, #E8F0FB);
  box-shadow: 0 0 0 2px var(--clay, #1D5FA6);
  transform: translateY(-1px);
}
.quick-tile .tile-icon, .ux-tile .ux-tile-icon { font-size: 18px; line-height: 1; }
.quick-tile .tile-label, .ux-tile .ux-tile-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink, #0F1D36);
  margin-top: 3px;
  text-align: center;
  line-height: 1.2;
}
.quick-tile.active .tile-label, .ux-tile.active .ux-tile-label { color: var(--clay, #1D5FA6); }
.quick-tile .tile-sub, .ux-tile .ux-tile-sub {
  font-size: 8px;
  color: var(--muted, #64748B);
  margin-top: 1px;
  text-align: center;
}

/* Champ "Autre personnalisé" */
#dep-cat-custom-wrap {
  display: none;
  margin-top: 8px;
}
#dep-cat-custom-wrap.visible { display: block; }
#dep-cat-custom-input {
  width: 100%;
  border: 1.5px solid var(--clay, #1D5FA6);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  box-sizing: border-box;
}

/* ── PHOTO SCAN BUTTON ───────────────────────────────────────────────── */
.photo-scan-area {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
#btn-photo-scan {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px dashed var(--clay, #1D5FA6);
  background: var(--clay-pp, #F5F8FD);
  color: var(--clay, #1D5FA6);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
#btn-photo-scan:hover {
  background: var(--clay-p, #E8F0FB);
  border-color: var(--clay, #1D5FA6);
}
#btn-photo-scan .scan-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--clay, #1D5FA6);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
#btn-photo-scan.scanning { opacity: .7; pointer-events: none; }
#btn-photo-scan.scanning .scan-spinner { display: inline-block; }
#receipt-file-input { display: none; }

/* Status messages under scan/voice buttons */
.scan-status, .voice-live {
  font-size: 12px;
  padding: 4px 0 6px;
  min-height: 18px;
  transition: color .2s;
}
.scan-status.info, .voice-live.info { color: var(--clay, #1D5FA6); }
.scan-status.ok,   .voice-live.ok   { color: var(--green, #1F6B3A); }
.scan-status.warn, .voice-live.warn { color: var(--amber, #8B5E0A); }

.ai-filled {
  position: relative;
}
.ai-filled::after {
  content: '✦ IA';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 700;
  color: var(--clay, #1D5FA6);
  background: var(--clay-p, #E8F0FB);
  padding: 2px 5px;
  border-radius: 4px;
  pointer-events: none;
}

/* ── VOICE INPUT BUTTON ──────────────────────────────────────────────── */
#btn-voice {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border, rgba(15,29,54,.1));
  background: var(--white, #fff);
  color: var(--ink, #0F1D36);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
#btn-voice.recording {
  border-color: #e53e3e;
  background: #fff5f5;
  color: #e53e3e;
  animation: pulseBorder 1.2s ease-in-out infinite;
}
#btn-voice.processing {
  opacity: .6;
  pointer-events: none;
}
.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e53e3e;
  display: none;
}
#btn-voice.recording .voice-dot { display: inline-block; animation: blink .8s ease infinite; }

@keyframes pulseBorder {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229,62,62,.3); }
  50%       { box-shadow: 0 0 0 6px rgba(229,62,62,0); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .2; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── SUGGESTIONS ─────────────────────────────────────────────────────── */
#dep-suggestions {
  display: none;
  margin-bottom: 12px;
}
#dep-suggestions.visible { display: block; }
#dep-suggestions .sugg-label {
  font-size: 11px;
  color: var(--muted, #64748B);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sugg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sugg-chip {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border, rgba(15,29,54,.1));
  background: var(--white, #fff);
  font-size: 12px;
  color: var(--ink, #0F1D36);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.sugg-chip:hover {
  background: var(--gold-b, rgba(201,150,58,.12));
  border-color: var(--gold, #c9963a);
}

/* ── FAB (Quick Log) ─────────────────────────────────────────────────── */
#quick-log-fab {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold, #c9963a);
  color: var(--ink, #0F1D36);
  font-size: 26px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(201,150,58,.5);
  z-index: 900;
  transition: transform .15s, box-shadow .15s;
}
#quick-log-fab.visible { display: flex; }
#quick-log-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(201,150,58,.65);
}

/* ── QUICK LOG MODAL ─────────────────────────────────────────────────── */
#quick-log-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  align-items: flex-end;
  justify-content: center;
}
#quick-log-modal.open { display: flex; }
#quick-log-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,29,54,.45);
}
#quick-log-sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--white, #fff);
  border-radius: 20px 20px 0 0;
  padding: 20px 22px 28px;
  z-index: 1;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
#quick-log-sheet h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink, #0F1D36);
  margin: 0 0 16px;
  text-align: center;
}
#quick-log-sheet .ql-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
#quick-log-sheet .ql-row input,
#quick-log-sheet .ql-row select {
  flex: 1;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border, rgba(15,29,54,.1));
  font-size: 14px;
  background: var(--white, #fff);
  color: var(--ink, #0F1D36);
  outline: none;
}
#quick-log-sheet .ql-row input:focus,
#quick-log-sheet .ql-row select:focus {
  border-color: var(--clay, #1D5FA6);
}
#quick-log-sheet .ql-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
#btn-ql-cancel {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border, rgba(15,29,54,.1));
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted, #64748B);
}
#btn-ql-save {
  flex: 2;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: var(--gold, #c9963a);
  color: var(--ink, #0F1D36);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .12s;
}
#btn-ql-save:hover { opacity: .88; }

/* ── VOICE FALLBACK MODAL ────────────────────────────────────────────── */
#voice-fallback-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1200;
  align-items: center;
  justify-content: center;
}
#voice-fallback-modal.open { display: flex; }
#voice-fallback-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,29,54,.5);
}
#voice-fallback-sheet {
  position: relative;
  width: 90%;
  max-width: 400px;
  background: var(--white, #fff);
  border-radius: 16px;
  padding: 22px;
  z-index: 1;
}
#voice-fallback-sheet h4 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink, #0F1D36);
}
#voice-fallback-sheet textarea {
  width: 100%;
  height: 80px;
  border-radius: 8px;
  border: 1.5px solid var(--border, rgba(15,29,54,.1));
  padding: 8px 10px;
  font-size: 13px;
  resize: none;
  box-sizing: border-box;
}
#voice-fallback-sheet .vf-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}
#voice-fallback-sheet button {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#btn-vf-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
#btn-vf-submit {
  background: var(--clay, #1D5FA6);
  border: none;
  color: #fff;
}


/* ── RESPONSIVE MOBILE (UXT-03/04 — audit) ────────────────────────────── */
@media (max-width: 768px) {
  /* UXT-03: Panel messages — 1 colonne sous 768px */
  #panel-messages [style*="grid-template-columns:1fr 2fr"] {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: 300px;
  }
  #conv-list {
    max-height: 220px;
    border-right: none !important;
    border-bottom: .5px solid var(--border, #E8E3DC);
  }
  #msg-thread {
    height: 360px !important;
  }
}

/* ── RTL / ARABIC FIXES (UXT-05 — audit) ──────────────────────────────── */
html[dir="rtl"] {
  /* Global text direction */
  direction: rtl;
  text-align: right;
}

/* Sidebar — flip to right side in RTL */
html[dir="rtl"] .sidebar {
  order: 1; /* push sidebar after main content in grid */
}
html[dir="rtl"] .dash-wrap {
  direction: rtl;
}

/* Sidebar links — icon + label reversed */
html[dir="rtl"] .sblink {
  flex-direction: row-reverse;
  text-align: right;
}
html[dir="rtl"] .sb-sec {
  text-align: right;
  padding-right: .5rem;
  padding-left: 0;
  letter-spacing: 0;
}

/* Arrow indicators flip */
html[dir="rtl"] .sblink::after,
html[dir="rtl"] .dh-caret {
  transform: scaleX(-1);
}

/* Dashboard panels */
html[dir="rtl"] .dh { flex-direction: row-reverse; }
html[dir="rtl"] .kpi-item { text-align: right; }
html[dir="rtl"] .form-group label { text-align: right; }

/* Input fields */
html[dir="rtl"] input[type="text"],
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="password"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] textarea,
html[dir="rtl"] select {
  text-align: right;
  direction: rtl;
}

/* Tables */
html[dir="rtl"] table { direction: rtl; }
html[dir="rtl"] th, html[dir="rtl"] td { text-align: right; }

/* Mobile sidebar — slide from right in RTL */
@media (max-width: 700px) {
  html[dir="rtl"] .sidebar {
    left: auto;
    right: -280px;
    transition: right .25s cubic-bezier(.4,0,.2,1);
    box-shadow: -4px 0 32px rgba(0,0,0,.35);
  }
  html[dir="rtl"] .sidebar.mob-open {
    right: 0;
    left: auto;
  }
}

/* Professional cards — layout fix */
html[dir="rtl"] .pro-card {
  flex-direction: row-reverse;
  text-align: right;
}

/* Quick tiles */
html[dir="rtl"] .quick-tiles {
  direction: rtl;
}

/* Toast notifications */
html[dir="rtl"] .toast-container {
  right: auto;
  left: 20px;
}

/* Chat messages — sent/received still correct since based on class */
html[dir="rtl"] .msg-bubble.sent {
  margin-left: 0;
  margin-right: auto;
}
html[dir="rtl"] .msg-bubble.received {
  margin-right: 0;
  margin-left: auto;
}

@media (max-width: 640px) {
  /* UXT-04: Tableau dépenses — 1 colonne */
  .expenses-table table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  /* UXT-04: Grilles 3 colonnes communauté/parrainage — cards verticales */
  [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: 1fr !important;
  }
  .pro-card-grid,
  [class*="comm-directory"],
  [id*="comm-directory"] {
    grid-template-columns: 1fr !important;
  }
  /* Nav bar compacte */
  .dash-nav { padding: .4rem .6rem !important; }
  .dash-panel { padding: 1rem !important; }
}

/* Utility */
.hidden { display: none !important; }

/* ── RTL ARABIC EXTENDED FIXES ─────────────────────────────────────────── */
html[dir="rtl"] {
  font-family: 'Noto Sans Arabic', 'Segoe UI', sans-serif;
}

/* Dashboard grid — RTL reverses columns automatically (sidebar → right, content → left) */
/* No margin overrides needed; CSS Grid handles direction. */

html[dir="rtl"] .card,
html[dir="rtl"] .dcard {
  text-align: right;
}

html[dir="rtl"] .toast {
  left: 1rem;
  right: auto;
}

html[dir="rtl"] .modal-box,
html[dir="rtl"] .modal-content {
  text-align: right;
}

html[dir="rtl"] .btn-row,
html[dir="rtl"] .action-row {
  flex-direction: row-reverse;
}

html[dir="rtl"] .msg-bubble.sent {
  margin-left: 0;
  margin-right: auto;
  border-radius: 18px 4px 18px 18px;
}

html[dir="rtl"] .msg-bubble.received {
  margin-right: 0;
  margin-left: auto;
  border-radius: 4px 18px 18px 18px;
}

/* Desktop sidebar: cosmetic RTL — border side swap, no position changes (grid handles it) */
html[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid rgba(255,255,255,.08);
}

/* Sidebar nav links: reverse icon + text order for RTL */
html[dir="rtl"] .sblink {
  text-align: right;
  flex-direction: row-reverse;
}

html[dir="rtl"] .sb-sec {
  text-align: right;
  padding-left: 0;
  padding-right: .5rem;
}

/* ── Community mobile layout ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .community-layout {
    flex-direction: column !important;
  }
  .community-posts {
    width: 100% !important;
    max-width: 100% !important;
  }
  .community-sidebar {
    display: none;
  }
  .community-sidebar.show {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--surface, #fff);
    overflow-y: auto;
    padding: 1rem;
  }
}

/* ── RTL mobile sidebar: slides in from RIGHT (must match max-width:700px in styles.css) ── */
@media (max-width: 700px) {
  html[dir="rtl"] .sidebar {
    right: -280px;
    left: auto !important;
    transition: right .25s cubic-bezier(.4,0,.2,1);
    box-shadow: -4px 0 32px rgba(0,0,0,.35);
  }
  html[dir="rtl"] .sidebar.mob-open {
    right: 0;
    left: auto !important;
  }
}
