/* mailuser-web — foglio di stile unico, nessuna risorsa esterna */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1b2430;
  --muted: #5d6b7a;
  --primary: #1f6feb;
  --primary-dark: #1758bd;
  --danger: #c62f34;
  --ok: #1c7c4a;
  --warn-bg: #fff5e5;
  --warn-border: #e7b46a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

h1, h2 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }

code { font-family: var(--mono); font-size: .88em; background: #eef1f5; padding: .1em .35em; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error-text { color: var(--danger); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--surface); padding: .5rem .75rem; border-radius: 8px;
}
.skip-link:focus { left: 8px; }

:focus-visible { outline: 3px solid #7db3ff; outline-offset: 2px; }

/* ------------------------------------------------------------- topbar */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }

.container { max-width: 1080px; margin: 0 auto; padding: 1.25rem; display: grid; gap: 1rem; }

/* -------------------------------------------------------------- tabs */

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.toolbar-actions { display: flex; gap: .5rem; }

.tabs { display: flex; gap: .25rem; background: #e9edf2; padding: .25rem; border-radius: 10px; }
.tab {
  border: 0; background: transparent; padding: .45rem .95rem; border-radius: 8px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.08); }

/* ------------------------------------------------------------ panel */

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}

.search input { min-width: 260px; }

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

.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { text-align: left; padding: .65rem .85rem; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
.table thead th {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: #fafbfc; font-weight: 700;
}
.table tbody tr:hover { background: #f7f9fc; }
.table .empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.col-actions { width: 1%; white-space: nowrap; }

.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }

.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  font-family: var(--mono); font-size: .78rem; background: #eef4ff;
  color: #1b4d9b; border: 1px solid #cfe0ff; border-radius: 999px;
  padding: .1rem .55rem;
}

/* ------------------------------------------------------------ badge */

.badge {
  display: inline-block; font-size: .74rem; font-weight: 700;
  letter-spacing: .03em; padding: .15rem .55rem; border-radius: 999px;
  text-transform: uppercase;
}
.badge-domain { background: #eef4ff; color: #1b4d9b; text-transform: none; letter-spacing: 0; }
.badge-ok { background: #e5f6ec; color: var(--ok); }
.badge-locked { background: #fdeaea; color: var(--danger); }

/* ----------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; font-size: .9rem;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; background: transparent; color: var(--text);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-small { padding: .3rem .6rem; font-size: .82rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-ghost { border-color: var(--border); background: var(--surface); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #f2f5f9; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a8262b; }

.btn-danger-ghost { border-color: #f0c9cb; color: var(--danger); background: #fff; }
.btn-danger-ghost:hover:not(:disabled) { background: #fdeaea; }

/* ------------------------------------------------------------ forms */

label { display: block; font-weight: 600; font-size: .88rem; margin: .75rem 0 .3rem; }

input[type="text"], input[type="password"], input[type="search"], select {
  width: 100%; font: inherit; padding: .55rem .7rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text);
}
input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(31,111,235,.18); }

.input-suffix { display: flex; align-items: center; }
.input-suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix .suffix {
  padding: .55rem .7rem; border: 1px solid var(--border); border-left: 0;
  border-radius: 0 8px 8px 0; background: #f4f6f9; color: var(--muted); font-size: .88rem;
  white-space: nowrap;
}

.password-row { display: flex; gap: .5rem; }
.password-row input { flex: 1; }

.check { display: flex; align-items: flex-start; gap: .5rem; font-weight: 500; margin-top: .9rem; }
.check input { margin-top: .25rem; }

.fieldset { border: 1px solid var(--border); border-radius: 10px; padding: .5rem .85rem .85rem; margin-top: 1rem; }
.fieldset legend { font-size: .85rem; font-weight: 700; padding: 0 .35rem; color: var(--muted); }

.hint { font-size: .8rem; color: var(--muted); margin: .4rem 0 0; }

/* ------------------------------------------------------------ card */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.params-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; margin: .85rem 0 0; }
.params-grid div { border-left: 3px solid #cfe0ff; padding-left: .7rem; }
.params-grid dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.params-grid dd { margin: .15rem 0 0; font-family: var(--mono); font-size: .85rem; }

/* ---------------------------------------------------------- dialog */

.dialog {
  border: 0; border-radius: 12px; padding: 0;
  width: min(520px, calc(100vw - 2rem));
  box-shadow: 0 24px 64px rgba(16,24,40,.28);
}
.dialog::backdrop { background: rgba(16,24,40,.45); }
.dialog-form { padding: 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.dialog-danger h2 { color: var(--danger); }

.alert { border-radius: 8px; padding: .65rem .8rem; font-size: .88rem; margin: .75rem 0 0; }
.alert-error { background: #fdeaea; color: #8f2327; border: 1px solid #f0c9cb; }
.alert-warning { background: var(--warn-bg); border: 1px solid var(--warn-border); color: #6b4a12; }

/* ---------------------------------------------------------- toast */

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 50; max-width: min(420px, calc(100vw - 2rem)); }
.toast {
  padding: .7rem .9rem; border-radius: 8px; font-size: .88rem; font-weight: 500;
  background: #14301f; color: #eaf7ee; box-shadow: var(--shadow);
  animation: slide-in .18s ease-out;
}
.toast-error { background: #4a1517; color: #fdeaea; }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity .3s ease, transform .3s ease; }

@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------- login page */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.75rem; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.3rem; }
.login-card .hint { margin-top: 1.25rem; }
.login-card .btn { margin-top: 1.25rem; }

/* --------------------------------------------------- responsive */

@media (max-width: 640px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { justify-content: space-between; }
  .search input { min-width: 0; width: 100%; }
  .table thead { display: none; }
  .table tbody tr { display: grid; gap: .15rem; padding: .75rem; border-bottom: 1px solid var(--border); }
  .table tbody td { border: 0; padding: .1rem 0; }
  .table tbody td.col-actions { padding-top: .5rem; }
  .row-actions { justify-content: flex-start; }
  .table tbody tr:has(td.empty) { display: table-row; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
