/* chat.css */

* { box-sizing: border-box; }

:root{
  --composer-h: 92px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body{
  height: 100%;
}

body{
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color: var(--text-main);
  background: var(--bg);
  overflow: hidden;
}

/* =====================
   TOP BAR
   ===================== */

.chatTop{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(11,15,25,0.72);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-top: var(--safe-top);
  transform: translateZ(0); 
  -webkit-transform: translateZ(0);
}

.chatTop__inner{
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatTop .brand__icon{
  width: 36px;
  height: 36px;
}

.chatTop .brand__name{
  font-size: 19px;
}

.chatTop .brand__badge{
  font-size: 11px;
  padding: 4px 8px;
}

.chatTop__link{
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.chatTop__link:hover{
  color: var(--text-main);
  text-decoration: underline;
}

/* Push install link and button to the right */
#installLink{
  margin-left: auto;
}

/* =====================
   LAYOUT
   ===================== */

.chatWrap{
  flex: 1;
  min-height: 0;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 0 18px;
  padding-top: 70px;
  display: flex;
}

.chat{
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

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

.messages{
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  padding: 22px 0 calc(18px + var(--composer-h));
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.messages::-webkit-scrollbar{ display: none; }

.msgRow{
  display: flex;
  margin: 10px 0;
}

.msgRow--bot{ justify-content: flex-start; }
.msgRow--user{ justify-content: flex-end; }

/* =====================
   BUBBLES
   ===================== */

.msg{
  max-width: min(680px, 92%);
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 16px;
  white-space: normal;
}

.msg--bot{
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-main);
}

.msg--user{
  background: rgba(111,45,189,0.18);
  border: 1px solid rgba(111,45,189,0.28);
  color: var(--text-main);
}

.msg--bot ul{
  list-style: none;
  padding-left: 0;
  margin: 10px 0 0;
}

.msg--bot li{
  margin: 8px 0;
  padding-left: 0;
}

.msg--bot strong,
.msg--bot h2,
.msg--bot h3{
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Typing dots */
.msg--typing{ padding: 10px 14px; }

.dots{
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.dots i{
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(249,250,251,0.55);
  display: inline-block;
  animation: b 1.1s infinite ease-in-out;
}

.dots i:nth-child(2){ animation-delay: .15s; }
.dots i:nth-child(3){ animation-delay: .30s; }

@keyframes b{
  0%, 80%, 100%{ transform: translateY(0); opacity: .55; }
  40%{ transform: translateY(-3px); opacity: 1; }
}

/* =====================
   TOURNAMENT CARDS
   ===================== */

.tournament-name{
  margin-top: 1.25rem;
  margin-bottom: 0.3rem;
}

.tournament-name:first-child{ margin-top: 0; }

.tournament-name strong,
.tournament-name a strong{
  margin: 0;
  color: var(--padelia-purple-light);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tournament-title-link{
  color: var(--padelia-purple-light);
  text-decoration: none;
}

.tournament-title-link:hover{
  text-decoration: underline;
}

.tournament-separator{
  margin: 1.25rem 0;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.tournament-details{
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0;
  line-height: 1.4;
}

/* =====================
   ACTION BUTTONS
   ===================== */

.actionsRow{
  display: flex;
  gap: 8px;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.msg .actionsRow .btn{
  text-decoration: none !important;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.msg .actionsRow .btn.btn--primary{
  background: var(--padelia-purple);
  box-shadow: 0 4px 12px rgba(111,45,189,0.35);
}

.msg .actionsRow .btn.btn--ghost{
  background: transparent;
}

.msg .actionsRow .btn--primary::after{
  content: " →";
}

/* =====================
   COMPOSER
   ===================== */

.composer{
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(11,15,25,0.86);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 12px 0 calc(10px + var(--safe-bottom));
}

.composer__inner{
  max-width: 980px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.composer__inputWrap{
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 999px;
  background: rgba(0,0,0,0.26);
  border: 1px solid rgba(255,255,255,0.08);
}

.composer__input{
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font-size: 16px;
  resize: none;
  line-height: 1.4;
  max-height: 140px;
  overflow: auto;
}

.composer__input::placeholder{
  color: rgba(249,250,251,0.45);
  font-size: 14px;
}

.composer__btn{
  border: 1px solid var(--padelia-purple);
  background: var(--padelia-purple);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(111,45,189,0.25);
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease, opacity .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.composer__btn:hover{
  background: var(--padelia-purple-dark);
  box-shadow: 0 8px 26px rgba(111,45,189,0.30);
}

.composer__btn:active{ transform: translateY(1px); }

.composer__btn:disabled{
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.10);
  color: rgba(249,250,251,0.70);
}

.composer__btnText{ display: none; }

.composer__btnIcon{
  font-size: 16px;
  line-height: 1;
  transform: translateY(-1px);
}

/* Focus states */
.composer__inputWrap:focus-within{
  border-color: rgba(111,45,189,0.55);
  box-shadow:
    0 0 0 1px rgba(111,45,189,0.35),
    0 0 0 6px rgba(111,45,189,0.12);
}

.composer__btn:focus-visible{
  outline: none;
  box-shadow:
    0 0 0 2px rgba(111,45,189,0.55),
    0 0 0 6px rgba(111,45,189,0.20);
}

/* =====================
   EMPTY STATE
   ===================== */

body.chat--empty{
  overflow: hidden;
}

body.chat--empty .chatWrap{ align-items: center; }
body.chat--empty .messages{ padding: 0; }

body.chat--empty .composer{
  position: static;
  border-top: 0;
  background: transparent;
  backdrop-filter: none;
  padding: 0;
}

body.chat--empty .composer__inner{ padding: 0 18px; }

body.chat--empty .composer__inputWrap{
  padding: 16px 16px;
  border-radius: 18px;
}

/* =====================
   INSTALL BUTTON
   ===================== */

.btn-install{
  padding: 8px 14px;
  background: rgba(111, 45, 189, 0.2);
  border: 1px solid rgba(111, 45, 189, 0.4);
  border-radius: 999px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-install:hover{
  background: rgba(111, 45, 189, 0.3);
  border-color: rgba(111, 45, 189, 0.6);
}

/* =====================
   IOS INSTALL TOAST
   ===================== */

.install-toast{
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 320px;
  width: calc(100% - 32px);
  background: rgba(11, 15, 25, 0.98);
  border: 1px solid rgba(111, 45, 189, 0.4);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  z-index: 9999;
  backdrop-filter: blur(10px);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp{
  from{
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to{
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.install-toast__inner{
  color: var(--text-main);
  position: relative;
}

.install-toast__close{
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.install-toast__inner strong{
  display: block;
  margin-bottom: 12px;
  color: var(--padelia-purple-light);
  font-size: 16px;
}

.install-toast__inner p{
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
}

/* =====================
   RESPONSIVE
   ===================== */

@media (min-width: 641px){
  .composer__btnText{ display: inline; }
}

@media (max-width: 720px){
  .composer__inner{ padding: 0 12px; }
  .chatTop__inner{ padding: 10px 12px; }
}

@media (max-width: 640px){
  .chatTop__link{ font-size: 12px; opacity: .9; }

  .messages{ padding: 16px 0 14px; }
  .msg{ max-width: 94%; padding: 11px 12px; border-radius: 14px; }

  .composer{ padding: 10px 0 calc(10px + var(--safe-bottom)); }
  .composer__inputWrap{ padding: 12px 14px; }
  .composer__btn{ padding: 10px 14px; font-size: 13px; }

  .tournament-separator{ margin: 1.5rem 0; }

  .tournament-name strong,
  .tournament-name h2,
  .tournament-name h3{
    font-size: 1rem;
  }

 .tournament-name strong,
  .tournament-name a strong{
    font-size: 0.95rem;
    text-transform: uppercase;
  }
  
  .tournament-details{
    font-size: 0.85rem;
    margin: 0.3rem 0;
  } 

  .msg .actionsRow .btn{
    padding: 6px 12px;
    font-size: 12px;
  }
}

@media (max-width: 400px){
  .composer__btn{ padding: 10px 12px; }
}