:root {
  --primary: #0EA5E9;
  --primary-dark: #0284C7;
  --secondary: #F59E0B;
  --success: #10B981;
  --danger: #EF4444;
  --dark: #0F172A;
  --dark-light: #1E293B;
  --gray: #64748B;
  --gray-light: #CBD5E1;
  --white: #FFFFFF;
  --bg: #F8FAFC;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.15);
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 24px;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--dark);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── HEADER ── */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
  gap: 12px;
}
.logo {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  white-space: nowrap;
}
.logo::before { content: '✈️'; font-size: 28px; -webkit-text-fill-color: initial; }

.user-info { display: flex; align-items: center; gap: 10px; }

.tokens-badge {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--dark);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s;
  white-space: nowrap;
}
.tokens-badge:hover { transform: translateY(-1px); }
.tokens-badge::before { content: '🪙'; font-size: 18px; }

.lang-ui-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 2px solid var(--gray-light);
  background: var(--white);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.lang-ui-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }

.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 14px;
  cursor: pointer; transition: transform 0.2s; user-select: none;
}
.user-avatar:hover { transform: scale(1.05); }

/* ── TABS ── */
.nav-tabs {
  background: var(--white);
  border-bottom: 2px solid var(--gray-light);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-tabs-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 8px;
}
.tab-btn {
  flex-shrink: 0;
  padding: 14px 18px;
  border: none; background: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px; font-weight: 700;
  color: var(--gray);
  position: relative;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform 0.2s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after { transform: scaleX(1); }

/* ── CONTAINER & PAGES ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.page { display: none; animation: fadeIn 0.4s; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── PAGE ASSISTANT — plein écran ── */
#page-assistant {
  margin: -24px -16px -40px;
  height: calc(100vh - 70px - 44px);
  min-height: 400px;
  max-height: calc(100vh - 70px - 44px);
  overflow: hidden !important;
}

/* ── CARD ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 800;
  margin-bottom: 16px;
}

/* ── ASSISTANT LAYOUT ── */
.assistant-layout {
  height: calc(100vh - 120px);
  display: flex; flex-direction: column;
}
#conversationBox { flex: 1; overflow-y: auto; padding-bottom: 10px; }
.assistant-status-zone { padding: 10px 0; }
.assistant-controls {
  position: sticky; bottom: 0;
  background: #fff;
  padding: 12px 0;
  border-top: 1px solid rgba(0,0,0,0.08);
  z-index: 10;
}

/* ── LANG SELECTORS ── */
.lang-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.lang-group { display: flex; flex-direction: column; gap: 8px; }
.lang-label {
  font-size: 12px; font-weight: 700;
  color: var(--gray);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.lang-select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--gray-light);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 16px; font-weight: 600;
  background: var(--white);
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%2364748B'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 44px;
  transition: all 0.2s;
}
.lang-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
}

