:root {
    --top-height: 60px;
    --sidebar-width: 250px;
    --footer-height: 80px;
    --footer-ad-height: 0px;

    --display-top: flex;
    --display-side: flex;
    --display-foot: flex;
    --display-foot-ad: none;

    --control-height: 38px;
}

body,
html {
    margin: 0;
    padding: 0;
    background: var(--bg-main);
    overflow: hidden;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    color: var(--text-light);
    text-align: justify;
}

/* ==================================================== */
/* CORE: GEOMETRIA DI SISTEMA (TASSATIVA DA VARIABILI)  */
/* ==================================================== */

#topbar {
    display: var(--display-top) !important;
    height: var(--top-height) !important;
    box-sizing: border-box !important;
    position: relative;
    z-index: 100;
    justify-content: flex-start;
    text-align: left;
    align-items: center;
    background: var(--bg-panel);
    padding-left: 4em;
    padding-right: 4em;
    border-bottom: 2px solid var(--border-main);
    box-shadow: 0 2px 10px var(--shadow-main);
    gap: 20px;
}

.sidebar {
    display: var(--display-side) !important;
    width: var(--sidebar-width) !important;
    box-sizing: border-box !important;
    flex-direction: column;
    background: var(--bg-panel);
    padding: 20px 0;
    border-right: 2px solid var(--border-main);
    overflow-y: auto;
}

#public-sidebar {
    display: var(--display-side) !important;
    flex-direction: column !important;
    width: var(--sidebar-width) !important;
    position: fixed !important;
    top: var(--top-height) !important;
    left: 0;
    bottom: calc(var(--footer-height, 0px) + var(--footer-ad-height, 0px)) !important;
    box-sizing: border-box !important;
    z-index: 900;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: var(--bg-panel);
    border-right: 2px solid var(--border-main);
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    transform: translateX(-100%);
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), background-color 0.3s ease;
}

#public-sidebar.open {
    left: 0;
    transform: translateX(0);
}

#public-sidebar:hover {
    transform: translateX(calc(-100% + 20px));
}

.layout:has(#public-sidebar:hover) .hamburger-btn {
    color: var(--text-light);
    background: var(--primary);
}

.app-container {
    width: 100vw !important;
    height: calc(100dvh - var(--top-height, 0px) - var(--footer-height, 0px) - var(--footer-ad-height, 0px)) !important;
    box-sizing: border-box !important;
    position: relative;
    overflow-y: auto;
}

#main-app-container {
    padding-left: 2px !important;
}

#footer {
    display: var(--display-foot) !important;
    height: var(--footer-height) !important;
    position: fixed !important;
    left: 0;
    width: 100vw;
    bottom: var(--footer-ad-height, 0px) !important;
    box-sizing: border-box !important;
    z-index: 100;
    align-items: center;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-main);
    padding: 0 20px;
    font-size: 0.85em;
    color: var(--text-muted);
}

#footer-ad {
    display: var(--display-foot-ad) !important;
    height: var(--footer-ad-height) !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0;
    width: 100vw;
    box-sizing: border-box !important;
    z-index: 105;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-main);
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ==================================================== */
/* COMPONENTI BASE CMS                                  */
/* ==================================================== */

#menu-toggle {
    display: none;
}

a {
    color: var(--text-light);
}

h2 {
    margin: 0;
    color: var(--primary);
    font-size: 1.5em;
}

h3 {
    margin-top: 20px;
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.2em;
}

h4 {
    margin-top: 10px;
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 1em;
}

/* Utilities */
.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
    text-align: center;
}

.justify-center {
    justify-content: center;
}

.gap-1 {
    gap: 5px;
}

.gap-2 {
    gap: 10px;
}

.flex-1 {
    flex: 1;
}

.flex-2 {
    flex: 2;
}

.flex-3 {
    flex: 3;
}

.w-100 {
    width: 100%;
    max-width: 100%;
}

.m-0 {
    margin: 0;
}

.mt-2 {
    margin-top: 10px;
}

.mt-4 {
    margin-top: 20px;
}

.mb-3 {
    margin-bottom: 15px;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.text-small {
    font-size: 0.9em;
}

.dashboard-container {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.topbar-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    overflow: hidden;
}

.topbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
}

#topbar a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.2s;
}

#topbar a:visited {
    color: var(--text-light);
}

#topbar a:hover {
    color: var(--text-light);
    text-decoration: underline;
}

