/* =========================================================
   BLUUPI — ASSISTANT CLEAN V5
========================================================= */

:root{
  --bluupi-dark:#0E3E61;
  --bluupi-primary:#127194;
  --bluupi-cyan:#5CD6F4;
  --bluupi-gray:#E6EEF2;
  --bluupi-text:#4B5A68;
  --bluupi-white:#FFFFFF;
  --app-bg:#0b324f;
  --footer-bg:#071f33;
  --safe-top:env(safe-area-inset-top, 0px);
}

*{ box-sizing:border-box; margin:0; padding:0; }

html,body{
  width:100%;
  min-height:100%;
  overflow-x:hidden;
  background:var(--app-bg);
}

body{
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",sans-serif;
  color:var(--bluupi-white);
  -webkit-text-size-adjust:100%;
}

/* MENUS */
.bottom-nav{ display:none; }

@media(max-width:1199px), (pointer:coarse){
  header,
  .desktop-menu,
  .desktop-header,
  .desktop-nav,
  .main-header,
  .site-header{
    display:none !important;
  }

  .bottom-nav{
    position:fixed;
    left:0;
    bottom:0;
    width:100vw;
    height:82px;
    background:var(--app-bg);
    border-top:1px solid rgba(230,238,242,.12);
    display:grid !important;
    grid-template-columns:repeat(5,1fr);
    z-index:95;
  }

  .bottom-nav a{
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:6px;
    color:rgba(255,255,255,.6);
    font-size:12px;
    font-weight:600;
    text-decoration:none;
  }

  .bottom-nav i{
    width:25px;
    height:25px;
    stroke-width:2;
    opacity:.85;
  }

  .bottom-nav a.active{
    color:var(--bluupi-cyan);
  }

  .bottom-nav a.active i{
    transform:scale(1.08);
    opacity:1;
  }
}

@media(min-width:1200px) and (pointer:fine){
  header,
  .desktop-menu,
  .desktop-header,
  .desktop-nav,
  .main-header,
  .site-header{
    display:none !important;
  }

  .bottom-nav{
    display:none !important;
  }
}

/* APP */
.app{
  width:100vw;
  max-width:100vw;
  min-height:100dvh;
  background:var(--app-bg);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  position:relative;
}

/* MASCOTTE */
.bluupi-zone{
  flex:0 0 auto;
  padding:calc(18px + var(--safe-top)) 16px 0;
  text-align:center;
  position:relative;
  z-index:5;
}

.bluupi-avatar{
  width:170px;
  height:auto;
  display:block;
  margin:0 auto -70px;
  animation:bluupi-pulse 2.2s ease-in-out infinite;
  position:relative;
  z-index:10;
}

.assistant-topbar,
.assistant-modes,
.mode-btn,
.account-btn,
.bluupi-bubble,
.weather-widget,
.quick-start{
  display:none !important;
}

@keyframes bluupi-pulse{
  0%{ transform:translateX(-26px) translateY(0) scale(1); }
  50%{ transform:translateX(-26px) translateY(-3px) scale(1.02); }
  100%{ transform:translateX(-26px) translateY(0) scale(1); }
}

/* CHAT */
.app-main{
  flex:1;
  min-height:0;
  display:flex;
  overflow:hidden;
}

.chat{
  flex:1;
  width:100%;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  padding:58px 14px 150px;
  font-size:16px;
}

.msg{
  display:flex;
  margin-bottom:12px;
}

.msg.me{
  justify-content:flex-end;
}

.bubble{
  max-width:86%;
  padding:12px 15px;
  border-radius:22px;
  line-height:1.38;
  white-space:pre-line;
  word-wrap:break-word;
  overflow-wrap:anywhere;
}

.bubble.bluupi{
  background:var(--bluupi-primary);
  color:#fff;
  border-bottom-left-radius:7px;
  box-shadow:0 14px 34px rgba(0,0,0,.14);
}

.bubble.me{
  background:var(--bluupi-gray);
  color:var(--bluupi-dark);
  border-bottom-right-radius:7px;
}

.chat .msg:first-child .bubble.bluupi{
  max-width:82%;
  margin-left:6px;
  padding:30px 22px 24px;
  border-radius:30px;
  border-bottom-left-radius:10px;
  font-size:20px;
  line-height:1.48;
}

/* MASCOTTE APRÈS DÉBUT CHAT */
body.chat-started .bluupi-zone{
  animation:bluupiLeave .45s ease forwards;
  pointer-events:none;
}

@keyframes bluupiLeave{
  0%{ opacity:1; transform:translateY(0) scale(1); }
  100%{
    opacity:0;
    transform:translateY(-28px) scale(.92);
    height:0;
    padding:0;
    margin:0;
  }
}

body.chat-started .chat{
  padding-top:24px;
}

