﻿/* ------------------------------------------------------------------
  Generals
------------------------------------------------------------------- */

body.page-body {
  margin: 0;
  font-family: "Exo 2", "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  --link-color: #121518;
  /* muted blue */
  --link-color-hover: #2d588d;
  color: var(--link-color);
}

a:hover {
  color: var(--link-color-hover);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Top navigation */
.topbar {
  border-bottom: 1px solid var(--line);
  background-color: #2d588d;
  backdrop-filter: blur(2px);
  color: white;
}

.topbar ul li {
  color: white;
  text-decoration: none;
}

.menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu ul {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  display: flex;
  gap: 18px;
}

.menu li a {
  text-decoration: none;
  color: white;
  font-weight: 700;
  letter-spacing: 0.6px;
  font-size: 14px;
}

.menu li.active a {
  color: #eeee99;
  border-bottom: 2px solid #eeee99;
  padding-bottom: 6px;
}

.menu li.has-down a::after {
  content: " \25BE";
  font-size: 12px;
  margin-left: 4px;
  color: #8aa0ba;
}

.menu-right {
  margin-left: auto;
}

.menu-right ul {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  display: flex;
  gap: 18px;
}

.menu-right a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.menu-right a:hover {
  color: var(--accent-dark);
}

/* Submenu bar */
.submenu {
  border-top: 1px solid var(--line);
  background-color: #f8fafc;
}

.submenu ul {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  display: flex;
  gap: 16px;
}

.submenu li a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}

.submenu li.active a {
  color: var(--accent-dark);
  border-bottom: 2px solid var(--accent-dark);
  padding-bottom: 5px;
}

/* ------------------------------------------------------------------
  Mobile app bar and drawer
------------------------------------------------------------------- */
.appbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.appbar .brand {
  font-weight: 700;
  font-size: 16px;
  color: #1f2937;
}

.appbar .hamburger {
  background: transparent;
  border: none;
  padding: 8px;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.appbar .hamburger span {
  width: 24px;
  height: 2px;
  background: #374151;
  display: block;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 80%;
  max-width: 320px;
  height: 100%;
  background: #ffffff;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
  transform: translateX(-100%);
  transition: transform 0.2s ease-in-out;
  z-index: 2000;
}

.mobile-drawer.open {
  transform: translateX(0);
}

.mobile-drawer .drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.mobile-drawer .drawer-header .brand {
  font-weight: 700;
}

.mobile-drawer .drawer-header .close {
  font-size: 22px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.mobile-drawer .drawer-content {
  padding: 8px 16px 24px;
}

.mobile-drawer .drawer-menu {
  list-style: none;
  padding: 0;
  margin: 8px 0 16px;
}

.mobile-drawer a {
  text-decoration: none;
  color: #374151;
  display: block;
  padding: 8px 0;
}

.mobile-drawer .drawer-menu li.active>a {
  color: var(--accent-dark);
  font-weight: 700;
}

.mobile-drawer .drawer-menu .drawer-submenu {
  list-style: none;
  padding: 0;
  margin: 4px 0 12px 16px;
}

.mobile-drawer .drawer-menu .drawer-submenu a {
  padding: 6px 0;
  color: #4b5563;
  font-size: 14px;
}

.mobile-drawer .drawer-menu .drawer-submenu li.active>a {
  color: var(--accent-dark);
  font-weight: 600;
}

.mobile-drawer .drawer-menu .menu-divider {
  border-top: 1px solid var(--line, rgba(148, 163, 184, 0.35));
  margin: 12px 0;
}

.mobile-drawer .drawer-menu .menu-right-item {
  margin-top: 4px;
}

.mobile-drawer .drawer-noscript {
  padding: 12px 0;
  font-size: 14px;
  color: #6b7280;
}

.mobile-drawer .subtitle {
  font-weight: 700;
  color: #6b7280;
  margin-top: 12px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1999;
}

/* Responsive tweaks */
@media (max-width: 860px) {
  .appbar {
    display: flex;
  }

  .menu ul,
  .menu-right,
  .submenu {
    display: none;
  }
}

/* Main wrapper */
.page-main {
  padding: 18px 0 28px;
  flex: 1 0 auto;
}

.page-body.has-footer .page-main {
  padding-bottom: 92px;
}

/* Footer */
.page-footer {
  border-top: 1px solid var(--line);
  background-color: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(4px);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
}

.page-footer .container {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 8px 0;
}

.page-footer .footer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Headings & sections (simili allo stile screenshot) */
.page-title {
  margin: 16px 0 14px;
  padding-top: 8px;
  font-size: 26px;
  letter-spacing: 0.5px;
}

.section-title {
  margin: 18px 0 12px;
  padding: 6px 0;
  font-size: 20px;
  color: var(--accent-dark);
  border-top: 2px solid #bfc9d4;
  border-bottom: 1px solid #dfe6ee;
  position: relative;
}

.section-title::before {
  content: "\25B8";
  color: var(--accent-dark);
  margin-right: 8px;
}

/* Form elements */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="password"],
input[type="date"],
select,
textarea {
  border: 1px solid #cbd5e1;
  background: #f9fbfe;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.25);
}

.muted {
  color: var(--muted);
}

.hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

/* Title bar (DOCUMENTI style) */
.title-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 2px solid #aeb9c5;
  padding-bottom: 6px;
  margin: 8px 0 12px;
}