#site-title-display {
    font-size: 1.2em;
    font-weight: bold;
    letter-spacing: 0.5px;
    color: var(--text-light);
    text-shadow: 0px 1px 3px var(--shadow-text-dark);
}

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: var(--bg-main);
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-main);
    padding-bottom: 15px;
}

.tab-section {
    display: none;
}

.tab-section.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Buttons */
.btn {
    border: none;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-light);
    font-size: 0.9em;
    font-weight: bold;
    text-decoration: none;
    box-sizing: border-box !important;
    height: var(--control-height);
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center;
    line-height: 1;
    padding: 0 16px;
    vertical-align: middle;
}

.btn-primary {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
}

.btn-success {
    background: var(--success);
}

.btn-danger {
    background: var(--danger);
}

.btn-info {
    background-color: var(--primary);
    color: var(--bg-main) !important;
}

.btn-warning {
    background: var(--warning);
}

.btn-dark {
    background: var(--border-main);
}

.btn-sm {
    font-size: 0.8em;
    height: 30px;
    padding: 0 10px;
}

.input-dark,
select.input-dark,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]) {
    box-sizing: border-box !important;
    height: var(--control-height);
    min-height: var(--control-height);
    /*line-height: var(--control-height) !important;*/
    padding: 0 12px;
    vertical-align: middle;
}

.form-col {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

textarea.input-dark,
textarea {
    height: auto;
    min-height: calc(var(--control-height) * 2);
    padding: 10px 12px;
}

input[type="color"].input-dark,
input[type="color"] {
    box-sizing: border-box !important;
    height: var(--control-height);
    width: 44px;
    padding: 2px;
    cursor: pointer;
}

.admin-footer-hidden-toggle {
    display: none !important;
}

.admin-btn-float {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    padding: 10px 15px;
    background: var(--bg-float-btn);
    color: var(--text-light);
    cursor: pointer;
    border-radius: 20px;
    border: none;
    font-weight: bold;
    box-shadow: 0 4px 10px var(--shadow-box);
    border: 1px solid var(--border-light);
}

.sidebar-btn {
    background: transparent;
    color: var(--text-light);
    border: none;
    padding: 15px 20px;
    text-align: left;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background 0.2s, border-left 0.2s;
    border-left: 4px solid transparent;
    text-decoration: none;
    display: block;
}

.sidebar-btn:hover {
    background: var(--bg-card);
}

.sidebar-btn.active {
    background: var(--bg-main);
    border-left: 4px solid var(--primary);
    color: var(--primary);
}

.sidebar-btn-danger {
    margin-top: auto;
    border-top: 1px solid var(--border-main);
    color: var(--danger-light);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--secondary);
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    transition: color 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--text-light);
    border-bottom: 2px solid var(--primary);
    margin-bottom: -1px;
}

/* FOOTER INTERNO */
.footer-left {
    flex: 1;
}

.footer-center {
    flex: 2;
    text-align: center;
}

.footer-right {
    flex: 1;
    display: flex;
    align-items: center;
    text-align: right;
}

#footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

#footer a:hover {
    color: var(--text-light);
}

.privacy-footer-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    font-size: 1em;
    padding: 0;
    transition: color 0.2s;
}

.privacy-footer-btn:hover {
    color: var(--text-light);
    text-decoration: underline;
}

/* Forms & Inputs */
input:not([type="color"]):not([type="checkbox"]) {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--secondary);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-light);
    font-size: 1em;
}

input.input-inline {
    background: var(--bg-main);
    border: 1px solid var(--border-main);
    padding: 10px;
}

input[type="color"] {
    height: 38px;
    width: 40px;
    padding: 0;
    cursor: pointer;
    border: none;
    margin: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    color: var(--text-muted);
    font-size: 0.9em;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9em;
    white-space: nowrap;
}

.gestione-form-bar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: var(--bg-card);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.95em;
    color: var(--text-light);
}

.setting-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin: 0;
    accent-color: var(--success);
}

.input-dark {
    width: 100%;
    padding: 10px;
    background: var(--bg-main);
    color: var(--text-light);
    border: 1px solid var(--border-main);
    box-sizing: border-box;
    border-radius: 4px;
}

.input-label {
    color: var(--text-muted);
    font-size: 0.9em;
    display: block;
    margin-bottom: 5px;
}

/* Tables & Grids */
table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
    font-size: 0.9em;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--border-main);
}

.admin-table-wrapper {
    max-height: 350px;
    overflow-y: auto;
    background: var(--bg-main);
    border-radius: 6px;
    padding: 10px;
    margin-top: 15px;
}

