/* =================================================
   IMAGE OVERLAY (FLAGS)
================================================= */

.tai-image-wrap {
  position: relative;
  display: block;
  width: 100%;
  overflow: visible !important;
}

.tai-image-wrap img {
  width: 100%;
  height: auto;
  display: block;
}


/* Overlay position */

.tai-image-overlay {
  position: absolute;

  bottom: 8px !important;
  left: 8px !important;
  right: auto !important;

  inset-inline-start: 8px !important;
  inset-inline-end: auto !important;

  z-index: 9999;

  pointer-events: auto;

  transform: none !important;
}



/* =================================================
   FLAGS BAR
================================================= */

.tai-translate-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  background: none !important;
  backdrop-filter: none !important;

  padding: 0 !important;
  border-radius: 0 !important;
}


/* Flag images */

.tai-flag {
  width: 24px !important;
  height: 24px !important;

  aspect-ratio: 1 / 1;

  border-radius: 50% !important;

  object-fit: contain !important;

  display: block;

  background: none !important;
  background-color: transparent !important;
  background-image: none !important;

  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;

  padding: 0 !important;
  margin: 0 !important;

  line-height: 0 !important;

  cursor: pointer;

  overflow: hidden;
}


/* Remove theme interference */

.tai-image-overlay img,
.tai-translate-bar img,
.tai-flag,
.tai-flag::before,
.tai-flag::after {
  background: none !important;
  background-color: transparent !important;
  background-image: none !important;

  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;

  filter: none !important;

  content: none !important;
}


/* Hover feedback */

.tai-flag:hover {
  transform: scale(1.08);
  transition: transform 0.15s ease;
}



/* =================================================
   AI ROOT (MODAL CONTAINER)
================================================= */

#tai-ai-root {
  position: fixed;
  inset: 0;

  background: rgba(0, 0, 0, 0.55);

  z-index: 999999;

  display: none;
}

.tai-ai-bg {
  position: absolute;
  inset: 0;
}



/* =================================================
   PANEL (MODAL BOX)
================================================= */

.tai-panel {
  position: relative;

  background: #ffffff;

  width: 92%;
  max-width: 720px;
  height: 90vh;

  margin: auto;
  top: 5vh;

  border-radius: 12px;
  overflow: hidden;

  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);

  display: flex;
  flex-direction: column;

  font-family: inherit;

  min-height: 0;
  /* Critical for scroll */
}



/* =================================================
   HEADER
================================================= */

.tai-panel-header {
  background: var(--tai-primary, #0056a3);
  color: #ffffff;

  padding: 12px 16px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  flex-shrink: 0;
}

.tai-panel-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tai-panel-brand img {
  height: 24px;
}

.tai-panel-title {
  font-size: 15px;
  font-weight: 600;
}

.tai-panel-close {
  cursor: pointer;
  font-size: 22px;
  line-height: 1;

  user-select: none;
}



/* =================================================
   BODY (SCROLL ZONE)
================================================= */

.tai-panel-body {
  padding: 18px;

  font-size: 15px;
  line-height: 1.6;
  color: #222222;

  flex: 1;

  overflow-y: auto;

  -webkit-overflow-scrolling: touch;

  min-height: 0;
  /* Critical for scroll */
}



/* =================================================
   FOOTER
================================================= */

.tai-panel-footer {
  padding: 12px 16px;

  border-top: 1px solid #eeeeee;

  background: #f8f9fb;

  display: flex;
  flex-wrap: nowrap;
  gap: 10px;

  overflow-x: hidden;

  flex-shrink: 0;
}



/* =================================================
   SOCIAL BUTTONS
================================================= */

.tai-social-btn {
  background: #f2f2f2;
  color: #333333;

  padding: 6px 12px;
  border-radius: 5px;

  font-size: 13px;
  text-decoration: none;

  transition: background 0.2s ease;
}

.tai-social-btn:hover {
  background: #dddddd;
}



/* =================================================
   LOADING
================================================= */

.tai-progress {
  text-align: center;
  padding: 30px 10px;
  color: #666666;
}



/* =================================================
   BODY LOCK
================================================= */

body.tai-no-scroll {
  overflow: hidden !important;
}



/* =================================================
   CLICK / Z-INDEX FIX
================================================= */

.tai-image-overlay,
.tai-translate-bar,
.tai-flag {
  pointer-events: auto !important;
}



/* =================================================
   MOBILE / TABLET
================================================= */

@media (max-width: 768px) {

  .tai-panel {
    width: 94%;
    height: 94vh;
    top: 3vh;
  }

  .tai-flag {
    width: 22px !important;
    height: 22px !important;
  }

}

/* =================================================
   AI TITLE NORMALIZATION
================================================= */

.tai-panel-body h2 {
  font-size: 22px !important;
  line-height: 1.3;
  font-weight: 700;

  margin: 0 0 14px 0;

  word-break: break-word;
  hyphens: auto;
}

@media (max-width: 768px) {

  .tai-panel-body h2 {
    font-size: 18px !important;
    line-height: 1.25;
  }

}

.tai-social-btn{
  font-weight: normal !important;
}

@media (max-width: 480px){

  .tai-panel-footer{
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;

    align-items: center;

    padding: 8px 6px; /* IMPORTANT */
  }

  .tai-social-btn{
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: center;

    text-align: center;

    font-size: 13px;
    padding: 6px 4px;

    white-space: nowrap;
  }

}