
:root {
--primary: #2E7D32;
--secondary: #81C784;
--accent: #FFD54F;
--dark: #1B5E20;
--bg: #F4F7F6;
--card-bg: #FFFFFF;
--text: #333333;
--muted: #666666;
--shadow: 0 4px 20px rgba(0,0,0,0.05);
--radius: 16px;
--font-main: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: var(--bg);
font-family: var(--font-main);
color: var(--text);
line-height: 1.6;
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
}

/* Header */
.header {
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
z-index: 100;
}

.brand {
display: flex;
align-items: center;
gap: 1rem;
}

.brand img {
height: 50px;
width: auto;
object-fit: contain;
}

.brand h1 {
font-size: 1.5rem;
font-weight: 700;
color: var(--primary);
letter-spacing: -0.5px;
}

.user-info {
display: flex;
align-items: center;
gap: 1.5rem;
}

.datetime {
text-align: right;
}

.time {
font-size: 1.25rem;
font-weight: 600;
color: var(--dark);
display: block;
}

.date {
font-size: 0.875rem;
color: var(--muted);
font-weight: 500;
}


.user-profile {
display: flex;
align-items: center;
gap: 0.75rem;
background: #e8f5e9;
padding: 0.5rem 1rem;
border-radius: 50px;
border: 1px solid var(--secondary);
}

.avatar {
width: 36px;
height: 36px;
background: var(--primary);
color: white;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 0.9rem;
}

.username {
font-weight: 600;
color: var(--dark);
font-size: 0.95rem;
}

/* Layout Container */
.app-container {
display: flex;
flex: 1;
overflow: hidden;
position: relative;
}

/* Sidebar */
.sidebar {
width: 260px;
background: #ffffff;
border-right: 1px solid rgba(0,0,0,0.05);
display: flex;
flex-direction: column;
padding: 1.5rem 1rem;
overflow-y: auto;
transition: transform 0.3s ease;
z-index: 90;
}

.nav-section {
margin-bottom: 2rem;
}

.nav-title {
font-size: 0.75rem;
text-transform: uppercase;
color: var(--muted);
font-weight: 700;
margin-bottom: 0.75rem;
padding-left: 0.75rem;
letter-spacing: 0.5px;
}

.nav-list {
list-style: none;
}

.nav-item {
margin-bottom: 0.25rem;
}

.nav-link {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem;
border-radius: 8px;
color: var(--text);
text-decoration: none;
font-weight: 500;
transition: all 0.2s ease;
}

.nav-link:hover {
background: #f1f8e9;
color: var(--primary);
}

.nav-link.active {
background: var(--primary);
color: white;
box-shadow: 0 4px 12px rgba(46, 125, 50, 0.2);
}

.nav-icon {
font-size: 1.25rem;
width: 24px;
text-align: center;
}

/* Resize Main Content for Sidebar */
.main-content {
flex: 1;
padding: 2rem;
overflow-y: auto;
display: grid;
gap: 2rem;
grid-template-columns: repeat(12, 1fr);
grid-auto-rows: min-content; /* Changed from template-rows to auto-rows */
}

@media (max-width: 1024px) {
.sidebar {
position: absolute;
height: 100%;
transform: translateX(-100%);
box-shadow: var(--shadow);
}

.sidebar.open {
transform: translateX(0);
}

.main-content {
grid-template-columns: 1fr;
}

.mod-1, .mod-2, .mod-3, .mod-4 {
grid-column: span 1;
grid-row: auto;
}
.mod-4 {
flex-direction: column;
gap: 1rem;
}
}

/* Layout moduli / card */
.grid-item {
background: var(--card-bg);
border-radius: 12px;
padding: 1.5rem;
box-shadow: var(--shadow);
min-width: 0;
}

.card-header {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: space-between;
gap: 0.75rem 1rem;
margin-bottom: 0.5rem;
}

.card-title {
margin: 0;
font-size: 1.35rem;
font-weight: 700;
color: var(--primary);
}

/* Griglia principale: consente scroll orizzontale alle tabelle figlie */
.main-content > * {
min-width: 0;
max-width: 100%;
}

@media (min-width: 1920px) {
.main-content {
padding: 1.25rem 1.5rem;
gap: 1.25rem;
}
}

/* Pannelli tabella CrudBuilder */
.ecoop-table-panel {
margin-top: 1rem;
background: #fff;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
overflow: visible;
min-width: 0;
}

.ecoop-table-panel + .ecoop-table-panel,
.ecoop-table-panel--grouped {
margin-top: 2rem;
}