.gestione-table-wrapper {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    max-width: 100%;
}

.table-cell-actions {
    text-align: right;
    white-space: nowrap;
}

.sys-info-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.sys-info-table th,
.sys-info-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-main);
    text-align: left;
}

.sys-info-table th {
    color: var(--primary);
    width: 30%;
    font-weight: normal;
}

.sys-info-table tr:last-child td,
.sys-info-table tr:last-child th {
    border-bottom: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border-bottom: 3px solid var(--primary);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--text-light);
    margin: 10px 0;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-modal);
    padding: 25px;
    border-radius: 8px;
    width: 95%;
    max-width: 600px;
    box-shadow: 0 5px 15px var(--shadow-main);
    max-height: 85dvh;
    overflow-y: auto;
    display: block;
}

.modal-sm {
    max-width: 350px;
}

.modal-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-page-content {
    max-width: 600px;
    width: 100%;
}

.modal-header-title {
    color: var(--primary);
    border-bottom: 1px solid var(--border-main);
    padding-bottom: 10px;
    margin-top: 0;
}

.modal-code-content {
    max-width: 90%;
    width: 100%;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-img-content {
    max-width: 400px;
    width: 100%;
}

/* Markdown & Code Editors */
.md-toolbar {
    display: flex;
    gap: 5px;
    background: var(--bg-panel);
    padding: 8px;
    border: 1px solid var(--border-main);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    flex-wrap: wrap;
}

.md-btn {
    background: var(--bg-main);
    color: var(--text-light);
    border: 1px solid var(--border-main);
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: background 0.2s, color 0.2s;
}

.md-btn:hover {
    background: var(--primary);
    color: var(--text-light);
}

.md-textarea {
    border-radius: 0 0 4px 4px !important;
    margin-top: 0 !important;
}

.md-separator {
    border-left: 1px solid var(--border-main);
    margin: 0 5px;
}

.editor-row {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    align-items: flex-start;
}

.editor-col {
    flex: 1;
    text-align: left;
}

.editor-col-2 {
    flex: 2;
    text-align: left;
}

.action-bar {
    display: flex;
    gap: 5px;
}

.help-text {
    color: var(--secondary);
    font-size: 0.85em;
    display: block;
    margin-top: 5px;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.code-title {
    margin: 0;
    color: var(--accent);
}

.code-filename {
    font-family: monospace;
    color: var(--text-muted);
}

.code-textarea {
    flex: 1;
    width: 100%;
    background: var(--bg-code);
    color: var(--text-code);
    font-family: 'Courier New', Courier, monospace;
    border: 1px solid var(--border-main);
    padding: 15px;
    resize: none;
    font-size: 14px;
    white-space: pre;
    overflow: auto;
    box-sizing: border-box;
}

.code-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

/* Drag & Drop */
.draggable-row {
    cursor: grab;
    transition: background-color 0.2s;
}

.draggable-row:active {
    cursor: grabbing;
}

.draggable-row.dragging {
    opacity: 0.5;
    background: var(--bg-panel);
}

.drag-handle {
    cursor: grab;
    padding-right: 10px;
    color: var(--secondary);
    font-weight: bold;
    user-select: none;
    font-size: 1.2em;
}

.drag-over-top {
    border-top: 2px solid var(--primary) !important;
}

.drag-over-bottom {
    border-bottom: 2px solid var(--primary) !important;
}

/* Notifications */
.notification-container-fixed {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.toast-notification {
    background: var(--bg-panel);
    color: var(--text-light);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 250px;
    pointer-events: auto;
    animation: slideUp 0.3s ease-out forwards;
    border-left: 5px solid var(--primary);
}

.toast-success {
    border-color: var(--success-light);
}

.toast-error {
    border-color: var(--danger-light);
}

.toast-warning {
    border-color: var(--warning-light);
}

.toast-fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Portfolio Layout */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    padding: 40px 20px;
    max-width: 1400px;
    margin: 0 auto;
    align-content: start;
}

.portfolio-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    border-top: 5px solid var(--primary);
    border-bottom: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px var(--shadow-main);
    position: relative;
}

.portfolio-card:hover {
    transform: translateY(-15px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
}

.portfolio-img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-main);
}

.portfolio-body {
    padding: 30px;
    text-align: center;
}

.portfolio-title {
    font-size: 1.6em;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--text-light);
    letter-spacing: 1px;
}

.portfolio-text {
    color: var(--text-muted);
    font-size: 1em;
    line-height: 1.7;
    margin-bottom: 1em;
}

