/* Espritec License Server — stesso sistema visivo di Espritec.CloudApi/wwwroot/css/app.css
   (stessi token colore/ombra/raggio), riadattato per un'app Razor Pages server-rendered
   invece che una SPA: niente sidebar apribile via JS, solo un layout che passa da sidebar
   fissa a barra orizzontale sotto i 900px — qui i link di navigazione sono solo tre, una
   sidebar comprimibile sarebbe complessità senza reale beneficio. */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0ea5e9;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.01em; }

/* ============ LOGIN ============ */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, .18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(14, 165, 233, .20), transparent 55%),
    linear-gradient(160deg, #0b1220 0%, #131f36 55%, #0b1220 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 34px 30px 28px;
  animation: rise .45s cubic-bezier(.2, .7, .3, 1) both;
}

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

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  text-align: center;
}
.auth-brand .mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  color: #fff;
}
.auth-brand .mark svg { width: 26px; height: 26px; }
.auth-brand h1 { margin: 0; font-size: 1.5rem; }
.auth-brand p { margin: 0; color: var(--text-muted); font-size: .9rem; }

/* ============ CAMPI / PULSANTI (condivisi login + form interni) ============ */

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  max-width: 26rem;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.field-check { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.field-check input { width: auto; }
.field-check label { margin: 0; font-weight: 500; color: var(--text); }
.field-hint { font-size: .8rem; color: var(--text-soft); margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  transition: background .15s, transform .08s, box-shadow .15s;
}
.btn:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--ok-bg); color: #065f46; border-color: #a7f3d0; }

.secret-reveal { padding: 16px 18px; margin-bottom: 18px; }
.secret-reveal p { margin: 0 0 8px; }
.secret-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86rem;
  padding: 10px 13px;
  background: var(--surface);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* ============ LAYOUT APP ============ */

.app { min-height: 100dvh; display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  margin-bottom: 14px;
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  color: #fff;
}
.sidebar-brand .mark svg { width: 18px; height: 18px; }
.sidebar-brand strong { color: #fff; font-size: 1rem; display: block; }
.sidebar-brand span { display: block; font-size: .72rem; color: #94a3b8; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  font-size: .93rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(148, 163, 184, .12); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar-user {
  border-top: 1px solid rgba(148, 163, 184, .18);
  padding-top: 14px;
  font-size: .82rem;
}
.sidebar-user .who { color: #fff; font-weight: 600; word-break: break-all; margin-bottom: 10px; }
.sidebar-user form { margin: 0; }
.sidebar-user > a.btn-ghost { display: block; margin-bottom: 8px; text-align: center; }
.sidebar-user .btn-ghost { width: 100%; background: transparent; border-color: rgba(148, 163, 184, .3); color: #cbd5e1; }
.sidebar-user .btn-ghost:hover { background: rgba(148, 163, 184, .12); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px 28px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.3rem; }
.topbar p { margin: 4px 0 0; color: var(--text-muted); font-size: .88rem; }

.content { padding: 24px 28px 44px; flex: 1; }

/* ============ CARD / KPI / TABELLE ============ */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
}
.kpi .label {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-soft); font-weight: 700;
}
.kpi .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-pad { padding: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-soft); font-weight: 700; padding: 11px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; }
.muted { color: var(--text-muted); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .77rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* ============ RESPONSIVE ============ */

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: auto;
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    gap: 14px;
    overflow-x: auto;
  }
  .sidebar-brand { border-bottom: none; margin-bottom: 0; padding: 0; flex: none; }
  .sidebar-brand span { display: none; }
  .nav { flex-direction: row; flex: none; }
  .sidebar-user { border-top: none; padding-top: 0; margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
  .sidebar-user .who { margin-bottom: 0; font-size: .78rem; }
  .sidebar-user .btn-ghost { width: auto; padding: 6px 12px; font-size: .82rem; }
  .topbar { padding: 14px 18px; }
  .content { padding: 18px 16px 34px; }
}

@media (max-width: 640px) {
  .card-head { flex-direction: column; align-items: stretch; }

  /* Tabelle -> schede, come nella webapp portale: sotto questa larghezza lo scroll
     orizzontale rende una griglia poco usabile su telefono. */
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  .table-wrap { overflow-x: visible; }
  tbody tr {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin: 12px; padding: 4px 0; background: var(--surface);
  }
  td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 14px; padding: 9px 13px; border-bottom: none; text-align: right;
  }
  td::before {
    content: attr(data-label); font-size: .72rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-soft); font-weight: 700; text-align: left; flex: none;
  }
  td:empty { display: none; }
  .row-actions { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
