/* =====================================================================
   HDB Launcher - GUI PRINCIPAL (MAE)
   Tema padrao: matrix (cores de https://imaping.cloud/hackersdobrasil/)
   Tema opcional: claro (light)
   ===================================================================== */

:root,
.theme-matrix {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #010409;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --accent: #3fb950;
  --accent-2: #2f81f7;
  --border: #30363d;
  --card-bg: #161b22;
  --card-hover: #1c2330;
  --shadow: 0 10px 30px rgba(0, 0, 0, .55);
  --glow: 0 0 0 1px rgba(63, 185, 80, .35), 0 8px 26px rgba(63, 185, 80, .18);
}

.theme-light {
  --bg-primary: #ffffff;
  --bg-secondary: #f0f2f5;
  --bg-tertiary: #e4e6eb;
  --text-primary: #050505;
  --text-secondary: #65676b;
  --accent: #42b72a;
  --accent-2: #1877f2;
  --border: #ced0d4;
  --card-bg: #ffffff;
  --card-hover: #f7f9fb;
  --shadow: 0 10px 30px rgba(0, 0, 0, .12);
  --glow: 0 0 0 1px rgba(66, 183, 42, .45), 0 8px 26px rgba(66, 183, 42, .18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(63, 185, 80, .10), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(47, 129, 247, .08), transparent 55%),
    var(--bg-primary);
  color: var(--text-primary);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  transition: background-color .3s, color .3s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------ Cabecalho ------------------------------ */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 28px;
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand .logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 12px rgba(63, 185, 80, .35));
}

.brand-titles { min-width: 0; }

.brand-titles h1 {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: .14em;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-titles .sub {
  display: block;
  margin-top: 3px;
  font-size: .74rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.topbar .spacer { flex: 1 1 auto; }

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search input {
  width: 250px;
  max-width: 42vw;
  padding: 10px 14px 10px 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  font-size: .88rem;
  transition: border-color .2s, box-shadow .2s;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(63, 185, 80, .18);
}

.search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  pointer-events: none;
}

.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-color .2s, background .2s, transform .1s, box-shadow .2s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); background: var(--card-hover); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

.btn.accent {
  background: var(--accent);
  color: #04121b;
  border-color: var(--accent);
}
.btn.accent:hover { filter: brightness(1.08); box-shadow: var(--glow); }

.btn.ghost { background: transparent; }

/* ------------------------------ Conteudo ------------------------------ */
main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 34px 28px 70px;
}

.hero {
  margin-bottom: 26px;
}

.hero .kicker {
  font-size: .72rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.hero h2 {
  margin: 8px 0 6px;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: .95rem;
  max-width: 780px;
  line-height: 1.5;
}

.stats {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .76rem;
  color: var(--text-secondary);
}
.chip b { color: var(--text-primary); }
.chip .dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 7px; vertical-align: middle;
  background: var(--accent);
}

/* Grade de botoes */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 16px;
  padding: 22px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform .16s ease, border-color .2s, box-shadow .25s, background .2s;
  overflow: hidden;
  animation: fadeIn .45s ease-out both;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: .0;
  transition: opacity .25s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: var(--shadow);
  background: var(--card-hover);
}
.card:hover::before { opacity: 1; }

.card .top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.card .icon {
  width: 50px; height: 50px;
  flex: 0 0 auto;
  border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-secondary));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--accent);
}
.card .icon svg { width: 26px; height: 26px; }

.card h3 {
  margin: 2px 0 0;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.25;
}

.card .badge {
  display: inline-block;
  margin-top: 6px;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 999px;
  padding: 3px 9px;
}

.card .desc {
  color: var(--text-secondary);
  font-size: .86rem;
  line-height: 1.5;
  flex: 1 1 auto;
}

.card .foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .76rem;
  color: var(--text-secondary);
}
.status .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-secondary);
}
.status.on .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status.off .dot { background: #f85149; }
.status.on { color: var(--accent); }
.status.off { color: #f85149; }

.card .actions { display: flex; gap: 8px; }

.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 9px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  cursor: pointer;
  transition: all .2s;
}
.icon-btn:hover { color: #f85149; border-color: #f85149; }
.icon-btn svg { width: 15px; height: 15px; }

/* botao de lancar */
.launch {
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: .84rem;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all .2s;
}
.launch:hover { background: var(--accent); color: #04121b; box-shadow: var(--glow); }
.launch:disabled { opacity: .55; cursor: progress; }
.launch svg { width: 15px; height: 15px; }

/* spinner */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}

/* ------------------------------ Rodape ------------------------------ */
footer {
  border-top: 1px solid var(--border);
  padding: 16px 28px;
  font-size: .76rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
footer b { color: var(--accent); }

/* ------------------------------ Modal ------------------------------ */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(1, 4, 9, .72);
  backdrop-filter: blur(3px);
  display: none;
  place-items: center;
  z-index: 60;
  padding: 20px;
}
.modal-back.open { display: grid; }

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: fadeIn .28s ease-out both;
}

.modal h3 { margin: 0 0 4px; font-size: 1.15rem; }
.modal .hint { color: var(--text-secondary); font-size: .8rem; margin: 0 0 18px; }

.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 700;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: .88rem;
  outline: none;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(63, 185, 80, .16);
}
.field .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.modal .actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px;
}

/* ------------------------------ Toast ------------------------------ */
#toasts {
  position: fixed;
  bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 80;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .86rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  max-width: 360px;
  animation: fadeIn .25s ease-out both;
}
.toast.err { border-left-color: #f85149; }

.hidden { display: none !important; }

@media (max-width: 720px) {
  header.topbar { flex-wrap: wrap; padding: 14px 16px; }
  .search input { width: 46vw; }
  main { padding: 24px 16px 60px; }
  .hero h2 { font-size: 1.35rem; }
}