/* INPUT */
.app-input{
  position:fixed;
  left:0;
  bottom:82px;
  width:100vw;
  z-index:90;
  background:var(--footer-bg);
  border-top:1px solid rgba(230,238,242,.12);
  padding:10px 12px;
}

.input-row{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
}

.mic-btn{
  width:54px;
  height:54px;
  flex:0 0 54px;
  border:0;
  border-radius:50%;
  background:rgba(92,214,244,.15);
  color:#fff;
  font-size:24px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.composer{
  position:relative;
  flex:1;
  min-width:0;
  display:flex;
  align-items:center;
}

.text-input{
  width:100%;
  height:56px;
  border:0;
  outline:0;
  border-radius:999px;
  background:var(--bluupi-gray);
  color:var(--bluupi-dark);
  font-size:17px;
  padding:0 16px 0 54px;
}

.text-input::placeholder{
  color:var(--bluupi-text);
}

.attach-btn{
  position:absolute;
  left:8px;
  top:50%;
  transform:translateY(-50%);
  width:40px;
  height:40px;
  border-radius:50%;
  border:1px solid rgba(92,214,244,.45);
  background:rgba(92,214,244,.22);
  color:#fff;
  font-size:25px;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:2;
}

.attach-menu{
  display:none;
  position:absolute;
  left:0;
  bottom:calc(100% + 10px);
  min-width:170px;
  background:rgba(8,31,51,.96);
  border:1px solid rgba(230,238,242,.14);
  border-radius:16px;
  padding:8px;
  box-shadow:0 14px 40px rgba(0,0,0,.35);
  backdrop-filter:blur(10px);
  z-index:999;
}

.attach-menu.open{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.attach-item{
  border:0;
  background:rgba(255,255,255,.08);
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  text-align:left;
}

.send-btn{
  width:56px;
  height:56px;
  flex:0 0 56px;
  border:0;
  border-radius:50%;
  background:var(--bluupi-cyan);
  color:var(--bluupi-dark);
  font-size:0;
  display:flex;
  align-items:center;
  justify-content:center;
}

.send-btn::before{
  content:"↑";
  font-size:34px;
  font-weight:900;
  line-height:1;
}

/* MOBILE */
@media(max-width:767px){
  .app{
    padding-bottom:140px;
  }

  .bottom-nav{
    height:82px;
  }

  .app-input{
    bottom:82px;
  }
}

/* TABLETTE PORTRAIT + HORIZONTALE */
@media(min-width:768px) and (max-width:1199px){
  .app{
    width:100vw;
    max-width:100vw;
    margin:0;
    padding-bottom:150px;
  }

  .bluupi-zone{
    padding-top:calc(22px + var(--safe-top));
  }

  .bluupi-avatar{
    width:235px;
    margin-bottom:-85px;
  }

  .chat{
    padding:74px 48px 175px;
    font-size:18px;
  }

  .bubble{
    max-width:72%;
    font-size:18px;
  }

  .chat .msg:first-child .bubble.bluupi{
    max-width:620px;
    margin-left:auto;
    margin-right:auto;
    font-size:22px;
    padding:34px 30px 28px;
  }

  .app-input{
    bottom:88px;
    padding:12px 28px;
  }

  .bottom-nav{
    height:88px;
  }

  @keyframes bluupi-pulse{
    0%{ transform:translateX(-42px) translateY(0) scale(1); }
    50%{ transform:translateX(-42px) translateY(-3px) scale(1.02); }
    100%{ transform:translateX(-42px) translateY(0) scale(1); }
  }
}

/* TABLETTE HORIZONTALE */
@media(min-width:768px) and (max-width:1199px) and (orientation:landscape){
  .bluupi-zone{
    padding-top:8px;
  }

  .bluupi-avatar{
    width:155px;
    margin-bottom:-70px;
     transform:translateX(-90px);
  }

  .chat{
    padding:56px 40px 160px;
  }

  .chat .msg:first-child .bubble.bluupi{
    max-width:620px;
    margin-left:0;
    margin-right:auto;
    font-size:18px;
    padding:26px 28px 22px;
  }

  .app-input{
    bottom:78px;
    padding:9px 24px;
  }

  .bottom-nav{
    height:78px;
  }

  .text-input{
    height:50px;
  }

  .mic-btn,
  .send-btn{
    width:50px;
    height:50px;
    flex-basis:50px;
  }
}

/* DESKTOP PROPRE SANS MENU CASSÉ */
@media(min-width:1200px) and (pointer:fine){
  body{
    background:var(--app-bg);
  }

  .app{
    width:100%;
    max-width:980px;
    margin:0 auto;
    min-height:100dvh;
  }

  .bluupi-zone{
    padding-top:38px;
  }

  .bluupi-avatar{
    width:230px;
    margin-bottom:-80px;
  }

  .chat{
    padding:74px 80px 120px;
    font-size:18px;
  }

  .bubble{
    max-width:70%;
    font-size:18px;
  }

  .chat .msg:first-child .bubble.bluupi{
    max-width:620px;
    margin-left:auto;
    margin-right:auto;
    font-size:22px;
    padding:34px 30px 28px;
  }

  .app-input{
    left:50%;
    transform:translateX(-50%);
    width:100%;
    max-width:980px;
    bottom:0;
    padding:12px 28px;
  }
}

/* TRANSITION FOND */
body.assistant-enter .app{
  animation:bluupiEnterWorld 3.6s ease forwards;
}

@keyframes bluupiEnterWorld{
  0%{ background:#F3F8FB; }
  45%{ background:#DFF3FA; }
  100%{ background:var(--app-bg); }
}

body.assistant-enter .bluupi-zone,
body.assistant-enter .app-main{
  opacity:1;
  transform:none;
  animation:none;
}

body.assistant-enter .app-input,
body.assistant-enter .bottom-nav{
  opacity:1;
  animation:none;
}
/* =========================================================
   FIX FINAL TABLETTE HORIZONTALE + DESKTOP ASSISTANT
========================================================= */

/* TABLETTE = toujours expérience app pleine largeur */
@media (max-width:1199px), (pointer:coarse){

  html,
  body{
    background:var(--app-bg) !important;
  }

  .app{
    width:100vw !important;
    max-width:100vw !important;
    margin:0 !important;
    border-radius:0 !important;
    overflow:hidden !important;
  }

  .app-main,
  .chat{
    width:100% !important;
    max-width:100% !important;
  }

  .chat{
    padding-left:24px !important;
    padding-right:24px !important;
  }

  .app-input{
    width:100vw !important;
    max-width:100vw !important;
    left:0 !important;
    transform:none !important;
    bottom:82px !important;
  }

  .bottom-nav{
    width:100vw !important;
    max-width:100vw !important;
    left:0 !important;
    transform:none !important;
    display:grid !important;
  }

  .desktop-menu,
  .desktop-header,
  .desktop-nav,
  .main-header,
  .site-header,
  header{
    display:none !important;
  }
}

/* TABLETTE HORIZONTALE : compact + pleine largeur */
@media (min-width:768px) and (max-width:1199px) and (orientation:landscape){

  .bluupi-zone{
    padding-top:8px !important;
  }

  .bluupi-avatar{
    width:145px !important;
    margin-bottom:-92px !important;
  }

  .chat{
    padding:42px 40px 160px !important;
  }

  .chat .msg:first-child .bubble.bluupi{
    max-width:620px !important;
    margin-left:auto !important;
    margin-right:auto !important;
    font-size:18px !important;
    padding:26px 28px 22px !important;
  }

  .app-input{
    bottom:78px !important;
    padding:9px 24px !important;
  }

  .bottom-nav{
    height:78px !important;
  }

  .text-input{
    height:50px !important;
  }

  .mic-btn,
  .send-btn{
    width:50px !important;
    height:50px !important;
    flex-basis:50px !important;
  }
}

/* DESKTOP : on cache le menu desktop cassé pour l’instant */
@media (min-width:1200px) and (pointer:fine){

  .desktop-menu,
  .desktop-header,
  .desktop-nav,
  .main-header,
  .site-header,
  header{
    display:none !important;
  }

  body{
    background:var(--app-bg) !important;
  }

  .app{
    width:100% !important;
    max-width:980px !important;
    margin:0 auto !important;
    min-height:100dvh !important;
    border-radius:0 !important;
  }

  .app-input{
    width:100% !important;
    max-width:980px !important;
    left:50% !important;
    transform:translateX(-50%) !important;
    bottom:0 !important;
  }

  .bottom-nav{
    display:none !important;
  }
}
/* =========================================================
   FIX — PREMIER MESSAGE BLUUPI = BULLE NORMALE
========================================================= */

.chat .msg:first-child .bubble.bluupi{
  max-width:86% !important;
  margin-left:0 !important;
  margin-right:0 !important;
  padding:12px 15px !important;
  border-radius:22px !important;
  border-bottom-left-radius:7px !important;
  font-size:inherit !important;
  line-height:1.38 !important;
  font-weight:400 !important;
}

@media(min-width:768px) and (max-width:1199px){
  .chat .msg:first-child .bubble.bluupi{
    max-width:72% !important;
    font-size:18px !important;
    padding:12px 15px !important;
  }
}

@media(min-width:1200px) and (pointer:fine){
  .chat .msg:first-child .bubble.bluupi{
    max-width:70% !important;
    font-size:18px !important;
    padding:12px 15px !important;
  }
}