/* =====================================================
   LibreSpeed Reformulado — estilo.css
   Base: /var/www/liveteste/temp-front/estilo.css
   Extensões: CSS variables, dark mode, novos componentes
   ===================================================== */

/* ---------- Fontes ---------- */
@font-face {
  font-family: OpenSansBold;
  src: url(fonts/OpenSans-Semibold.ttf);
}
@font-face {
  font-family: OpenSans;
  src: url(fonts/OpenSans-Light.ttf);
}

/* ---------- Animações (originais preservadas) ---------- */
@keyframes shadow-pulse {
  0%   { box-shadow: 0 0 0 0px var(--color-btn); }
  100% { box-shadow: 0 0 0 15px rgba(0,0,0,0); }
}
@keyframes shadow-pulsered {
  0%   { box-shadow: 0 0 0 0px #F44336; }
  100% { box-shadow: 0 0 0 15px rgba(0,0,0,0); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- CSS Variables — Light Mode ---------- */
:root {
  --color-bg:           #F5F5F5;
  --color-bg-card:      #FFFFFF;
  --color-fg:           #212121;
  --color-fg-muted:     #616161;
  --color-header:       #424242;
  --color-header-text:  #FFFFFF;
  --color-footer:       #424242;
  --color-footer-text:  #FFFFFF;
  --color-accent-dl:    #00E676;
  --color-accent-ul:    #00E5FF;
  --color-btn:          #40C4FF;
  --color-btn-stop:     #F44336;
  --color-btn-stop-border: #E53935;
  --color-ping:         #FF9100;
  --color-warn:         #F44336;
  --color-warn-dark:    #C62828;
  --color-link:         #01579B;
  --color-border:       #E0E0E0;
  --color-border-card:  #BDBDBD;
  --color-meter-bg:     #424242;
  --color-input-bg:     #F5F5F5;
  /* bufferbloat grades */
  --grade-A:  #4CAF50;
  --grade-B:  #8BC34A;
  --grade-C:  #FFC107;
  --grade-D:  #FF9800;
  --grade-F:  #F44336;
  /* badge IP stack */
  --badge-dual:   #1976D2;
  --badge-ipv4:   #616161;
  --badge-ipv6:   #7B1FA2;
  --badge-cgnat:  #E65100;
}

/* ---------- Dark Mode ---------- */
[data-theme="dark"], @media (prefers-color-scheme: dark) {
  :root {
    --color-bg:           #121212;
    --color-bg-card:      #1E1E1E;
    --color-fg:           #E0E0E0;
    --color-fg-muted:     #9E9E9E;
    --color-header:       #1A1A1A;
    --color-header-text:  #FFFFFF;
    --color-footer:       #1A1A1A;
    --color-footer-text:  #BDBDBD;
    --color-accent-dl:    #00E676;
    --color-accent-ul:    #00E5FF;
    --color-btn:          #29B6F6;
    --color-btn-stop:     #EF5350;
    --color-btn-stop-border: #E53935;
    --color-ping:         #FFB74D;
    --color-warn:         #EF5350;
    --color-warn-dark:    #FF7043;
    --color-link:         #64B5F6;
    --color-border:       #333333;
    --color-border-card:  #424242;
    --color-meter-bg:     #333333;
    --color-input-bg:     #2A2A2A;
  }
}
[data-theme="dark"] {
  --color-bg:           #121212;
  --color-bg-card:      #1E1E1E;
  --color-fg:           #E0E0E0;
  --color-fg-muted:     #9E9E9E;
  --color-header:       #1A1A1A;
  --color-header-text:  #FFFFFF;
  --color-footer:       #1A1A1A;
  --color-footer-text:  #BDBDBD;
  --color-btn:          #29B6F6;
  --color-btn-stop:     #EF5350;
  --color-btn-stop-border: #E53935;
  --color-ping:         #FFB74D;
  --color-warn:         #EF5350;
  --color-warn-dark:    #FF7043;
  --color-link:         #64B5F6;
  --color-border:       #333333;
  --color-border-card:  #424242;
  --color-meter-bg:     #333333;
  --color-input-bg:     #2A2A2A;
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  border: none; padding: 0; margin: 0;
  background: var(--color-bg);
  color: var(--color-fg);
  transition: background 0.3s, color 0.3s;
}
body {
  text-align: center;
  font-family: "OpenSans", sans-serif;
}
img { max-width: 100%; height: auto; }
a   { color: var(--color-link); }

/* ---------- Layout Raiz ---------- */
#testWrapper {
  position: relative;
  min-height: 100vh;
}
#test {
  padding-bottom: 210px;
  animation: fadeIn 0.4s ease;
}

/* ---------- Header ---------- */
.cabec {
  height: 68px;
  background: var(--color-header);
  color: var(--color-header-text);
  margin-bottom: 20px;
}
.tit {
  margin: auto;
  width: 95%;
  display: flex;
  align-items: center;
  font-size: 1.25rem;
  font-weight: bold;
  height: 68px;
  gap: 0.6em;
}
.tit a { display: flex; align-items: center; }
.tit img { height: 36px; margin-right: 8px; }

/* Controles do header: seletor de servidor + toggle dark */
.header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75em;
}
#serverSelect {
  background: rgba(255,255,255,0.1);
  color: var(--color-header-text);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 0.25em 0.5em;
  font-family: "OpenSans", sans-serif;
  font-size: 0.85em;
  cursor: pointer;
  max-width: 180px;
}
#serverSelect option { color: #212121; background: #fff; }
#themeToggleBtn {
  background: none; border: none;
  color: var(--color-header-text);
  cursor: pointer;
  font-size: 1.2em;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.2s;
}
#themeToggleBtn:hover { background: rgba(255,255,255,0.15); }
#themeToggleBtn:focus-visible { outline: 2px solid var(--color-btn); }

