/* ============================================================
   DARK MODE — Tech / Enterprise
   Font: IBM Plex Mono (headings) + IBM Plex Sans (body)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600;700&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg:          #0a0e1a;
  --bg-card:     #111827;
  --bg-input:    #0d1321;
  --border:      #1e2d45;
  --border-glow: #1a4a7a;
  --accent:      #00b4ff;
  --accent-dim:  #0077aa;
  --accent-glow: rgba(0, 180, 255, 0.15);
  --green:       #00e5a0;
  --red:         #ff4f6e;
  --text:        #d6e4f7;
  --text-muted:  #5a7899;
  --text-dim:    #3a5570;
  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 2px 20px rgba(0,0,0,0.5);
  --transition:  0.2s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,180,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,180,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

/* ---- Typography ---- */
h1, h2, h3 {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}
h1 { font-size: 1.9rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.35rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.05rem; margin-bottom: 0.6rem; }

p { color: var(--text); margin-bottom: 0.75rem; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: #fff; }

/* ---- Layout ---- */
.narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ---- Topbar ---- */
.topbar {
  background: rgba(10,14,26,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 54px;
  max-width: 1800px;
  margin: 0 auto;
}

.topbar nav a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.topbar nav a:hover { color: var(--accent); }

/* ---- Cards ---- */
article {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
article:hover {
  border-color: var(--border-glow);
  box-shadow: 0 0 20px rgba(0,180,255,0.06);
}

article header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

article header strong {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--accent);
  font-size: 0.9rem;
}

/* ---- Inputs ---- */
input, select, textarea {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.9rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none; }
input[type="checkbox"] { -webkit-appearance: checkbox; appearance: checkbox; width: auto; padding: 0; border: none; background: transparent;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder { color: var(--text-dim); }

/* Custom select arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a7899'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2rem;
}
select option { background: var(--bg-card); color: var(--text); }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.3rem;
}

/* ---- Buttons ---- */
button, a[role="button"] {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
}

/* Primary */
button[type="submit"],
a[role="button"]:not(.secondary):not(.contrast) {
  background: var(--accent);
  color: #000;
  font-weight: 700;
}
button[type="submit"]:hover,
a[role="button"]:not(.secondary):not(.contrast):hover {
  background: #fff;
  box-shadow: 0 0 20px rgba(0,180,255,0.4);
}

/* Secondary */
button.secondary, a[role="button"].secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-glow);
}
button.secondary:hover, a[role="button"].secondary:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

/* Outline */
button.secondary.outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
}
button.secondary.outline:hover {
  color: var(--red);
  border-color: var(--red);
  background: rgba(255,79,110,0.08);
}

/* Contrast link */
a.contrast {
  color: var(--text-muted);
  font-size: 0.85rem;
}
a.contrast:hover { color: var(--accent); }

/* ---- Helpers ---- */
.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: 'IBM Plex Mono', monospace;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

pre {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  background: #070b14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  color: #7cc8ff;
}

details summary {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0;
  user-select: none;
}
details summary:hover { color: var(--accent); }

/* ---- Grid ---- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* ======================================================
   HOME (index.html)
   ====================================================== */