/* ── VOICE BUTTONS ── */
.voice-controls { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.voice-btn {
  width: 150px; height: 150px;
  border: none; border-radius: 50%;
  font-size: 46px; cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-lg);
  user-select: none;
}
.voice-btn-speak {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}
.voice-btn-speak:hover { transform: scale(1.04); box-shadow: var(--shadow-xl); }
.voice-btn-speak:active { transform: scale(0.96); }
.voice-btn-speak.recording {
  animation: pulse-recording 1.3s ease-in-out infinite;
  background: linear-gradient(135deg, var(--danger), #DC2626);
}
@keyframes pulse-recording {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

/* ── BTN ── */
.btn {
  padding: 12px 16px;
  border: none; border-radius: 12px;
  font-family: var(--font-body);
  font-size: 15px; font-weight: 800;
  cursor: pointer; transition: all 0.2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; max-width: 380px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; box-shadow: var(--shadow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #DC2626); color: white; }

/* ── TRANSLATION OUTPUT ── */
.translation-output {
  width: 100%; min-height: 110px;
  padding: 16px;
  background: var(--bg);
  border: 2px dashed var(--gray-light);
  border-radius: var(--radius);
  font-size: 16px; text-align: center;
  display: flex; align-items: center; justify-content: center;
  color: var(--dark);
}

/* ── CONVERSATION BOX ── */
.conversation-box {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 260px; max-height: 520px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.message {
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  animation: slideIn 0.25s;
  word-break: break-word;
}
@keyframes slideIn {
  from { opacity:0; transform: translateX(-10px); }
  to   { opacity:1; transform: translateX(0); }
}
.message-user {
  background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
  margin-left: 44px; text-align: right;
}
.message-assistant {
  background: linear-gradient(135deg, #F3F4F6, #E5E7EB);
  margin-right: 44px; text-align: left;
}
.message-photo {
  max-width: 260px; border-radius: 12px;
  margin-top: 8px; display: block;
  margin-left: auto; margin-right: auto;
}

/* ── P2P ── */
.p2p-actions {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 16px;
}
.p2p-option {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  border-radius: var(--radius);
  padding: 16px; text-align: center;
  cursor: pointer; font-weight: 900;
  border: 3px solid transparent;
  transition: all 0.2s;
}
.p2p-option:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.p2p-option .icon { font-size: 42px; }
.p2p-option .desc { font-size: 12px; color: var(--gray); margin-top: 6px; font-weight: 700; }

.room-code-display {
  background: var(--dark); color: white;
  padding: 18px; border-radius: var(--radius);
  text-align: center; margin: 16px 0;
}
.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 46px; font-weight: 900;
  letter-spacing: 10px; margin: 12px 0 6px;
}

/* ── MODAL ── */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000; padding: 18px;
}
.modal.active { display: block; }
.modal-card {
  background: var(--white);
  border-radius: 18px;
  max-width: 520px;
  margin: 60px auto 0;
  padding: 18px;
  box-shadow: var(--shadow-xl);
}
.modal-top {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.modal-title { font-family: var(--font-display); font-weight: 900; font-size: 18px; }
.modal-close { border:none; background: transparent; font-size: 28px; cursor:pointer; color: #999; }
.modal-close:hover { color: #111; }

/* ── SUB CARDS ── */
.sub-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.sub-card {
  position: relative;
  background: white;
  border: 2px solid var(--gray-light);
  border-radius: 16px; padding: 20px;
  transition: all 0.3s;
}
.sub-card.pro   { border-color: #10B981; box-shadow: 0 4px 12px rgba(16,185,129,0.15); }
.sub-card.premium {
  border-color: var(--secondary);
  box-shadow: 0 4px 12px rgba(245,158,11,0.15);
}
.sub-card:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); }
.sub-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sub-name { font-size: 18px; font-weight: bold; color: #333; }
.sub-tokens { font-size: 16px; font-weight: 900; color: var(--primary); }
.badge-recommended {
  position: absolute; top: -10px; right: 10px;
  background: linear-gradient(135deg, #10B981, #059669);
  color: white; padding: 4px 12px; border-radius: 12px;
  font-size: 11px; font-weight: bold;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

/* ── FORM ── */
.form-row { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.input {
  width: 100%; padding: 12px 14px;
  border-radius: 12px; border: 2px solid var(--gray-light);
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
}
.input:focus { outline:none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,0.12); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── MIC METER ── */
.mic-meter {
  height: 10px; background: rgba(0,0,0,0.12);
  border-radius: 999px; overflow: hidden;
}
#micMeterFill, #assistantMicMeterFill {
  height: 100%; width: 0%;
  background: #00c853;
  transition: width 0.08s linear;
}

/* ── MODALS FIX ── */
#langsModal { position: fixed; inset: 0; z-index: 9999; }
#langsModal .modal-card { max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#langsModal .sub-grid   { max-height: 60vh; overflow-y: auto; padding-right: 6px; -webkit-overflow-scrolling: touch; }
#subModal .modal-card   { max-height: 85vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ── MODE BILINGUE — bulles ── */
@keyframes slideInBubble {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#bilingualHistory {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
#bilingualHistory::-webkit-scrollbar { width: 4px; }
#bilingualHistory::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
#speakBtnBilingual {
  width: 72px !important; height: 72px !important;
  font-size: 28px !important;
}

/* ── SAFE AREA (iPhone) ── */
#assistantBottomBar {
  padding-bottom: max(8px, env(safe-area-inset-bottom, 8px)) !important;
}

/* =============================================
   MOBILE <= 768px
============================================= */
@media (max-width: 768px) {

  body { padding: 0; }

  .header-content { padding: 0 12px; height: 56px; }
  .logo { font-size: 18px; }
  .user-info { gap: 10px; }
  .tokens-badge { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
  .user-avatar { width: 34px; height: 34px; font-size: 13px; }

  .nav-tabs-inner { padding: 0 10px; gap: 6px; }
  .tab-btn { padding: 10px 12px; font-size: 13px; border-radius: 10px; }

  .container { padding: 14px 12px 110px; }

  /* PAGE ASSISTANT mobile */
  #page-assistant {
    margin: -14px -12px -110px;
    height: calc(100vh - 56px - 40px);
    max-height: calc(100vh - 56px - 40px);
  }

  .card { padding: 16px; border-radius: 16px; }
  .card-title { font-size: 18px; margin-bottom: 14px; }

  .lang-selector { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
  .lang-select { padding: 14px 16px; font-size: 15px; }

  .translation-output { min-height: 90px; padding: 14px; font-size: 15px; border-radius: 14px; }

  .conversation-box {
    min-height: 220px; max-height: 340px;
    padding: 14px; border-radius: 16px;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
  }
  #conversationBox { -webkit-overflow-scrolling: touch; }

  .message { padding: 12px 14px; font-size: 14px; }
  .message-user    { margin-left: 30px; }
  .message-assistant { margin-right: 30px; }

  .voice-btn { width: 110px; height: 110px; font-size: 34px; }

  .assistant-toggle-btn {
    width: 100%; max-width: 380px;
    padding: 14px 16px;
    border: none; border-radius: 14px;
    font-size: 16px; font-weight: 900;
    cursor: pointer; transition: all 0.2s;
    box-shadow: var(--shadow);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
  }
  .assistant-toggle-btn.recording {
    background: linear-gradient(135deg, var(--danger), #DC2626);
    animation: pulse-recording 1.3s ease-in-out infinite;
  }

  .p2p-options { grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
  .room-code-display { padding: 18px; border-radius: 16px; margin: 16px 0; }
  .room-code { font-size: 34px; letter-spacing: 6px; margin: 12px 0; }
  .qr-code { width: 140px; height: 140px; font-size: 56px; margin: 14px auto; }

  .p2p-sticky-bar {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: rgba(248,250,252,0.96);
    border-top: 1px solid var(--gray-light);
    padding: 10px 12px;
    display: flex; gap: 10px; align-items: center; justify-content: space-between;
    z-index: 999; backdrop-filter: blur(10px);
  }
  .p2p-sticky-bar .voice-btn { width: 70px; height: 70px; font-size: 22px; flex: 0 0 auto; border-radius: 50%; }
  .p2p-sticky-bar .btn { flex: 1; justify-content: center; padding: 14px; font-size: 15px; border-radius: 14px; }

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

  #bilingualHistory { padding-bottom: env(safe-area-inset-bottom, 0px); }

  @keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.05); }
  }
  #p2pHoldBtn.recording { background: #dc3545 !important; animation: pulse 0.8s infinite; }

  .poi-tooltip {
    background: rgba(0,0,0,0.75);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
  }

}
