/* ── Skip link accessibilità ────────────────────────────────── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: #067338;
    color: #fff;
    font-weight: 600;
    border-radius: 0 0 6px 6px;
    text-decoration: none;
    transition: top 0.1s;
}
.skip-link:focus {
    top: 0;
    color: #fff;
}

/* ── Layout ─────────────────────────────────────────────────── */
body { font-size: 0.9rem; }

/* Topbar mobile */
#topbar { height: 56px; z-index: 1040; }

/* Sidebar — desktop */
#sidebar {
    width: 240px;
    min-height: 100vh;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 1035;
    transition: transform 0.28s ease;
}

/* Sidebar — mobile: nascosta di default, scorre da sinistra */
@media (max-width: 991.98px) {
    #app-wrapper { display: block !important; }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 260px;
        transform: translateX(-100%);
        z-index: 1050;
        min-height: unset;
    }
    #sidebar.sidebar--open {
        transform: translateX(0);
    }

    #main-content {
        width: 100%;
    }
}

/* Overlay scuro dietro la sidebar mobile */
#sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1045;
}
#sidebarOverlay.overlay--visible {
    display: block;
}

/* Blocca scroll body quando sidebar aperta */
body.sidebar-is-open { overflow: hidden; }

#sidebar .nav-link {
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: background 0.15s;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
}

/* ── Tabelle responsive ──────────────────────────────────────── */
.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Su mobile le tabelle scrollano orizzontalmente */
@media (max-width: 767.98px) {
    .card .table { min-width: 600px; }
}

/* ── Cards ──────────────────────────────────────────────────── */
.card { border-radius: 10px; }
.card-header { border-radius: 10px 10px 0 0 !important; }

/* ── Table ──────────────────────────────────────────────────── */
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: #6c757d; }

/* ── Login page ─────────────────────────────────────────────── */
.card.shadow-sm { border-radius: 14px; }

/* ── Utilities ──────────────────────────────────────────────── */
code { font-size: 0.8em; background: #f1f3f5; padding: 2px 5px; border-radius: 4px; }

/* ── Drop zone ──────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed #ced4da;
    border-radius: 10px;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #fafafa;
    user-select: none;
}
.drop-zone:hover {
    border-color: #08B05B;
    background: #f0fdf6;
}
.drop-zone--over {
    border-color: #08B05B;
    background: #e6f9ef;
}
.drop-zone--has-file {
    border-color: #08B05B;
    background: #f0fdf6;
}
.drop-zone-icon {
    font-size: 2.2rem;
    color: #adb5bd;
    display: block;
    margin-bottom: 0.5rem;
    transition: color 0.2s;
}
.drop-zone--over .drop-zone-icon,
.drop-zone--has-file .drop-zone-icon {
    color: #08B05B;
}
.drop-zone-label {
    font-size: 0.9rem;
    color: #495057;
}
.drop-zone-browse {
    color: #08B05B;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}
.drop-zone-hint {
    font-size: 0.78rem;
    color: #adb5bd;
    margin-top: 0.25rem;
}
.drop-zone-filename {
    font-size: 0.85rem;
    font-weight: 600;
    color: #08B05B;
    margin-top: 0.5rem;
    word-break: break-all;
}
.drop-zone-input {
    display: none;
}

/* ── Brand color ────────────────────────────────────────────── */
/*
 * #08B05B  → usato per bordi e sfondi decorativi (no testo sopra)
 * #067338  → usato dove c'è testo (contrasto 6:1 su bianco, WCAG AA ✓)
 */

/* Bottoni pieni */
.btn-dark {
    background-color: #067338;
    border-color: #067338;
    color: #fff;
}
.btn-dark:hover,
.btn-dark:focus,
.btn-dark:active {
    background-color: #055c2d;
    border-color: #055c2d;
    color: #fff;
}

/* Bottoni outline-primary */
.btn-outline-primary {
    color: #067338;
    border-color: #067338;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: #067338;
    border-color: #067338;
    color: #fff;
}

/* Badge success */
.badge.bg-success {
    background-color: #067338 !important;
}

/* Sidebar: voce attiva */
#sidebar .nav-link.active {
    background-color: #067338 !important;
}

/* Paginazione attiva */
.page-item.active .page-link {
    background-color: #067338;
    border-color: #067338;
}
.page-link {
    color: #067338;
}
.page-link:hover {
    color: #055c2d;
}

/* Drop zone: bordi e testi brand (solo decorativi o su sfondo colorato) */
.drop-zone:hover,
.drop-zone--over,
.drop-zone--has-file    { border-color: #08B05B; }
.drop-zone--over        { background: #e6f9ef; }
.drop-zone--has-file    { background: #f0fdf6; }
.drop-zone:hover        { background: #f0fdf6; }

.drop-zone--over .drop-zone-icon,
.drop-zone--has-file .drop-zone-icon { color: #067338; }

.drop-zone-browse   { color: #067338; }
.drop-zone-filename { color: #067338; }

/* Link brand */
a.text-success { color: #067338 !important; }

/* ── Folder Tree ─────────────────────────────────────────────── */
.sortable-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-item {
    margin-bottom: 3px;
}

.tree-row {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.65rem;
    border-radius: 7px;
    background: #fff;
    border: 1px solid #e9ecef;
    gap: 0.3rem;
    transition: background 0.12s, border-color 0.12s;
    min-height: 42px;
}
.tree-row:hover {
    background: #f8f9fa;
    border-color: #dee2e6;
}

/* Drag handle */
.drag-handle {
    cursor: grab;
    color: #ced4da;
    padding: 0 3px;
    flex-shrink: 0;
    font-size: 1rem;
    transition: color 0.15s;
}
.drag-handle:hover { color: #6c757d; }
.drag-handle:active { cursor: grabbing; }

/* Expand/collapse toggle */
.tree-toggle {
    border: none;
    background: none;
    padding: 1px 4px;
    color: #6c757d;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
    line-height: 1;
    font-size: 0.75rem;
    transition: color 0.12s, background 0.12s;
}
.tree-toggle:hover {
    color: #212529;
    background: #e9ecef;
}
.tree-toggle .bi {
    display: inline-block;
    transition: transform 0.2s;
}
.tree-toggle.collapsed .bi {
    transform: rotate(-90deg);
}
/* Placeholder per nodi senza figli (mantiene allineamento) */
.tree-toggle-ph {
    display: inline-block;
    width: 24px;
    flex-shrink: 0;
}

/* Folder icon */
.tree-folder-icon {
    font-size: 1rem;
    color: #f0ad4e;
    flex-shrink: 0;
}

.tree-name { font-size: 0.9rem; }
.tree-desc { font-size: 0.78rem; }
.tree-badge { font-size: 0.72rem; }

/* Children container */
.tree-children {
    padding-left: 2.2rem;
    padding-top: 3px;
    padding-bottom: 1px;
}
/* Empty children: min-height for drop zone */
.tree-children--empty {
    min-height: 6px;
}

/* SortableJS ghost / chosen */
.sortable-ghost > .tree-row {
    opacity: 0.35;
}
.sortable-chosen > .tree-row {
    border-color: #08B05B;
    box-shadow: 0 2px 8px rgba(6,115,56,0.12);
}
.sortable-drag > .tree-row {
    box-shadow: 0 4px 18px rgba(0,0,0,0.14);
    background: #fff;
}