.page-home {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-home main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.page-home h1 {
  font-size: 2rem;
  background: linear-gradient(90deg, #fff 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.page-home .site-tagline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}

.page-home #auth section { margin-bottom: 1.5rem; }

/* Glowing card for login/register */
.page-home article {
  position: relative;
  overflow: hidden;
}
.page-home article::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.page-home article:hover::before { opacity: 1; }

.page-home #menu article { text-align: center; }
.page-home #menu article p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }

/* ======================================================
   FORM (form.html)
   ====================================================== */
.page-form .narrow {
  max-width: min(1800px, 98vw);
  padding-inline: 1rem;
}

.page-form h1 { font-size: 1.4rem; }
.page-form > main { padding: 1.5rem; }

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

.vm-table {
  width: 100%;
  min-width: 1400px;
  table-layout: fixed;
  border-collapse: collapse;
}

.vm-table th {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

.vm-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(30,45,69,0.5);
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.vm-table tr:hover td { background: rgba(0,180,255,0.025); }

/* Column widths */
.vm-table td:nth-child(7),
.vm-table th:nth-child(7)  { width: 13%; }
.vm-table td:nth-child(8),
.vm-table th:nth-child(8)  { width: 10%; }
.vm-table td:nth-child(9),
.vm-table th:nth-child(9)  { width: 11%; }
.vm-table td:nth-child(10),
.vm-table th:nth-child(10) { width: 12%; }
.vm-table td:nth-child(5),
.vm-table th:nth-child(5)  { width: 6%; }
.vm-table td:nth-child(6),
.vm-table th:nth-child(6)  { width: 7%; }

.page-form input[type="number"],
.page-form input[type="text"],
.page-form select {
  font-size: 0.88rem;
  padding: 0.38rem 0.55rem;
  height: auto;
}

/* Remove-row button */
.cell-actions .remove-row {
  padding: 0.3rem 0.45rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: transparent;
}
.cell-actions .remove-row:hover {
  color: var(--red);
  border-color: var(--red);
  background: rgba(255,79,110,0.08);
}

/* Bottom bar */
.page-form .form-footer {
  margin-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ======================================================
   SUBMISSIONS (submissions.html)
   ====================================================== */
.page-submissions .narrow {
  max-width: min(1400px, 96vw);
  padding-inline: 1rem;
}

.page-submissions h1 {
  font-size: 1.6rem;
  margin-bottom: 0;
}

.page-submissions article {
  animation: slideUp 0.3s ease both;
}
.page-submissions article:nth-child(2) { animation-delay: 0.05s; }
.page-submissions article:nth-child(3) { animation-delay: 0.1s; }
.page-submissions article:nth-child(4) { animation-delay: 0.15s; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Status badge */
.badge {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-pending {
  background: rgba(255,180,0,0.1);
  color: #ffb400;
  border: 1px solid rgba(255,180,0,0.25);
}
.badge-done {
  background: rgba(0,229,160,0.1);
  color: var(--green);
  border: 1px solid rgba(0,229,160,0.25);
}

/* ======================================================
   Scrollbar (webkit)
   ====================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ======================================================
   ARTICLES (articles.html)
   ====================================================== */
.page-articles .narrow { max-width: 860px; }

.page-articles #articlesList article {
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.page-articles #articlesList article:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: 0 4px 24px rgba(0,180,255,.08);
}

/* Dialog / Modal */
dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  color: var(--text);
  padding: 0;
  max-width: min(720px, 96vw);
  width: 100%;
  box-shadow: 0 8px 60px rgba(0,0,0,.7);
}

dialog::backdrop {
  background: rgba(5, 8, 18, 0.85);
  backdrop-filter: blur(6px);
}

dialog > article {
  border: none;
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-height: 88vh;
  overflow-y: auto;
}

dialog > article > header {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

dialog > article > header h2 {
  font-size: 1.25rem;
  padding-right: 2rem; /* space for close btn */
}

.close-modal {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .3rem .55rem;
  font-size: .8rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
}
.close-modal:hover {
  color: var(--red);
  border-color: var(--red);
  background: rgba(255,79,110,.08);
}

dialog textarea {
  resize: vertical;
  min-height: 80px;
}

/* Comment block */
#commentsList > div {
  animation: slideUp .25s ease both;
}

/* Contrast button (usato nella card Articoli) */
a[role="button"].contrast, button.contrast {
  background: transparent;
  color: var(--green);
  border: 1px solid rgba(0,229,160,.35);
}
a[role="button"].contrast:hover, button.contrast:hover {
  background: rgba(0,229,160,.1);
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(0,229,160,.15);
}
