/* ============================================================
   /css/global.css
   Reset, variáveis CSS, grid principal, sidebar, topbar,
   modais globais, toast, animações de fundo e utilitários.
   ============================================================ */

/* ── RESET & BASE ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #080d1c;
  color: #e8ecf8;
  overflow: hidden;
}

/* ── VARIÁVEIS GLOBAIS ── */
:root {
  --verde:       #34d863;
  --amarelo:     #ffcc00;
  --vermelho:    #ff453a;
  --roxo:        #5b6af5;
  --roxo-dim:    rgba(91, 106, 245, .15);
  --superficie:  rgba(14, 19, 42, .58);
  --borda:       rgba(255, 255, 255, .07);
  --texto-dim:   rgba(160, 175, 220, .6);
}

/* ── FUNDO GRADIENTE ── */
body {
  background:
    radial-gradient(ellipse 55% 45% at 78% 18%, rgba(90,60,220,.28) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 18% 72%, rgba(30,60,200,.20) 0%, transparent 55%),
    radial-gradient(ellipse 60% 35% at 55% 88%, rgba(50,80,255,.14) 0%, transparent 55%),
    linear-gradient(160deg, #080c1e 0%, #0b1025 40%, #0d1230 70%, #080c1a 100%);
}

/* ── CANVAS DE PARTÍCULAS ── */
canvas#estrelas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ── LAYOUT PRINCIPAL ── */
.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  padding: 12px;
  gap: 10px;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 188px;
  min-width: 188px;
  background: rgba(10, 14, 30, .82);
  border: 1px solid var(--borda);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  padding: 16px 12px 14px;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    0 24px 60px rgba(0,0,0,.45);
  overflow: hidden;
}

/* Marca */
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 4px 18px;
}
.brand-ic {
  width: 32px;
  height: 32px;
  background: #11183a;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #c8d4ff;
  flex-shrink: 0;
}
.brand-name {
  font-size: 16px;
  font-weight: 600;
  color: #dce6ff;
  letter-spacing: -.2px;
}

/* Perfil do usuário */
.user-profile {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 14px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  cursor: default;
  transition: background .18s;
}
.user-profile:hover { background: rgba(255,255,255,.09); }
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.15);
  object-fit: cover;
  flex-shrink: 0;
  background: #11183a;
}
.user-nickname {
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(220,232,255,.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Itens de navegação */
.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 450;
  color: rgba(180,192,230,.65);
  cursor: pointer;
  transition:
    background .18s,
    color .18s,
    transform .15s cubic-bezier(.34,1.56,.64,1);
  border: 1px solid transparent;
  user-select: none;
}
.nav-item:hover {
  background: rgba(255,255,255,.05);
  color: rgba(220,230,255,.9);
  transform: translateX(1px);
}
.nav-item.ativo {
  background: #fff;
  color: #0a0e20;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(255,255,255,.12);
}
.nav-item.ativo svg { opacity: .75; }
.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .6;
}

/* Rodapé da sidebar */
.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--borda);
  margin-top: 12px;
}
.btn-visit-page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.03);
  color: rgba(160,175,220,.6);
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition:
    background .18s,
    color .18s,
    border-color .18s,
    transform .15s;
}
.btn-visit-page:hover {
  background: rgba(255,255,255,.07);
  color: rgba(220,232,255,.88);
  border-color: rgba(255,255,255,.16);
  transform: translateX(1px);
}
.btn-visit-page svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── ÁREA PRINCIPAL ── */
.main {
  flex: 1;
  background: rgba(10,14,32,.62);
  border: 1px solid var(--borda);
  border-radius: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.04),
    0 24px 60px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px 0;
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #e8eeff;
  letter-spacing: -.4px;
}
.btn-menu-mobile {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: rgba(220,232,255,.86);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-menu-mobile svg {
  width: 18px;
  height: 18px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* Relógios do topbar */
.hdr-clocks {
  display: flex;
  align-items: center;
  gap: 16px;
}
.hdr-clock-item { text-align: right; }
.hdr-clock-label {
  font-size: 10px;
  color: var(--texto-dim);
  letter-spacing: .03em;
}
.hdr-clock-val {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: #dde6ff;
}
.hdr-sep {
  width: 1px;
  height: 24px;
  background: var(--borda);
}

/* Botões do topbar */
.btn-refresh {
  background: var(--roxo-dim);
  border: 1px solid rgba(91,106,245,.35);
  color: #8b97f8;
  padding: 7px 14px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s, transform .18s;
  white-space: nowrap;
}
.btn-refresh:hover { background: rgba(91,106,245,.25); transform: scale(1.03); }
.btn-refresh:active { transform: scale(.98); }

.btn-add {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--roxo);
  border: none;
  color: #fff;
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background .18s,
    transform .2s cubic-bezier(.34,1.56,.64,1),
    box-shadow .18s;
  box-shadow: 0 4px 14px rgba(91,106,245,.35);
}
.btn-add:hover {
  background: #7080ff;
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 6px 20px rgba(91,106,245,.5);
}
.btn-add:active { transform: scale(.97); }

.btn-logout {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(180,195,240,.55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background .18s,
    color .18s,
    border-color .18s,
    transform .2s cubic-bezier(.34,1.56,.64,1);
  flex-shrink: 0;
}
.btn-logout:hover {
  background: rgba(255,69,58,.15);
  border-color: rgba(255,69,58,.35);
  color: var(--vermelho);
  transform: scale(1.08);
}
.btn-logout:active { transform: scale(.97); }
.btn-logout svg { width: 15px; height: 15px; }

/* ── CONTAINER DE CONTEÚDO ── */
/* Ocupa o restante da .main e serve de âncora para scroll das telas */
.conteudo {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* cada tela controla seu próprio scroll interno */
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, .6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 20;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(20,28,58,.96);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  color: #dde6ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 9999;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── MODAIS GLOBAIS ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4,8,20,.72);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
}
.modal-overlay.aberto { display: flex; }

.modal {
  background: rgba(12,17,38,.95);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 18px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 32px 80px rgba(0,0,0,.6);
  overflow: hidden;
  animation: modal-entrar .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modal-entrar {
  from { transform: scale(.92) translateY(12px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--borda);
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #e8eeff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-header p {
  font-size: 12.5px;
  color: var(--texto-dim);
  margin-top: 5px;
}

.modal-body  { padding: 18px 24px; }
.modal-footer {
  padding: 14px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-field { margin-bottom: 14px; }
.modal-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(180,195,240,.7);
  margin-bottom: 7px;
}
.modal-field input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  color: #e8eeff;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  outline: none;
  transition: border-color .18s, background .18s;
}
.modal-field input:focus {
  border-color: rgba(91,106,245,.5);
  background: rgba(91,106,245,.06);
}
.modal-field input::placeholder { color: rgba(130,145,190,.4); }

.modal-hint {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11.5px;
  color: rgba(130,145,190,.5);
  padding: 8px 12px;
  background: rgba(255,255,255,.03);
  border-radius: 8px;
  line-height: 1.5;
}

/* Seletor de tipo de monitor */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}
.type-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  font-size: 11px;
  font-weight: 500;
  color: rgba(180,195,240,.6);
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
}
.type-opt:hover {
  background: rgba(255,255,255,.06);
  color: rgba(220,230,255,.85);
}
.type-opt.selected {
  border-color: rgba(91,106,245,.5);
  background: rgba(91,106,245,.1);
  color: #8b97f8;
}

/* Botões dos modais */
.btn-cancel {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: rgba(180,195,240,.7);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s, color .18s;
}
.btn-cancel:hover {
  background: rgba(255,255,255,.08);
  color: #dde6ff;
}
.btn-submit {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 9px;
  border: none;
  background: var(--roxo);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .18s, box-shadow .18s;
  box-shadow: 0 4px 14px rgba(91,106,245,.3);
}
.btn-submit:hover {
  background: #7080ff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(91,106,245,.45);
}
.btn-submit:active { transform: scale(.97); }

.btn-del-confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 9px;
  border: none;
  background: rgba(255,69,58,.18);
  color: var(--vermelho);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s, transform .18s;
  border: 1px solid rgba(255,69,58,.3);
}
.btn-del-confirm:hover {
  background: rgba(255,69,58,.28);
  transform: translateY(-1px);
}
.btn-del-confirm:active { transform: scale(.97); }

