/* ── NSL Syncronize Portal ── */

:root {
  --bg:        #0e1117;
  --bg-card:   #161b22;
  --bg-hover:  #1c2330;
  --border:    #2a3140;
  --text:      #e2e8f0;
  --text-dim:  #8b95a8;
  --accent:    #2d8cf0;
  --accent-h:  #4da3ff;
  --green:     #34d399;
  --green-dim: rgba(52,211,153,.12);
  --red:       #f87171;
  --red-dim:   rgba(248,113,113,.12);
  --yellow:    #fbbf24;
  --yellow-dim:rgba(251,191,36,.12);
  --radius:    10px;
  --radius-sm: 6px;
  --font:      'DM Sans', system-ui, -apple-system, sans-serif;
  --mono:      'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.screen { display: none; }
.screen.active { display: flex; }

/* ── Login ── */
#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(45,140,240,.10) 0%, transparent 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 2.4rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}
.brand-icon { margin-bottom: .6rem; display: inline-block; }
.login-brand h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.login-sub {
  color: var(--text-dim);
  font-size: .85rem;
  margin-top: .2rem;
}

#login-form label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: .35rem;
}
#login-form input {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: .85rem;
  outline: none;
  transition: border-color .15s;
}
#login-form input:focus { border-color: var(--accent); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  width: 100%;
  padding: .65rem 1.2rem;
  margin-top: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.error-msg {
  color: var(--red);
  font-size: .82rem;
  margin-top: .7rem;
  text-align: center;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: .55rem;
}
.topbar-icon { flex-shrink: 0; }
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
}
.topbar-tag {
  font-size: .7rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(45,140,240,.12);
  padding: .12rem .45rem;
  border-radius: 4px;
  margin-left: .25rem;
  vertical-align: middle;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  padding: .35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color .15s, border-color .15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--text-dim); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: .85rem;
  cursor: pointer;
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

/* ── Dashboard ── */
#dashboard-screen {
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.6rem 1.2rem 3rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .2rem;
}
.btn-back {
  font-size: .82rem;
}

/* ── Machine cards ── */
.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .75rem;
}

.machine-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.machine-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.machine-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.machine-hostname {
  font-weight: 600;
  font-size: .95rem;
}
.machine-id {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--text-dim);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 600;
  padding: .18rem .55rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-online  { background: var(--green-dim); color: var(--green); }
.badge-offline { background: var(--red-dim);   color: var(--red);   }
.badge-running { background: var(--yellow-dim);color: var(--yellow);}
.badge-idle    { background: rgba(139,149,168,.1); color: var(--text-dim); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.machine-meta {
  font-size: .78rem;
  color: var(--text-dim);
}

/* ── Profile cards ── */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .75rem;
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.profile-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.profile-name {
  font-weight: 600;
  font-size: .92rem;
  margin-bottom: .25rem;
}
.profile-detail {
  font-size: .78rem;
  color: var(--text-dim);
  line-height: 1.45;
}

/* ── Backups table ── */
.backups-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.btn-run {
  width: auto;
  padding: .5rem 1.1rem;
  font-size: .85rem;
}

.run-status {
  font-size: .82rem;
  color: var(--text-dim);
}
.run-status.ok   { color: var(--green); }
.run-status.fail { color: var(--red); }

.backups-table-wrap { overflow-x: auto; }

table.backups {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
table.backups th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.backups td {
  padding: .55rem .7rem;
  border-bottom: 1px solid rgba(42,49,64,.4);
  white-space: nowrap;
}
table.backups tr:last-child td { border-bottom: none; }
table.backups tbody tr:hover { background: var(--bg-hover); }

td.kind-full         { color: var(--accent); }
td.kind-incremental  { color: var(--green);  }
td.kind-diferencial  { color: var(--yellow); }
td.size-cell         { font-family: var(--mono); font-size: .78rem; }
td.date-cell         { font-family: var(--mono); font-size: .78rem; color: var(--text-dim); }

.empty-msg {
  color: var(--text-dim);
  font-size: .85rem;
  padding: 1rem 0;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem 1.2rem;
  font-size: .84rem;
  color: var(--text);
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity:0; transform:translateX(-50%) translateY(8px); } }

/* ── Responsive ── */
@media (max-width: 520px) {
  .main-content { padding: 1rem .7rem 2rem; }
  .machines-grid, .profiles-grid { grid-template-columns: 1fr; }
  .topbar { padding: .6rem .8rem; }
}
