:root{
  --bg:#060608;
  --surface:#17171F;
  --surface2:#0D0D13;
  --header:#0F2027;
  --border:#23232E;
  --border2:#1F1F28;
  --cyan:#22D3EE;
  --cyanText:#67E8F9;
  --yellow:#FACC15;
  --pink:#E94F8A;
  --purple:#8B5CF6;
  --green:#4ADE80;
  --red:#F87171;
  --text:#FFFFFF;
  --text2:#D4D4DC;
  --muted:#8A8A95;
  --muted2:#5C5C68;
}

*{
  box-sizing:border-box;
  -webkit-tap-highlight-color:transparent;
}

html,body{
  margin:0;
  width:100%;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  overflow:hidden;
}

body{
  min-height:100dvh;
}

button,input{
  font:inherit;
}

button{
  cursor:pointer;
}

.app{
  position:relative;
  width:100%;
  height:100dvh;
  overflow:hidden;
  background:var(--bg);
}

.waves{
  position:fixed;
  inset:0;
  pointer-events:none;
  overflow:hidden;
  opacity:.9;
}

.wave{
  position:absolute;
  left:-10%;
  width:120%;
  height:90px;
  border-radius:50%;
  border-top:1.4px solid;
  animation:waveMove 12s linear infinite;
}

.wave.cyan{
  top:27%;
  border-color:rgba(34,211,238,.28);
}

.wave.pink{
  top:45%;
  border-color:rgba(233,79,138,.28);
  animation-duration:17s;
  animation-direction:reverse;
}

.wave.purple{
  top:63%;
  border-color:rgba(139,92,246,.28);
  animation-duration:10s;
}

.wave.yellow{
  top:78%;
  border-color:rgba(250,204,21,.28);
  animation-duration:22s;
  animation-direction:reverse;
}

@keyframes waveMove{
  0%{transform:translateX(-5%) rotate(-2deg) scaleY(.7)}
  50%{transform:translateX(5%) rotate(2deg) scaleY(1.3)}
  100%{transform:translateX(-5%) rotate(-2deg) scaleY(.7)}
}

.screen{
  position:relative;
  z-index:2;
  width:100%;
  height:100%;
}

.hidden{
  display:none!important;
}

.login-screen{
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:auto;
  padding:
    max(24px,env(safe-area-inset-top))
    32px
    max(24px,env(safe-area-inset-bottom));
}

.login-box{
  width:100%;
  max-width:420px;
  text-align:center;
}

.logo-glow{
  width:180px;
  height:180px;
  margin:0 auto 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  filter:drop-shadow(0 0 28px rgba(34,211,238,.25));
}

.logo-glow img{
  width:140px;
  height:140px;
  object-fit:contain;
}

.login-title{
  margin:0;
  font-size:24px;
  font-weight:700;
}

.login-subtitle{
  margin:5px 0 40px;
  color:var(--muted);
  font-size:13px;
}

.field{
  position:relative;
  display:flex;
  align-items:center;
  width:100%;
  min-height:50px;
  margin-bottom:12px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:12px;
}

.field-icon{
  width:48px;
  color:var(--muted2);
  font-size:20px;
  flex:none;
}

.field input{
  width:100%;
  min-width:0;
  padding:14px 14px 14px 0;
  border:0;
  outline:0;
  color:white;
  background:transparent;
  font-size:14px;
}

.field input::placeholder{
  color:var(--muted2);
}

.password-toggle{
  width:46px;
  height:46px;
  border:0;
  background:transparent;
  color:var(--muted2);
  font-size:19px;
}

.login-error{
  margin:4px 0 12px;
  color:var(--red);
  font-size:13px;
  text-align:left;
}

.btn-primary{
  width:100%;
  min-height:48px;
  border:0;
  border-radius:12px;
  background:var(--yellow);
  color:var(--surface2);
  font-weight:700;
  font-size:15px;
}

.btn-primary:disabled{
  opacity:.65;
}

.main-screen{
  display:flex;
  flex-direction:column;
}