/* ── UTILITÁRIOS COMPARTILHADOS ── */

/* Cabeçalho de seção */
.sec-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: rgba(160,175,220,.55);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sec-head::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--borda);
}
.sec-head small {
  font-size: 10px;
  font-weight: 400;
  color: rgba(130,145,190,.45);
  letter-spacing: 0;
  text-transform: none;
}

/* Card de estatística */
.stat-card {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 14px 16px;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), background .2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  background: rgba(20,28,58,.7);
}
.stat-card-label {
  font-size: 11px;
  color: var(--texto-dim);
  margin-bottom: 6px;
}
.stat-card-val {
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: #e8eeff;
  letter-spacing: -.5px;
}
.stat-card-sub {
  font-size: 10.5px;
  color: var(--texto-dim);
  margin-top: 4px;
}
.stat-card-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  margin-top: 5px;
}

/* Badges */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.badge-up    { background: rgba(52,216,99,.12);  color: var(--verde);    border: 1px solid rgba(52,216,99,.2);  }
.badge-warn  { background: rgba(255,204,0,.12);  color: var(--amarelo);  border: 1px solid rgba(255,204,0,.2);  }
.badge-down  { background: rgba(255,69,58,.12);  color: var(--vermelho); border: 1px solid rgba(255,69,58,.2);  }

/* Estado vazio */
.empty-state {
  text-align: center;
  padding: 32px 0;
  color: var(--texto-dim);
  font-size: 13.5px;
}
.empty-state svg {
  opacity: .25;
  margin-bottom: 10px;
}

/* ── ANIMAÇÕES DE FUNDO ── */
@keyframes piscar-ponto {
  0%,100% { opacity: 1; transform: scale(1);   }
  50%      { opacity: .6; transform: scale(.85); }
}

/* ── RESPONSIVIDADE ── */
@media (max-width: 700px) {
  html, body {
    overflow: hidden;
  }

  .app {
    padding: 8px;
  }

  .sidebar {
    display: flex;
    position: fixed;
    left: 8px;
    top: 8px;
    bottom: 8px;
    z-index: 30;
    width: min(280px, calc(100vw - 32px));
    min-width: 0;
    transform: translateX(calc(-100% - 16px));
    transition: transform .22s ease;
  }

  body.menu-mobile-aberto .sidebar {
    transform: translateX(0);
  }

  body.menu-mobile-aberto .mobile-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .main {
    min-width: 0;
    width: 100%;
  }

  .topbar {
    padding: 14px 16px 0;
    align-items: flex-start;
    gap: 10px;
  }

  .topbar-left {
    flex: 1;
    min-width: 0;
  }

  .page-title {
    font-size: 20px;
    line-height: 1.1;
  }

  .btn-menu-mobile {
    display: inline-flex;
  }

  .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 58%;
  }

  .hdr-clocks {
    display: none;
  }

  .btn-refresh {
    padding: 7px 10px;
    font-size: 12px;
  }

  .toast {
    max-width: calc(100vw - 24px);
    white-space: normal;
    text-align: center;
  }
}