.ecoop-table-panel__title {
margin: 0;
padding: 1rem;
background: #fdfdfd;
color: var(--primary);
font-size: 1.1rem;
border-bottom: 2px solid var(--primary);
}

/* Scroll orizzontale tabelle (tutte le pagine) */
.table-responsive,
.ecoop-table-scroll {
width: 100%;
max-width: 100%;
min-width: 0;
overflow-x: auto;
overflow-y: auto;
max-height: calc(100vh - 10.5rem);
-webkit-overflow-scrolling: touch;
scrollbar-width: thin;
scrollbar-color: #b0bec5 #eceff1;
position: relative;
}

body.ecoop-hscroll-active .main-content {
padding-bottom: 1.25rem;
}

/* Barra orizzontale sempre visibile in basso allo schermo */
.ecoop-hscroll-proxy {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 18px;
overflow-x: auto;
overflow-y: hidden;
z-index: 300;
background: #eceff1;
border-top: 2px solid #90a4ae;
box-shadow: 0 -3px 10px rgba(0,0,0,0.12);
display: none;
}

.ecoop-hscroll-proxy.is-active {
display: block;
}

.ecoop-hscroll-proxy__inner {
height: 1px;
}

.ecoop-hscroll-proxy::-webkit-scrollbar {
height: 14px;
}

.ecoop-hscroll-proxy::-webkit-scrollbar-thumb {
background: #78909c;
border-radius: 999px;
}

.ecoop-hscroll-proxy::-webkit-scrollbar-track {
background: #eceff1;
}

.table-responsive::-webkit-scrollbar,
.ecoop-table-scroll::-webkit-scrollbar {
height: 10px;
}

.table-responsive::-webkit-scrollbar-thumb,
.ecoop-table-scroll::-webkit-scrollbar-thumb {
background: #b0bec5;
border-radius: 999px;
}

.ecoop-table-scroll.is-scrollable {
cursor: ew-resize;
}

.ecoop-table-scroll-hint {
display: none;
font-size: 0.75rem;
color: var(--muted);
padding: 0.35rem 0.75rem 0.55rem;
text-align: right;
}

.ecoop-table-scroll.is-scrollable + .ecoop-table-scroll-hint,
.ecoop-table-scroll-hint.is-visible {
display: block;
}

.ecoop-data-table {
width: 100%;
border-collapse: collapse;
table-layout: auto;
}

.ecoop-data-table thead tr {
background: #f9f9f9;
border-bottom: 2px solid #eee;
}

.ecoop-data-table th,
.ecoop-data-table td {
padding: 0.65rem 0.75rem;
text-align: left;
vertical-align: top;
}

.ecoop-data-table th {
color: var(--muted);
font-size: 0.8rem;
font-weight: 600;
white-space: nowrap;
}

.ecoop-data-table tbody tr {
border-bottom: 1px solid #eee;
}

.ecoop-data-table tbody tr:hover td {
background: #fafcff;
}

.ecoop-data-table .ecoop-col-actions {
text-align: right;
white-space: nowrap;
position: sticky;
right: 0;
z-index: 2;
background: #fff;
box-shadow: -6px 0 10px -8px rgba(0,0,0,0.25);
}

.ecoop-data-table thead .ecoop-col-actions {
background: #f9f9f9;
z-index: 3;
}

.ecoop-data-table .ecoop-cell-wrap {
white-space: normal;
min-width: 120px;
max-width: 220px;
}

.ecoop-data-table .ecoop-cell-ellipsis {
max-width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

/* >= 1920x1080: tabella compatta per vedere più colonne senza scroll */
@media (min-width: 1920px) {
.ecoop-data-table {
font-size: 0.78rem;
table-layout: fixed;
}

.ecoop-data-table th,
.ecoop-data-table td {
padding: 0.42rem 0.5rem;
}

.ecoop-data-table .ecoop-cell-ellipsis {
max-width: 120px;
}

.ecoop-data-table .ecoop-cell-wrap {
max-width: 160px;
max-height: 3.4em;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
}

/* < 1920: scroll orizzontale esplicito */
@media (max-width: 1919px) {
.ecoop-data-table {
font-size: 0.85rem;
min-width: max-content;
}

.ecoop-data-table th,
.ecoop-data-table td {
white-space: nowrap;
}

.ecoop-data-table .ecoop-cell-wrap {
white-space: normal;
min-width: 180px;
max-width: 280px;
}
}