.topbar{
  flex:none;
  min-height:56px;
  padding:
    max(8px,env(safe-area-inset-top))
    14px
    8px;
  background:var(--header);
  display:flex;
  align-items:center;
  gap:10px;
}

.topbar-logo{
  width:32px;
  height:32px;
  padding:4px;
  background:#111;
  border-radius:50%;
  object-fit:contain;
}

.topbar-title{
  font-size:16px;
  font-weight:600;
}

.topbar-spacer{
  flex:1;
}

.content{
  position:relative;
  flex:1;
  min-height:0;
  overflow:hidden;
}

.page{
  position:absolute;
  inset:0;
  display:none;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

.page.active{
  display:block;
}

.page-title{
  margin:0;
  padding:15px 16px;
  background:var(--header);
  font-size:16px;
  font-weight:600;
}

.page-body{
  padding:16px;
  padding-bottom:28px;
}

.bottom-nav{
  flex:none;
  display:flex;
  min-height:64px;
  padding-bottom:env(safe-area-inset-bottom);
  background:#000;
  border-top:1px solid var(--border2);
}

.nav-item{
  flex:1;
  border:0;
  background:transparent;
  color:var(--muted2);
  padding:9px 2px 7px;
  font-size:10.5px;
}

.nav-item .nav-icon{
  display:block;
  margin-bottom:4px;
  font-size:21px;
}

.nav-item.active{
  color:var(--cyan);
  font-weight:600;
}

.card{
  margin-bottom:12px;
  padding:16px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
}

.empty{
  min-height:50vh;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--muted2);
  text-align:center;
}

.loading{
  min-height:50vh;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--cyan);
}

.spinner{
  width:24px;
  height:24px;
  border:2px solid rgba(34,211,238,.2);
  border-top-color:var(--cyan);
  border-radius:50%;
  animation:spin .7s linear infinite;
}

@keyframes spin{
  to{transform:rotate(360deg)}
}

.status{
  display:inline-block;
  padding:4px 10px;
  border-radius:20px;
  font-size:11px;
  font-weight:600;
}

.status.pago,.status.ativo{
  color:var(--green);
  background:rgba(74,222,128,.15);
}

.status.atrasado,.status.suspenso{
  color:var(--red);
  background:rgba(248,113,113,.15);
}

.status.pendente{
  color:var(--yellow);
  background:rgba(250,204,21,.15);
}

.profile{
  padding:20px;
  text-align:center;
}

.profile-avatar{
  width:72px;
  height:72px;
  margin:0 auto 12px;
  border-radius:50%;
  border:1px solid var(--border);
  background:var(--surface);
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--cyan);
  font-size:36px;
}

.profile-name{
  font-size:17px;
  font-weight:600;
}

.logout-btn{
  width:100%;
  height:48px;
  margin-top:32px;
  border:1px solid var(--border);
  border-radius:12px;
  background:transparent;
  color:var(--red);
  font-weight:600;
}

@media (min-width:700px){
  .app{
    max-width:520px;
    margin:0 auto;
    border-left:1px solid var(--border);
    border-right:1px solid var(--border);
  }
}

/* CORRECAO DO FUNDO - ONDAS MIDIAON */
.waves{
  background:
    radial-gradient(ellipse at 25% 30%, rgba(34,211,238,.045) 0%, transparent 38%),
    radial-gradient(ellipse at 75% 48%, rgba(233,79,138,.035) 0%, transparent 38%),
    radial-gradient(ellipse at 30% 68%, rgba(139,92,246,.035) 0%, transparent 38%),
    #060608;
}

.wave{
  display:none;
}

/* PWA ocupa toda a tela */
@media (min-width:700px){
  .app{
    max-width:none;
    width:100%;
    margin:0;
    border:0;
  }

  .login-box{
    max-width:420px;
  }
}