/* ---------- Botão Start/Stop (original preservado) ---------- */
#startStopBtn {
  display: inline-block;
  width: 90px;
  height: 90px;
  font: 18px/90px "OpenSans", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.1px;
  color: var(--color-fg);
  text-align: center;
  font-weight: bold;
  border-radius: 50%;
  border: 0.1em solid var(--color-btn);
  animation: shadow-pulse 1s 10;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
  margin: 1em 0;
}
#startStopBtn.running {
  background-color: var(--color-btn-stop);
  border-color: var(--color-btn-stop-border);
  color: #FFFFFF;
  animation: shadow-pulsered 1s 2;
}
#startStopBtn::before { content: "Iniciar"; }
#startStopBtn.running::before { content: "Parar"; }
#startStopBtn:focus-visible { outline: 3px solid var(--color-btn); outline-offset: 3px; }

/* ---------- Medidores (testArea) ---------- */
div.testGroup {
  display: block;
  margin: 0 auto;
}
div.testArea {
  display: inline-block;
  width: 16em;
  height: 12.5em;
  position: relative;
  box-sizing: border-box;
}
div.testArea2 {
  display: inline-block;
  width: 14em;
  height: 7em;
  position: relative;
  box-sizing: border-box;
  text-align: center;
}
div.testArea div.testName {
  position: absolute;
  top: 0.1em; left: 0;
  width: 100%;
  font-size: 1.2em;
  z-index: 9;
}
div.testArea2 div.testName {
  display: block;
  text-align: center;
  font-size: 1.2em;
}
div.testArea div.meterText {
  position: absolute;
  bottom: 1.55em; left: 0;
  width: 100%;
  font-size: 2.2em;
  z-index: 9;
}
div.testArea2 div.meterText {
  display: inline-block;
  font-size: 1.5em;
}
div.meterText:empty::before { content: "0.00"; }
div.testArea div.unit {
  position: absolute;
  bottom: 2em; left: 0;
  width: 100%;
  z-index: 9;
}
div.testArea2 div.unit { display: inline-block; }
div.testArea canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
}

/* ---------- Seção de recomendações ---------- */
#recomend {
  text-align: center;
  font-size: 1em;
  color: var(--color-warn-dark);
}

/* ---------- Seção de IP ---------- */
#ipArea {
  margin: 0.5em 0;
  font-size: 0.95em;
  color: var(--color-fg-muted);
}

