/* StackSign — stile del frontend single-page */

:root {
	--accent: #4f6df5;
	--accent-2: #7b5cf0;
	--accent-soft: #eef1fe;
	--bg: #f4f6fb;
	--surface: #ffffff;
	--text: #1c2333;
	--text-muted: #6b7386;
	--border: #e3e7f0;
	--ok: #1e9e5a;
	--ok-soft: #e5f6ec;
	--ko: #d9364c;
	--ko-soft: #fdecef;
	--warn: #d98c00;
	--warn-soft: #fdf3e0;
	--neutral: #6b7386;
	--neutral-soft: #eef0f5;
	--shadow: 0 1px 2px rgba(28, 35, 51, .05), 0 8px 24px rgba(28, 35, 51, .07);
	--radius: 14px;
}

@media (prefers-color-scheme: dark) {
	:root {
		--accent: #7d93ff;
		--accent-2: #a08cff;
		--accent-soft: #262b45;
		--bg: #12141c;
		--surface: #1c2030;
		--text: #e8eaf2;
		--text-muted: #9aa1b5;
		--border: #2d3348;
		--ok: #3fbf7f;
		--ok-soft: #17362a;
		--ko: #f0637a;
		--ko-soft: #3d222a;
		--warn: #e8a33d;
		--warn-soft: #3a3022;
		--neutral: #9aa1b5;
		--neutral-soft: #262b3b;
		--shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
	}
}

* { box-sizing: border-box; }

/* l'attributo hidden deve vincere sui display:flex assegnati dalle classi */
[hidden] { display: none !important; }

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

.page {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	max-width: 960px;
	margin: 0 auto;
	padding: 0 20px;
}

/* ---------- Header ---------- */

.app-header {
	padding: 40px 0 28px;
	text-align: center;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 12px;
}

.brand-icon {
	height: 48px;
	width: auto;
	border-radius: 10px;
}