.title-bar .title {
  margin: 0;
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0.6px;
  color: #2b5da3;
  text-transform: uppercase;
  font-weight: 800;
}

.title-bar .meta {
  font-size: 12px;
  color: var(--muted);
}

/* Utilities for cell alignment */
.alignleft {
  text-align: left !important;
}

.alignright {
  text-align: right !important;
}

.aligncenter,
td.date,
td.text-center,
th.date,
th.text-center {
  text-align: center !important;
}

/* Small colored square for document type */
.flag {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 8px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.flag.orange {
  background: #f4603c;
  border-color: #dc633f;
}

.flag.gray {
  background: #b9c0c7;
  border-color: #a7b0b9;
}

td.date_expired {
  color: red;
}

.note {
  font-style: italic;
  font-size: 14px;
  color: #666;
}

/* ------------------------------------------------------------------
  Tables
------------------------------------------------------------------- */

/* Table: elenco */
table.elenco {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 16px;
}

table.elenco thead th {
  text-align: left;
  font-size: 16px;
  font-weight: 700;
  color: #3f5166;
  padding: 6px 10px;
  /*border-bottom:2px solid #cbd5e1;*/
}

table.elenco tbody {
  border: 1px solid #cbd5e1;
}

table.elenco tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #e5edf3;
}

table.elenco tbody tr:last-child td {
  border-bottom: 1px solid #cbd5e1;
}

table.elenco tbody tr:nth-child(odd) {
  background: #f7f9fc;
}

table.elenco tbody tr:nth-child(even) {
  background-color: #e6eef6;
}

table.elenco tbody tr:hover {
  background: #eeeed6;
}

table.elenco tbody tr.active td {
  background-color: palegoldenrod;
}

table.elenco tbody td button,
table.elenco tbody td input,
table.elenco tbody td optgroup,
table.elenco tbody td select,
table.elenco tbody td textarea {
  padding: 6px 10px;
}

table.elenco .button {
  margin-top: 0;
  padding: 6px 10px;
}

.minimize,
th[data-col-key="actions"],
td[data-col-key="actions"] {
  width: 1px;
  white-space: nowrap;
  text-align: center;
}