/* ONDAS ANIMADAS MIDIAON */
.waves::before{
  content:"";
  position:absolute;
  inset:-10%;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='800' viewBox='0 0 1200 800'%3E%3Cpath d='M0 230 C150 190 300 270 450 230 S750 190 900 230 S1050 270 1200 230' fill='none' stroke='%2322D3EE' stroke-opacity='.28' stroke-width='1.4'/%3E%3Cpath d='M0 380 C150 330 300 430 450 380 S750 330 900 380 S1050 430 1200 380' fill='none' stroke='%23E94F8A' stroke-opacity='.28' stroke-width='1.4'/%3E%3Cpath d='M0 520 C150 485 300 555 450 520 S750 485 900 520 S1050 555 1200 520' fill='none' stroke='%238B5CF6' stroke-opacity='.28' stroke-width='1.4'/%3E%3Cpath d='M0 650 C150 620 300 680 450 650 S750 620 900 650 S1050 680 1200 650' fill='none' stroke='%23FACC15' stroke-opacity='.28' stroke-width='1.4'/%3E%3C/svg%3E");
  background-size:cover;
  background-position:center;
  animation:midiaWaves 12s ease-in-out infinite alternate;
}

@keyframes midiaWaves{
  from{transform:translateX(-2%) translateY(-5px);}
  to{transform:translateX(2%) translateY(5px);}
}

/* ANIMACAO REAL DAS ONDAS SVG */
.waves::before{
  display:none !important;
}

.waves-svg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  overflow:visible;
}

.svg-wave{
  fill:none;
  stroke-width:1.4;
  vector-effect:non-scaling-stroke;
  animation:ondaMidiaOn 7s ease-in-out infinite alternate;
}

.cyan-line{
  stroke:rgba(34,211,238,.30);
  animation-duration:6s;
}

.pink-line{
  stroke:rgba(233,79,138,.30);
  animation-duration:8s;
  animation-direction:alternate-reverse;
}

.purple-line{
  stroke:rgba(139,92,246,.30);
  animation-duration:5.5s;
}

.yellow-line{
  stroke:rgba(250,204,21,.30);
  animation-duration:9s;
  animation-direction:alternate-reverse;
}

@keyframes ondaMidiaOn{
  0%{
    transform:translateX(-25px) translateY(-6px);
  }
  50%{
    transform:translateX(20px) translateY(7px);
  }
  100%{
    transform:translateX(-10px) translateY(-3px);
  }
}

/* CHAT MIDIAON */
.page[data-page="chat"]{
  overflow:hidden;
}

.chat-layout{
  height:100%;
  display:flex;
  flex-direction:column;
}

.chat-messages{
  flex:1;
  min-height:0;
  overflow-y:auto;
  padding:16px;
  -webkit-overflow-scrolling:touch;
}

.chat-empty{
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  color:var(--muted2);
  line-height:1.5;
}

.message-row{
  display:flex;
  margin:4px 0;
}

.message-row.cliente{
  justify-content:flex-end;
}

.message-row.midiahosts{
  justify-content:flex-start;
}

.message{
  max-width:75%;
  padding:10px 14px;
  border-radius:14px;
  background:var(--surface);
  border:1px solid var(--border);
  color:var(--text2);
  font-size:14px;
  line-height:1.4;
  overflow-wrap:anywhere;
}

.message-row.cliente .message{
  background:#1A2E33;
  border-color:rgba(34,211,238,.30);
  color:var(--cyanText);
}

.message a{
  color:var(--yellow);
  text-decoration:underline;
}

.message-row.cliente .message a{
  color:var(--cyan);
}

.message-time{
  display:block;
  margin-top:4px;
  color:var(--muted2);
  font-size:10px;
}

.message-image{
  display:block;
  max-width:100%;
  max-height:320px;
  border-radius:10px;
  cursor:pointer;
}

.message-audio{
  width:260px;
  max-width:100%;
}

.message-document{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px;
  background:var(--surface2);
  border-radius:10px;
  color:inherit;
  text-decoration:none!important;
}

.message-document-icon{
  font-size:25px;
}

.message-document-name{
  min-width:0;
  flex:1;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:12px;
}

.chat-preview{
  flex:none;
  display:none;
  align-items:center;
  gap:10px;
  padding:8px 16px;
  background:var(--surface2);
  border-top:1px solid var(--border2);
}

.chat-preview.active{
  display:flex;
}