/* ---------- Panel (cards de métricas) ---------- */
.panel {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-card);
  border-radius: 8px;
  margin: 1em auto;
  padding: 1em 1.25em;
  max-width: 860px;
  text-align: left;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  animation: fadeIn 0.35s ease;
}
.panel-title {
  font-size: 1em;
  font-family: "OpenSansBold", sans-serif;
  margin-bottom: 0.75em;
  display: flex;
  align-items: center;
  gap: 0.5em;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5em;
}
.panel-title .icon { font-size: 1.15em; }

/* ---------- Metric Grid ---------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75em;
}
.metric-item {
  text-align: center;
  padding: 0.6em 0.4em;
  border-radius: 6px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  position: relative;
}
.metric-label {
  font-size: 0.75em;
  color: var(--color-fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
}
.metric-value {
  font-size: 1.4em;
  font-family: "OpenSansBold", sans-serif;
}
.metric-unit {
  font-size: 0.7em;
  color: var(--color-fg-muted);
}

/* Cores de estado das métricas */
.metric-good  { color: var(--color-accent-dl); }
.metric-warn  { color: var(--color-ping); }
.metric-bad   { color: var(--color-warn); }
.metric-neutral { color: var(--color-fg); }

/* ---------- Bufferbloat Badge ---------- */
.bufferbloat-grade {
  display: inline-block;
  width: 2em; height: 2em;
  line-height: 2em;
  text-align: center;
  border-radius: 50%;
  font-family: "OpenSansBold", sans-serif;
  font-size: 1.1em;
  color: #fff;
}
.grade-A { background: var(--grade-A); }
.grade-B { background: var(--grade-B); }
.grade-C { background: var(--grade-C); color: #212121; }
.grade-D { background: var(--grade-D); }
.grade-F { background: var(--grade-F); }
.grade-empty { background: var(--color-border); color: var(--color-fg-muted); }

/* ---------- Badge Stack IP ---------- */
.ip-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 12px;
  font-size: 0.75em;
  font-family: "OpenSansBold", sans-serif;
  color: #fff;
  margin: 0.1em;
}
.badge-dual   { background: var(--badge-dual); }
.badge-ipv4   { background: var(--badge-ipv4); }
.badge-ipv6   { background: var(--badge-ipv6); }
.badge-cgnat  { background: var(--badge-cgnat); }

/* ---------- Tabela de comparação IPv4/IPv6 ---------- */
.ipv-compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}
.ipv-compare th, .ipv-compare td {
  border: 1px solid var(--color-border);
  padding: 0.5em 0.75em;
  text-align: center;
}
.ipv-compare th {
  background: var(--color-bg);
  font-family: "OpenSansBold", sans-serif;
}

/* ---------- Tabela CDN Latency ---------- */
.cdn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
}
.cdn-table th, .cdn-table td {
  border: 1px solid var(--color-border);
  padding: 0.4em 0.7em;
  text-align: center;
}
.cdn-table th { background: var(--color-bg); font-family: "OpenSansBold", sans-serif; }
.cdn-table td:first-child { text-align: left; }

/* ---------- Área de compartilhamento ---------- */
#shareArea {
  width: 95%;
  max-width: 40em;
  margin: 0 auto;
  margin-top: 1.5em;
}
#shareArea > * {
  display: block;
  height: auto;
  margin: auto;
  max-width: 100%;
}
#resultsURL {
  text-align: center;
  background: var(--color-input-bg);
  cursor: pointer;
  color: var(--color-link);
  border: 1px solid var(--color-border-card);
  border-radius: 4px;
  font-size: 0.8em;
  font-family: "OpenSans", sans-serif;
  width: 100%;
  padding: 10px;
  margin-bottom: 0.5em;
  transition: background 0.2s;
}
#resultsURL:focus { outline: 2px solid var(--color-btn); }
.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  justify-content: center;
  margin-top: 0.75em;
}
.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.5em 1em;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-family: "OpenSans", sans-serif;
  font-size: 0.85em;
  transition: opacity 0.2s, transform 0.15s;
  color: #fff;
  background: var(--color-btn);
}
.btn-share:hover  { opacity: 0.88; }
.btn-share:active { transform: scale(0.97); }
.btn-share:focus-visible { outline: 2px solid var(--color-btn); outline-offset: 2px; }
.btn-share.btn-pdf { background: #E53935; }
.btn-share.btn-export { background: #388E3C; }

/* ---------- Histórico / Gráfico ---------- */
.history-chart-container {
  position: relative;
  width: 100%;
  max-width: 780px;
  margin: 0 auto 1em;
  height: 220px;
}

/* ---------- Tooltip ---------- */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 0.3em 0.6em;
  border-radius: 4px;
  font-size: 0.75em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
  max-width: 220px;
  white-space: normal;
  text-align: center;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus::after { opacity: 1; }

/* ---------- Disclaimer Banner ---------- */
#disclaimerBanner {
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  font-size: 0.75em;
  color: var(--color-fg-muted);
  padding: 0.5em 1em;
  text-align: center;
  position: relative;
  z-index: 10;
}
#disclaimerBanner details summary {
  cursor: pointer;
  user-select: none;
  color: var(--color-link);
}