/* ------------------------------------------------------------------
  Mobile tables: horizontal scroll when overflow
------------------------------------------------------------------- */
@media (max-width: 860px) {
  table.elenco {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

/* Simple autocomplete dropdown */
.autocomplete-list {
  position: absolute;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  padding: 4px 0;
  z-index: 50;
}

.autocomplete-item {
  padding: 6px 10px;
  cursor: pointer;
}

.autocomplete-item:hover {
  background: #f3f4f6;
}

/* ------------------------------------------------------------------
  Forms
------------------------------------------------------------------- */

.form-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
  padding: 18px;
  margin-bottom: 18px;
}

.form-title {
  margin: 0;
  font-size: 18px;
  color: #1f2937;
  padding-bottom: 8px;
  border-bottom: 1px solid #eef1f5;
}

.form-title.form-collapsable {
  position: relative;
  /* Scribit: da verificare. mi serve per far funzionare */
  cursor: pointer;
}

.form-subtitle {
  margin: 2px 0 0 0;
  font-size: 13px;
  color: #6b7280;
}

.form-section {
  margin-top: 12px;
}

.form-section:first-child {
  margin-top: 0;
}

.form-section-title {
  font-size: 13px;
  font-weight: 700;
  min-height: 29px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 0 0 10px 0;
  letter-spacing: 0.2px;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.form-section-title::after,
.form-collapsable:after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.15s ease;
  color: #6b7280;
}

.form-section.collapsed .form-section-title::after,
.form-title.collapsed.form-collapsable::after {
  transform: translateY(-50%) rotate(-90deg);
}

.form-section .form-grid,
.form-section .form-actions {
  max-height: 800px;
  /* un valore sufficientemente grande per il contenuto */
  transition: max-height 1s ease, opacity 0.2s ease;
  opacity: 1;
}

.form-section,
.form-section .form-actions {
  margin: 15px 0;
}

.form-section.collapsed .form-grid,
.form-section.collapsed .form-actions {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.form-grid {
  display: grid;
  gap: 0 14px;
  align-items: center;
  grid-template-columns: 160px minmax(0, 1fr);
}

/* Two-column inputs (label+input repeated side-by-side) */
.form-grid-2col {
  grid-template-columns: 160px minmax(0, 1fr) 140px minmax(0, 1fr);
}

/* Three-column inputs (label+input repeated three times) */
.form-grid-3col {
  grid-template-columns: 160px minmax(0, 1fr) 120px minmax(0, 1fr) 120px minmax(0,
      1fr);
}

/* Four-column inputs (label+input repeated four times) */
.form-grid-4col {
  grid-template-columns:
    160px minmax(0, 1fr) 100px minmax(0, 1fr) 100px minmax(0, 1fr) 100px minmax(0, 1fr);
}

.form-grid .form-row {
  display: contents;
}

.form-grid label {
  font-size: 14px;
  text-align: right;
  align-self: center;
}

.form-grid span {
  font-size: 15px;
  line-height: 30px;
  font-weight: 500;
  align-self: center;
}

/* Responsive: stack to single column on narrow containers */
@media (max-width: 800px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid label {
    text-align: left;
  }

  .form-grid {
    gap: 6px 10px;
  }
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  padding: 6px 10px;
  margin: 3px 0;
}

.form-row input[type="checkbox"] {
  width: auto;
  margin-right: 10px;
  vertical-align: text-bottom;
}

.form-row input[type="file"] {
  padding: 6px 0;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-grid .form-grid-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
  margin-top: 4px;
}

/* Compact helper, e.g. for tight table filters */
.form-compact .form-grid {
  gap: 8px 10px;
}

.form-compact .form-grid input {
  padding: 6px 8px;
  font-size: 13px;
}

/* ------------------------------------------------------------------
  Tabs
------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #ddd;
}

.tabs a {
  padding: 8px 12px;
  text-decoration: none;
  color: #333;
  border: 1px solid #ddd;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  /* Stesso stile form */
  background: #f6f6f6;
}

.tabs a.active {
  background: #fff;
  font-weight: 600;
  margin-bottom: -1px;
  /* Per nascondere il bordo inferiore */
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  border: 1px solid #ddd;
  border-top-width: 0;
  padding: 1em;

  /* Stesso stile form */
  background: #ffffff;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

/* Drag handle for sortable tables */
.drag-handle {
  text-align: center;
  color: #666;
  cursor: grab;
  user-select: none;
}

table.sortable tbody tr {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

table.sortable tbody tr.dragging {
  opacity: 0.5;
  /*transform: scale(0.9995);*/
  transform: scale(1.01);
}