.chat-preview-name{
  flex:1;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:12px;
}

.chat-preview-remove{
  border:0;
  background:transparent;
  color:var(--muted);
  font-size:20px;
}

.chat-compose{
  flex:none;
  display:flex;
  align-items:center;
  gap:6px;
  padding:12px;
  background:var(--surface2);
  border-top:1px solid var(--border2);
  padding-bottom:max(12px,env(safe-area-inset-bottom));
}

.chat-attach{
  width:38px;
  height:38px;
  flex:none;
  border:0;
  background:transparent;
  color:var(--muted);
  font-size:23px;
}

.chat-input-wrap{
  flex:1;
  min-width:0;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:24px;
}

.chat-input{
  width:100%;
  min-height:42px;
  border:0;
  outline:0;
  background:transparent;
  color:white;
  padding:10px 16px;
  font-size:14px;
}

.chat-input::placeholder{
  color:var(--muted2);
}

.chat-send{
  width:40px;
  height:40px;
  flex:none;
  border:0;
  border-radius:50%;
  background:var(--yellow);
  color:var(--surface2);
  font-size:22px;
  font-weight:700;
}

.chat-send:disabled{
  opacity:.6;
}

#chatFile{
  display:none;
}

/* CORRECAO CHAT ACIMA DO MENU INFERIOR */
.page[data-page="chat"]{
  overflow:hidden;
}

.page[data-page="chat"] .chat-layout{
  height:100%;
  min-height:0;
  padding-bottom:0;
}

.chat-messages{
  min-height:0;
}

.chat-compose{
  position:relative;
  z-index:5;
  flex-shrink:0;
}

/* AJUSTE DEFINITIVO DA ALTURA DO CHAT */
.page[data-page="chat"].active{
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.page[data-page="chat"] .topbar{
  flex-shrink:0;
}

.page[data-page="chat"] .chat-layout{
  flex:1;
  height:auto;
  min-height:0;
  overflow:hidden;
}

.page[data-page="chat"] .chat-messages{
  flex:1;
  min-height:0;
  overflow-y:auto;
}

.page[data-page="chat"] .chat-compose{
  flex:none;
}

/* CORRECAO SAFARI IOS - INPUT DE ARQUIVO */
#chatFile{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
  opacity:0 !important;
  pointer-events:none !important;
}

.chat-compose{
  width:100%;
  flex-wrap:nowrap !important;
}

.chat-input-wrap{
  min-width:0;
}

.chat-input{
  display:block;
  width:100%;
}

/* PRESERVAR FORMATACAO DAS MENSAGENS DO CHATBOT */
.message{
  white-space:pre-wrap;
}

/* CORRECAO DAS CAIXAS DE MENSAGEM */
.message{
  white-space:normal;
}

.message-text{
  white-space:pre-wrap;
}

/* MICROFONE - ATENDIMENTO HUMANO */
.chat-mic{
  width:40px;
  height:40px;
  flex:none;
  border:0;
  border-radius:50%;
  background:transparent;
  color:var(--cyan);
  font-size:22px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.chat-mic.gravando{
  color:var(--red);
  background:rgba(248,113,113,.15);
  animation:micPulse 1s ease-in-out infinite;
}

@keyframes micPulse{
  50%{
    transform:scale(1.12);
    opacity:.65;
  }
}

/* DESTAQUE FORTE - MICROFONE GRAVANDO */
.chat-mic.gravando{
  color:#FFFFFF !important;
  background:#EF4444 !important;
  box-shadow:
    0 0 0 5px rgba(239,68,68,.20),
    0 0 18px rgba(239,68,68,.85);
  animation:micGravandoForte .85s ease-in-out infinite alternate;
}

@keyframes micGravandoForte{
  from{
    transform:scale(1);
    box-shadow:
      0 0 0 3px rgba(239,68,68,.20),
      0 0 10px rgba(239,68,68,.60);
  }
  to{
    transform:scale(1.12);
    box-shadow:
      0 0 0 8px rgba(239,68,68,.10),
      0 0 24px rgba(239,68,68,1);
  }
}