.category-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 5px 12px;
    border-radius: 20px;
    color: var(--text-light);
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 10;
    box-shadow: 0 2px 5px var(--shadow-box);
}

/* Media Gallery Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.media-card {
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-main);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.media-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px var(--shadow-main);
}

.media-preview {
    width: 100%;
    height: 130px;
    object-fit: cover;
    background: var(--bg-panel);
    cursor: zoom-in;
    border-bottom: 1px solid var(--border-main);
}

.media-info {
    padding: 10px;
}

.media-name {
    font-size: 0.8em;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
}

.media-actions {
    display: flex;
    gap: 5px;
}

.media-actions .btn {
    flex: 1;
    padding: 5px;
    font-size: 0.75em;
}

/* Sidebar Mobile */
.sidebar-toggle-btn {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2em;
}

@media (max-width: 768px) {
    .sidebar-toggle-btn {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 5px 0 15px var(--shadow-main);
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        padding-top: 70px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.open {
        display: block;
    }
}

/* GDPR COOKIE BANNER */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-panel);
    padding: 15px 25px;
    box-shadow: 0 -5px 20px var(--shadow-main);
    z-index: 10001;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    border-top: 3px solid var(--primary);
    gap: 20px;
}

.cookie-banner-text {
    flex: 1;
    font-size: 0.9em;
    color: var(--text-muted);
    line-height: 1.5;
}

.cookie-banner-btn {
    white-space: nowrap;
}

@media (max-width: 600px) {
    .cookie-banner {
        flex-direction: column;
        text-align: center;
        padding: 20px 15px;
    }

    .cookie-banner-btn,
    .cookie-banner-btn .btn {
        width: 100%;
    }
}

/* Markdown Containers */
p>code {
    background: var(--bg-code);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-main);
}

.markdown-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-main);
    border-radius: 12px;
    box-shadow: 0 5px 15px var(--shadow-main);
    color: var(--text-light);
}

@media (max-width: 768px) {
    .markdown-container {
        margin: 20px 15px;
        padding: 20px;
    }
}

.markdown-container a,
a.md-link,
.read-more-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.markdown-container a:hover,
a.md-link:hover,
.read-more-link:hover {
    color: var(--text-light);
    text-decoration: underline;
}

/* Accordion */
.accordion-item {
    border: 1px solid var(--border-light);
    border-top: 5px solid var(--primary);
    margin-bottom: 15px;
    border-radius: 12px;
    background: var(--accordion-bg);
    overflow: hidden;
    box-shadow: 0 4px 15px var(--shadow-box);
}

.accordion-header {
    padding: 15px 20px;
    cursor: pointer;
    background: var(--accordion-header-bg);
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
    user-select: none;
}

.accordion-content {
    display: none;
    padding: 20px;
    border-top: 1px solid var(--border-light);
}

.accordion-header:hover {
    background: var(--accordion-header-hover);
}

.acc-icon {
    font-size: 1.2em;
    font-family: monospace;
    color: var(--primary);
}

/* Scrollbars */
#public-sidebar::-webkit-scrollbar {
    width: 5px;
}

#public-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#public-sidebar::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-main);
}

::-webkit-scrollbar {
    width: 20px;
    height: 20px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
    border-radius: 20px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 20px;
    border: 2px solid var(--bg-main);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* System Behaviors */
#scroll-progress-container {
    display: var(--display-top) !important;
    top: var(--top-height) !important;
    height: 2px;
    position: fixed;
    width: 100%;
    z-index: 99;
}

#scroll-progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.1s ease-out;
}

#back-to-top-btn {
    position: fixed;
    bottom: 65px;
    right: 20px;
    width: 35px;
    height: auto;
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 0 8px var(--text-light));
}

#back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1.1);
}

#back-to-top-btn:hover {
    filter: drop-shadow(0 0 15px var(--primary)) brightness(1.1);
    transform: translateY(-5px) scale(1.1);
}

.hamburger-btn {
    z-index: 10;
    cursor: pointer;
    font-size: 30px;
    color: black;
    user-select: none;
    transition: color 0.4s ease;
    background: var(--bg-panel);
    border-radius: 5px;
    border: 1px solid;
    width: 1.3em;
    text-align: center;
    position: fixed;
    left: 0.3em;
}

/* INNESCO APERTURA MENU LATERALE */
#menu-toggle:checked~#public-sidebar {
    transform: translateX(0);
}

#menu-toggle:checked~.hamburger-btn {
    color: var(--text-light);
    background: var(--primary);
}