.brand-name {
	margin: 0;
	font-size: 2.4rem;
	font-weight: 700;
	letter-spacing: -.02em;
	background: linear-gradient(120deg, var(--accent), var(--accent-2));
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.tagline {
	margin: 6px 0 0;
	color: var(--text-muted);
	font-size: .95rem;
}

/* ---------- Card ---------- */

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

/* ---------- Upload ---------- */

.upload-card { padding: 18px; }

.dropzone {
	border: 2px dashed var(--border);
	border-radius: calc(var(--radius) - 4px);
	padding: 44px 24px;
	text-align: center;
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease;
	color: var(--text);
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragover {
	border-color: var(--accent);
	background: var(--accent-soft);
	outline: none;
}

.dropzone-icon {
	width: 48px;
	height: 48px;
	color: var(--accent);
}

.dropzone-title {
	margin: 12px 0 4px;
	font-size: 1.1rem;
	font-weight: 600;
}

.dropzone-hint {
	margin: 0;
	color: var(--text-muted);
	font-size: .9rem;
}

.link-like {
	color: var(--accent);
	text-decoration: underline;
}

.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 44px 24px;
	color: var(--text-muted);
}

.spinner {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 3px solid var(--accent-soft);
	border-top-color: var(--accent);
	animation: spin .8s linear infinite;
	flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.upload-error {
	margin-top: 14px;
	padding: 12px 16px;
	border-radius: 10px;
	background: var(--ko-soft);
	color: var(--ko);
	font-size: .92rem;
}

/* ---------- Verdetto ---------- */

.result {
	display: flex;
	flex-direction: column;
	gap: 18px;
	margin-top: 18px;
}

.verdict {
	display: flex;
	align-items: center;
	gap: 18px;
	padding: 22px 24px;
	flex-wrap: wrap;
}

.verdict-badge {
	width: 58px;
	height: 58px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.7rem;
	font-weight: 700;
	flex-shrink: 0;
}

.verdict-badge.ok   { background: var(--ok-soft);      color: var(--ok); }
.verdict-badge.ko   { background: var(--ko-soft);      color: var(--ko); }
.verdict-badge.warn { background: var(--warn-soft);    color: var(--warn); }
.verdict-badge.muted{ background: var(--neutral-soft); color: var(--neutral); }

.verdict-text { flex: 1; min-width: 220px; }

.verdict-text h2 {
	margin: 0;
	font-size: 1.35rem;
}

.verdict-text h2.ok   { color: var(--ok); }
.verdict-text h2.ko   { color: var(--ko); }
.verdict-text h2.warn { color: var(--warn); }
.verdict-text h2.muted{ color: var(--neutral); }

.verdict-file {
	margin: 2px 0 10px;
	color: var(--text-muted);
	font-size: .92rem;
	word-break: break-all;
}

.verdict-chips {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.chip {
	background: var(--neutral-soft);
	color: var(--text-muted);
	border-radius: 999px;
	padding: 3px 12px;
	font-size: .8rem;
	font-weight: 600;
}

.verdict-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: stretch;
}

/* ---------- Bottoni ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	border: none;
	border-radius: 10px;
	padding: 10px 18px;
	font-size: .92rem;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: filter .15s ease, background-color .15s ease;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
	background: linear-gradient(120deg, var(--accent), var(--accent-2));
	color: #fff;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
	background: transparent;
	color: var(--text-muted);
	border: 1px solid var(--border);
}

.btn-ghost:hover {
	color: var(--text);
	border-color: var(--text-muted);
}

/* ---------- Tabs ---------- */

.report-panel { overflow: hidden; }

.tab-bar {
	display: flex;
	gap: 4px;
	padding: 10px 14px 0;
	border-bottom: 1px solid var(--border);
	overflow-x: auto;
}

.tab {
	border: none;
	background: transparent;
	font-family: inherit;
	font-size: .92rem;
	font-weight: 600;
	color: var(--text-muted);
	padding: 10px 16px;
	cursor: pointer;
	border-radius: 8px 8px 0 0;
	border-bottom: 3px solid transparent;
	white-space: nowrap;
}

.tab:hover { color: var(--text); }

.tab[aria-selected="true"] {
	color: var(--accent);
	border-bottom-color: var(--accent);
}

.tab-panels { padding: 20px 24px 24px; }

.tab-panel[hidden] { display: none; }

/* ---------- Riepilogo (tabella) ---------- */

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

.summary-table {
	width: 100%;
	border-collapse: collapse;
	font-size: .9rem;
}

.summary-table th {
	text-align: left;
	color: var(--text-muted);
	font-weight: 600;
	font-size: .78rem;
	text-transform: uppercase;
	letter-spacing: .05em;
	padding: 8px 12px;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

.summary-table td {
	padding: 10px 12px;
	border-bottom: 1px solid var(--border);
	vertical-align: top;
}

.summary-table tr:last-child td { border-bottom: none; }

/* ---------- Badge esito ---------- */

.status-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border-radius: 999px;
	padding: 3px 12px;
	font-size: .8rem;
	font-weight: 600;
	white-space: nowrap;
}

.status-badge.ok   { background: var(--ok-soft);      color: var(--ok); }
.status-badge.ko   { background: var(--ko-soft);      color: var(--ko); }
.status-badge.warn { background: var(--warn-soft);    color: var(--warn); }
.status-badge.muted{ background: var(--neutral-soft); color: var(--neutral); }

/* ---------- Dettaglio firma ---------- */

.level-intro {
	margin: 0 0 16px;
	color: var(--text-muted);
	font-size: .9rem;
}

.signature-card {
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 18px 20px;
	margin-bottom: 16px;
}

.signature-card:last-child { margin-bottom: 0; }

.signature-card-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
	flex-wrap: wrap;
}

.signature-card-header h3 {
	margin: 0;
	font-size: 1.02rem;
}

.detail-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 10px 24px;
	margin: 0;
}

.detail-grid > div { min-width: 0; }

.detail-grid > div.detail-wide { grid-column: 1 / -1; }

.detail-grid dt {
	font-size: .75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: var(--text-muted);
	margin: 0 0 1px;
}