/* ---------- Aviso de limitação (inline) ---------- */
.limitation-note {
  font-size: 0.78em;
  color: var(--color-fg-muted);
  background: var(--color-bg);
  border-left: 3px solid var(--color-ping);
  border-radius: 0 4px 4px 0;
  padding: 0.4em 0.7em;
  margin-top: 0.5em;
  text-align: left;
}

/* ---------- Seção de geolocalização ---------- */
#geoSection {
  text-align: center;
}
#geoRequestBtn {
  background: none;
  border: 1px solid var(--color-btn);
  color: var(--color-btn);
  border-radius: 4px;
  padding: 0.4em 1em;
  cursor: pointer;
  font-family: "OpenSans", sans-serif;
  font-size: 0.85em;
  transition: background 0.2s, color 0.2s;
}
#geoRequestBtn:hover {
  background: var(--color-btn);
  color: #fff;
}
#geoRequestBtn:focus-visible { outline: 2px solid var(--color-btn); }

/* ---------- Seção multi-servidor ---------- */
.server-list {
  list-style: none;
  padding: 0; margin: 0;
}
.server-list li {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.4em 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9em;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 4px;
}
.server-list li:last-child { border-bottom: none; }
.server-list li:hover { background: var(--color-bg); }
.server-list li.selected { font-family: "OpenSansBold", sans-serif; }
.server-ping {
  margin-left: auto;
  font-size: 0.8em;
  color: var(--color-accent-dl);
  min-width: 55px;
  text-align: right;
}
.server-dist {
  font-size: 0.75em;
  color: var(--color-fg-muted);
}

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-btn);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

/* ---------- MTU Section ---------- */
#mtuValue {
  font-size: 1.5em;
  font-family: "OpenSansBold", sans-serif;
}
.pmtu-warning {
  color: var(--color-warn);
  font-size: 0.85em;
}

/* ---------- Utilitários ---------- */
.mgt1 { margin-top: 14px; }
.hidden { display: none !important; }
.text-muted { color: var(--color-fg-muted); font-size: 0.85em; }
h5 { margin-bottom: 3px; }
.section-collapsed .panel-body { display: none; }
.collapse-toggle {
  cursor: pointer;
  user-select: none;
  font-size: 0.85em;
  color: var(--color-link);
  margin-left: auto;
}

/* ---------- Footer ---------- */
footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  min-height: 178px;
  background: var(--color-footer);
  color: var(--color-footer-text);
  text-align: center;
  padding: 20px;
}
footer img { height: 34px; margin-bottom: 6px; }
footer small { color: rgba(255,255,255,0.6); }

/* ---------- Responsividade Mobile ---------- */
@media all and (max-width: 40em) {
  body { font-size: 0.8em; }
  .panel { margin: 0.75em 0.5em; padding: 0.75em 1em; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .history-chart-container { height: 160px; }
}

/* ---------- Responsividade Desktop ---------- */
@media (min-width: 992px) {
  .cabec { height: 100px; margin-bottom: 40px; }
  .tit { font-size: 1.75em; width: 85%; transition: font-size 0.3s; height: 100px; }
  .tit img { height: 48px; }
}