.hamburger-btn:hover {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary);
}

/* Social Share Overrides for perfect alignment */
#share-toggle {
    display: none;
}

#share {
    position: fixed;
    top: calc((var(--top-height) - 40px)/2);
    right: calc((var(--top-height) - 40px)/2);
    z-index: 9999;
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    background-color: var(--bg-panel);
    padding: 8px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    width: 40px;
    height: 40px;
    overflow: hidden;
    box-sizing: border-box;
    transition: width 0.3s ease-in-out;
}

.share-btn {
    font-size: 24px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin: 0;
}

.share-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.share-icons {
    display: flex;
    gap: 12px;
    padding-right: 15px;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: white;
    font-weight: bold;
}

.share-icons a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid;
    text-decoration: none;
    font-size: 14px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.share-icons a img {
    width: 14px !important;
    height: 14px !important;
    object-fit: contain;
}

.share-icons span {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, filter 0.2s;
}

.share-icons span:hover {
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.9));
}

#share-toggle:checked~#share {
    width: 220px;
}

#share-toggle:checked~#share .share-icons {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease 0.15s, transform 0.3s ease 0.15s;
}

/* Pulsanti e input di sistema */
button[type="submit"],
input[type="submit"],
.btn[type="submit"] {
    background-color: var(--success) !important;
    border-color: var(--success) !important;
    color: var(--text-light) !important;
}

button[type="submit"]:hover,
input[type="submit"]:hover,
.btn-primary {
    background-color: var(--success) !important;
    border-color: var(--success) !important;
    color: --success-dark !important;
}

.btn-primary:active {
    filter: brightness(0.9);
}

.btn:hover,
.sidebar-btn:hover,
.tab-btn:hover,
.md-btn:hover,
.admin-btn-float:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
    filter: brightness(0.85) !important;
    transition: filter 0.2s ease;
    opacity: 1 !important;
}

.btn-primary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-dark {
    color: #ffffff !important;
}

.btn-sm img {
    height: 16px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
}

/* Admin Footer e Log Header */
.admin-footer-open {
    position: fixed;
    bottom: 10px;
    left: 0;
    background: #1a252f;
    color: #bdc3c7;
    padding: 8px 12px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    z-index: 9999;
    border: 2px solid #e74c3c;
    border-left: none;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
    transition: left 0.4s ease;
}

.admin-debug-footer {
    position: fixed;
    bottom: 0;
    left: -100%;
    width: 100%;
    background-color: #1a252f;
    border-top: 2px solid #e74c3c;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 15px;
    z-index: 10000;
    font-family: monospace;
    font-size: 13px;
    box-sizing: border-box;
    transition: left 0.4s ease-in-out;
}

#admin-footer-toggle:checked~.admin-debug-footer {
    left: 0;
}

#admin-footer-toggle:checked~.admin-footer-open {
    left: -50px;
}

.admin-footer-close {
    cursor: pointer;
    font-size: 16px;
    padding: 0 10px;
    color: #bdc3c7;
}

.admin-footer-close:hover,
.admin-footer-open:hover {
    color: #fff;
}

.sticky-log-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-card, #1e1e1e);
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-main, #333);
    margin-bottom: 15px;
}

.log-search-bar {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.clickable-log-cell {
    cursor: pointer;
    transition: background-color 0.2s;
}

.clickable-log-cell:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.zebrata table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

.zebrata table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.d-none {
    display: none !important;
}

/* WIDGET FLOATING SHARE CMS */
#share-floating {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border-main);
    border-radius: 30px;
    padding: 5px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    width: 40px;
    height: 40px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.share-main-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2em;
    flex-shrink: 0;
    z-index: 2;
}

.share-icons-container {
    display: flex;
    align-items: center;
    padding-right: 15px;
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.3s;
    pointer-events: none;
}

#share-toggle:checked~#share-floating {
    width: auto;
    max-width: 350px;
}

#share-toggle:checked~#share-floating .share-icons-container {
    opacity: 1;
    pointer-events: auto;
}

/* KANBAN (Traspone base normal.css senza angoli smussati) */
.kanban-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 20px;
    justify-content: center;
}

.kanban-container a {
    text-decoration: none !important;
}

.kanban-col {
    min-width: 300px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
    background: var(--bg-card);
    border-top: 5px solid var(--section-color, var(--secondary));
    box-shadow: 0 4px 15px var(--shadow-box);
    padding-bottom: 10px;
    border-radius: 12px;
    border: none;
}

.kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-main);
    background: transparent;
}

