/* G2 Forge — foglio di stile unico, scritto a mano (nessun bundler, nessun framework CSS).
   Palette e spaziature allineate allo stile Fluent 2 usato nell'ecosistema G2. */

:root {
  --bg: #f3f2f1;
  --surface: #ffffff;
  --surface-alt: #faf9f8;
  --border: #e1dfdd;
  --text: #201f1e;
  --text-soft: #605e5c;
  --brand: #0f6cbd;
  --brand-dark: #115ea3;
  --ok: #107c10;
  --warn: #ca5010;
  --err: #a4262c;
  --radius: 6px;
  --shadow: 0 1.6px 3.6px rgba(0, 0, 0, .13), 0 .3px .9px rgba(0, 0, 0, .11);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a19;
    --surface: #292827;
    --surface-alt: #201f1e;
    --border: #3b3a39;
    --text: #f3f2f1;
    --text-soft: #c8c6c4;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-loading { padding: 2rem; color: var(--text-soft); }

/* ── Layout ── */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: .5rem;
  padding: 1rem 1.25rem; font-weight: 600; font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
}
.brand i { color: var(--brand); }
.sidebar nav { flex: 1; padding: .5rem 0; }
.nav-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem 1.25rem; color: var(--text); text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--surface-alt); }
.nav-item.active { border-left-color: var(--brand); background: var(--surface-alt); font-weight: 600; }
.nav-item i { color: var(--text-soft); width: 1rem; }
.nav-item.active i { color: var(--brand); }

.sidebar-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.user-name { font-weight: 600; }
.user-roles { font-size: .8rem; color: var(--text-soft); margin-bottom: .5rem; }

.content { padding: 1.5rem 2rem; overflow-x: auto; }

/* ── Tipografia e blocchi ── */
h1 { font-size: 1.35rem; font-weight: 600; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.subtitle { color: var(--text-soft); margin: 0 0 1.25rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem; margin-bottom: 1rem;
}

.empty { padding: 2rem; color: var(--text-soft); text-align: center; }
.empty.error { color: var(--err); }

.toolbar { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ── Tabelle ── */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
tbody tr:hover { background: var(--surface-alt); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: .85em; }

/* ── Controlli ── */
.btn {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .375rem .875rem; border-radius: 4px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
  font: inherit; text-decoration: none;
}
.btn:hover { background: var(--surface-alt); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); padding-left: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-weight: 600; margin: .75rem 0 .25rem; font-size: .875rem; }
label .hint { font-weight: 400; color: var(--text-soft); }
input, select, textarea {
  width: 100%; padding: .375rem .5rem; font: inherit;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text);
}
input[type="checkbox"] { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 1rem; }
.field-row { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; }
.field-row label { margin: 0; }

/* ── Badge ── */
.badge {
  display: inline-block; padding: .0625rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface-alt); color: var(--text-soft);
}
.badge-ok { background: #dff6dd; border-color: #a7e3a5; color: #0b5c0b; }
.badge-warn { background: #fff4ce; border-color: #ffd88c; color: #6b4a00; }
.badge-err { background: #fde7e9; border-color: #f1a3a8; color: #7a1a1f; }
.badge-info { background: #e5f1fb; border-color: #a9cdf0; color: #0b4a78; }
.badge-tag { background: #efe4ff; border-color: #cbb2f0; color: #4b2a86; }

/* ── Console dei job ── */
.console {
  background: #0c0c0c; color: #e6e6e6; border-radius: var(--radius);
  padding: .75rem 1rem; font-family: "Cascadia Mono", Consolas, monospace;
  font-size: .8rem; line-height: 1.45; max-height: 26rem; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}
.console .l-err { color: #f88; }
.console .l-sys { color: #7fd1ff; }

.steps { display: flex; flex-direction: column; gap: .25rem; margin-bottom: 1rem; }
.step { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.step .dot { width: .625rem; height: .625rem; border-radius: 50%; background: var(--border); flex: none; }
.step.running .dot { background: var(--brand); animation: pulse 1.2s ease-in-out infinite; }
.step.ok .dot { background: var(--ok); }
.step.failed .dot { background: var(--err); }
.step.skipped .dot { background: var(--warn); }
.step .elapsed { color: var(--text-soft); margin-left: auto; font-variant-numeric: tabular-nums; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ── Login ── */
.login-card {
  max-width: 26rem; margin: 15vh auto; padding: 2rem; text-align: center;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ── Toast ── */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; }
.toast {
  padding: .625rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow);
  background: var(--surface); border-left: 3px solid var(--brand); max-width: 26rem;
}
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--err); }
.toast-ok { border-left-color: var(--ok); }

/* ── Dialog ── */
dialog {
  border: none; border-radius: var(--radius); padding: 1.5rem;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  max-width: 40rem; width: calc(100vw - 2rem);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { display: flex; }
  .content { padding: 1rem; }
}