.detail-grid dd {
	margin: 0;
	font-size: .92rem;
	word-break: break-word;
}

.detail-grid dd.mono {
	font-family: Consolas, "Cascadia Mono", monospace;
	font-size: .84rem;
}

.empty-state {
	text-align: center;
	color: var(--text-muted);
	padding: 24px 0;
}

/* ---------- Marche temporali e messaggi di validazione ---------- */

.panel-subheading {
	margin: 22px 0 10px;
	font-size: .95rem;
}

.timestamp-card {
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 18px 20px;
	margin-bottom: 16px;
}

.timestamp-card:last-child { margin-bottom: 0; }

/* Marca temporale che accompagna una firma: sotto-scheda dentro la signature-card */
.timestamp-card.nested {
	margin: 14px 0 0;
	padding: 14px 16px;
	background: var(--neutral-soft);
	border-style: dashed;
}

.timestamp-card .signature-card-header h4 {
	margin: 0;
	font-size: .92rem;
}

.validation-messages {
	list-style: none;
	margin: 14px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.validation-messages li {
	font-size: .85rem;
	padding: 7px 10px;
	border-radius: 8px;
	border-left: 3px solid;
}

.validation-messages .msg-error {
	background: var(--ko-soft);
	border-color: var(--ko);
	color: var(--ko);
}

.validation-messages .msg-warn {
	background: var(--warn-soft);
	border-color: var(--warn);
	color: var(--warn);
}

/* ---------- Footer ---------- */

.app-footer {
	margin-top: auto;
	padding: 36px 0 20px;
	text-align: center;
	color: var(--text-muted);
	font-size: .8rem;
	opacity: .75;
}

.footer-donate {
	margin-top: 10px;
}

.footer-links {
	display: flex;
	gap: 14px;
	justify-content: center;
	margin-top: 6px;
}

.footer-links a {
	color: inherit;
	text-decoration: none;
}

.footer-links a:hover {
	text-decoration: underline;
}

/* ---------- Pagine legali (privacy, disclaimer) ---------- */

.legal-content {
	padding: 32px clamp(20px, 5vw, 48px);
	margin-bottom: 24px;
}

.legal-content h1 {
	margin: 0 0 4px;
	font-size: 1.5rem;
}

.legal-content h2 {
	margin: 26px 0 8px;
	font-size: 1.05rem;
}

.legal-content h2:first-of-type {
	margin-top: 22px;
}

.legal-content p {
	margin: 0 0 14px;
}

.legal-content .legal-meta {
	color: var(--text-muted);
	font-size: .85rem;
	margin-bottom: 22px;
}

.legal-content h3 {
	margin: 18px 0 6px;
	font-size: .95rem;
}

.legal-content ul,
.legal-content ol {
	margin: 0 0 14px;
	padding-left: 22px;
}

.legal-content li {
	margin-bottom: 6px;
}

.legal-content code {
	font-family: Consolas, "Cascadia Mono", monospace;
	font-size: .85em;
	background: var(--neutral-soft);
	padding: 1px 5px;
	border-radius: 4px;
}

.legal-content table {
	width: 100%;
	border-collapse: collapse;
	margin: 0 0 18px;
	font-size: .85rem;
}

.legal-content th,
.legal-content td {
	border: 1px solid var(--border);
	padding: 8px 10px;
	text-align: left;
	vertical-align: top;
}

.legal-content th {
	background: var(--neutral-soft);
}

.legal-content .toc-list {
	margin: 0 0 14px;
	padding-left: 22px;
	columns: 2;
	column-gap: 24px;
}

.legal-content .toc-list li {
	break-inside: avoid;
	font-size: .92rem;
}

.guide-index {
	display: grid;
	gap: 16px;
}

.guide-index-item h2 {
	margin: 0 0 6px;
	font-size: 1.1rem;
}

.guide-index-item p {
	margin: 0;
	color: var(--text-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
	.verdict { flex-direction: column; align-items: flex-start; }
	.verdict-actions { width: 100%; }
	.app-header { padding-top: 28px; }
	.brand-name { font-size: 2rem; }
}