.kanban-header-title {
    font-size: 1.1em;
    font-weight: bold;
    margin: 0 10px;
    color: var(--secondary);
}

.kanban-header a {
    color: var(--secondary) !important;
}

.kanban-list {
    min-height: 100px;
    padding: 10px;
}

.kanban-item {
    background: var(--bg-panel);
    margin-bottom: 10px;
    padding: 15px;
    position: relative;
    box-shadow: 0 2px 5px var(--shadow-box);
    cursor: grab;
    user-select: none;
    border: 1px solid var(--border-main);
    border-radius: 8px;
}

.kanban-item.is-done {
    opacity: 0.55;
    background: var(--bg-main) !important;
    border-color: var(--secondary) !important;
}

.kanban-item.is-done .kanban-item-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.item-dragging {
    opacity: 0.4;
    border: 2px dashed var(--secondary) !important;
}

.kanban-item * {
    pointer-events: none;
}

.kanban-item .action-bar,
.kanban-item input[type="checkbox"],
.kanban-item a {
    pointer-events: auto;
}

/* Toggle Switch UI */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-off-color, var(--text-muted));
    transition: .3s;
    border-radius: 24px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--toggle-on-color, var(--primary));
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(22px);
}

/* MINIVIEW */
body.miniview-body {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh !important;
    background: var(--bg-main) !important;
}

.miniview-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
    box-sizing: border-box !important;
}

body.miniview-body .markdown-container,
body.miniview-body .kanban-container,
body.miniview-body [class*="wrapper"],
body.miniview-body [class*="card"] {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
}

/* Utilities Specifiche Immagini Markdown */
.md-img-wrapper {
    display: flex;
    justify-content: center;
    margin: 25px 0;
}

.md-img-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 6px var(--bg-main);
}

.md-img-container img {
    max-width: 100%;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    border: 1px solid var(--border-main);
}

.md-img-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--text-light);
    color: var(--bg-main);
    opacity: 0.95;
    padding: 8px 12px;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    font-size: 0.85em;
    text-align: center;
    font-weight: bold;
    border: 1px solid var(--border-main);
    border-top: none;
    box-sizing: border-box;
}

/* ==================================================== */
/* OVERLAY DI CARICAMENTO GLOBALE                       */
/* ==================================================== */

.loading-overlay {
    --overlay-bg: rgba(220, 220, 220, 0.72);
    --dot-size: 10px;
    --orbit-radius: 42px;
    --animation-duration: 1.2s;

    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    backdrop-filter: blur(2px);
    
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 220ms ease, visibility 220ms ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.loader {
    position: relative;
    width: calc(var(--orbit-radius) * 2 + var(--dot-size));
    height: calc(var(--orbit-radius) * 2 + var(--dot-size));
}

.dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--dot-size);
    height: var(--dot-size);
    margin: calc(var(--dot-size) / -2);
    border-radius: 50%;
    background: #707070;
    transform: rotate(var(--angle)) translateY(calc(var(--orbit-radius) * -1));
    animation: woosh var(--animation-duration) infinite ease-in-out;
    animation-delay: var(--delay);
}

.dot:nth-child(1) { --angle: 0deg; --delay: -1s; }
.dot:nth-child(2) { --angle: 60deg; --delay: -0.8s; }
.dot:nth-child(3) { --angle: 120deg; --delay: -0.6s; }
.dot:nth-child(4) { --angle: 180deg; --delay: -0.4s; }
.dot:nth-child(5) { --angle: 240deg; --delay: -0.2s; }
.dot:nth-child(6) { --angle: 300deg; --delay: 0s; }

@keyframes woosh {
    0%, 100% {
        opacity: 0.3;
        background: #707070;
        filter: blur(0);
        transform: rotate(var(--angle)) translateY(calc(var(--orbit-radius) * -1)) scale(0.75);
    }
    35% {
        opacity: 1;
        background: #ffffff;
        filter: blur(1px);
        box-shadow: 0 0 6px #ffffff, 0 0 14px rgba(255, 255, 255, 0.9);
        transform: rotate(var(--angle)) translateY(calc(var(--orbit-radius) * -1)) scale(1.45);
    }
    60% {
        opacity: 0.45;
        background: #8a8a8a;
        filter: blur(0);
        transform: rotate(var(--angle)) translateY(calc(var(--orbit-radius) * -1)) scale(0.9);
    }
}

@media (prefers-reduced-motion: reduce) {
    .dot {
        animation-duration: 2.5s;
    }
}