/* ══════════════════════════════════════════════════════════════════
   PROMETEO SHELL v2
   Top navbar slim + Sidebar rail collapsible + Command palette
══════════════════════════════════════════════════════════════════ */

:root {
    --topbar-h: 56px;
    --rail-w: 248px;
    --rail-w-collapsed: 248px;
    --rail-w-expanded: 248px;
    --rail-bg: #fbfbfa;
    --rail-bg-dark: #1f1f1e;
    --rail-bg-hover: rgba(55,53,47,.06);
    --rail-bg-active: rgba(55,53,47,.09);
    --rail-text: #4a4a47;
    --rail-text-active: #18181b;
    --rail-border: #ececea;
    --topbar-bg: #ffffff;
    --topbar-border: #ececea;
    --content-bg: #ffffff;
}

body.has-shell {
    margin: 0;
    padding-top: var(--topbar-h);
    padding-left: var(--rail-w);
    background: var(--content-bg);
}
body.auth-only { padding: 0; margin: 0; }

/* ════════════════════════════════════════════════════
   TOPBAR (slim, sticky)
═══════════════════════════════════════════════════ */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.topbar-burger {
    display: none;
    background: transparent;
    border: 0;
    width: 32px; height: 32px;
    border-radius: 6px;
    color: #4a4a47;
    font-size: 1.15rem;
    cursor: pointer;
}
.topbar-burger:hover { background: #f4f4f3; }
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: opacity .15s;
    flex-shrink: 0;          /* impedisce il wrap quando lo spazio è poco */
}
.topbar-brand:hover { opacity: .7; }
.topbar-brand img {
    width: 26px; height: 26px;
    filter: grayscale(1) contrast(1.1);
    flex-shrink: 0;
}
.topbar-brand-text {
    display: inline-flex;     /* una sola riga */
    align-items: baseline;
    gap: 8px;
    white-space: nowrap;
    font-family: 'Inter', system-ui, sans-serif;
}
.brand-wordmark {
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: 2.4px;    /* spaziatura "executive" */
    text-transform: uppercase;
    color: #0a0a0a;
    line-height: 1;
}
.brand-for {
    font-size: .62rem;
    font-weight: 600;
    color: #71717a;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.brand-for-sep {
    color: #d4d4d8;
    font-weight: 400;
    font-size: .9rem;
    line-height: 1;
}
@media (max-width: 640px) {
    .brand-for { display: none; }   /* su mobile lasciamo solo PROMETEO */
    .brand-wordmark { letter-spacing: 1.6px; }
}

/* Search/command palette trigger */
.topbar-search-wrap {
    flex: 1;
    max-width: 460px;
    margin: 0 auto;
}
.topbar-search {
    background: #f4f4f3;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    color: #6b6b66;
}
.topbar-search:hover {
    background: #ececea;
    border-color: #dcdcd8;
    box-shadow: none;
}
.topbar-search i { font-size: .9rem; }
.topbar-search-placeholder {
    flex: 1;
    font-size: .82rem;
    color: #91918c;
}
.topbar-search-kbd {
    background: #fff;
    border: 1px solid #dcdcd8;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: .66rem;
    font-weight: 600;
    color: #6b6b66;
    font-family: ui-monospace, monospace;
}

/* Right buttons */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.topbar-icon-btn {
    background: transparent;
    border: 0;
    width: 32px; height: 32px;
    border-radius: 6px;
    color: #6b6b66;
    font-size: 1rem;
    cursor: pointer;
    position: relative;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.topbar-icon-btn:hover {
    background: #f4f4f3;
    color: #18181b;
}

/* ── Notification panel ── */
.topbar-notif { position: relative; }
.topbar-notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 16px; height: 16px;
    background: #dc2626;
    color: #fff;
    border-radius: 9px;
    font-size: .6rem;
    font-weight: 700;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
.topbar-notif-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 340px;
    background: #fff;
    border: 1px solid #ececea;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(24,24,27,.12), 0 0 0 1px rgba(24,24,27,.04);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity .15s, transform .15s;
    overflow: hidden;
    z-index: 200;
}
.topbar-notif.open .topbar-notif-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.topbar-notif-header {
    padding: 12px 14px;
    border-bottom: 1px solid #ececea;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-notif-list { max-height: 360px; overflow-y: auto; }
.topbar-notif-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: #2f2f2c;
    transition: background .12s;
    border-bottom: 1px solid #f4f4f3;
}
.topbar-notif-item:hover { background: #f7f7f5; color: #18181b; }
.topbar-notif-item:last-child { border-bottom: 0; }
.notif-dot {
    width: 28px; height: 28px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #4a4a47;
    font-size: .85rem;
    flex-shrink: 0;
    background: #f4f4f3;
    border: 1px solid #ececea;
}
.notif-dot.dot-warn   { color: #b45309; }
.notif-dot.dot-info   { color: #2f2f2c; }
.notif-dot.dot-danger { color: #b91c1c; }
.notif-text {
    font-size: .85rem;
    line-height: 1.35;
    color: #2f2f2c;
}
.topbar-notif-empty {
    padding: 36px 18px;
    text-align: center;
    color: #91918c;
}
.topbar-notif-empty i {
    font-size: 2rem;
    color: #4a4a47;
    margin-bottom: 10px;
}
.topbar-notif-empty div { font-weight: 600; color: #18181b; }

/* ── User menu ── */
.topbar-user { position: relative; }
.topbar-user-btn {
    background: transparent;
    border: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px 5px 5px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .18s;
}
.topbar-user-btn:hover { background: #f4f4f3; }
.topbar-user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: #18181b;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: .78rem;
    flex-shrink: 0;
    position: relative;
}
.topbar-user-avatar::after {
    content: '';
    position: absolute;
    bottom: -1px; right: -1px;
    width: 8px; height: 8px;
    background: #16a34a;
    border: 2px solid #fff;
    border-radius: 50%;
}
.topbar-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    text-align: left;
}
.topbar-user-name {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar-user-role {
    font-size: .65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 1px;
}
.topbar-user-chev {
    color: var(--text-muted);
    font-size: .78rem;
}
@media (max-width: 720px) {
    .topbar-user-info, .topbar-user-chev { display: none; }
}

.topbar-user-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: #fff;
    border: 1px solid #ececea;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(24,24,27,.12), 0 0 0 1px rgba(24,24,27,.04);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity .15s, transform .15s;
    overflow: hidden;
    z-index: 200;
}
.topbar-user.open .topbar-user-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.topbar-user-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar-user-avatar-big {
    width: 40px; height: 40px;
    border-radius: 8px;
    background: #18181b;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}
.topbar-user-badge {
    display: inline-block;
    margin-top: 4px;
    background: #f4f4f3;
    color: #4a4a47;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .68rem;
    font-weight: 600;
    border: 1px solid #ececea;
}
.topbar-user-divider {
    height: 1px;
    background: #ececea;
    margin: 0;
}
.topbar-user-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    text-decoration: none;
    color: #2f2f2c;
    font-size: .88rem;
    font-weight: 500;
    transition: background .12s;
}
.topbar-user-link:hover { background: #f7f7f5; color: #18181b; }
.topbar-user-link i {
    color: #91918c;
    font-size: 1rem;
    width: 18px;
    text-align: center;
}
.topbar-user-link:hover i { color: #4a4a47; }
.topbar-user-logout { color: #b91c1c !important; }
.topbar-user-logout i { color: #b91c1c !important; }
.topbar-user-logout:hover { background: #fef2f2; }


/* ════════════════════════════════════════════════════
   SIDEBAR RAIL (collapsible)
═══════════════════════════════════════════════════ */
.sidebar-rail {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--rail-w);
    background: var(--rail-bg);
    border-right: 1px solid var(--rail-border);
    z-index: 90;
    overflow: hidden;
}

.rail-nav {
    padding: 12px 8px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100%;
}
.rail-nav::-webkit-scrollbar { width: 6px; }
.rail-nav::-webkit-scrollbar-thumb { background: rgba(55,53,47,.12); border-radius: 3px; }
.rail-nav::-webkit-scrollbar-thumb:hover { background: rgba(55,53,47,.22); }

.rail-section {
    margin-bottom: 12px;
}
.rail-section-label {
    font-size: .68rem;
    font-weight: 600;
    color: #91918c;
    text-transform: uppercase;
    letter-spacing: .6px;
    padding: 10px 10px 4px;
    white-space: nowrap;
    overflow: hidden;
}

.rail-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    margin: 2px 0;
    border-radius: 12px;
    text-decoration: none;
    color: var(--rail-text);
    transition: background .15s ease, color .15s ease, transform .15s ease;
    overflow: hidden;
    cursor: pointer;
    white-space: nowrap;
    font-size: .88rem;
}
.rail-item:hover { transform: translateX(2px); }
.rail-item:hover {
    background: var(--rail-bg-hover);
    color: var(--rail-text-active);
}
.rail-item.active {
    background: var(--rail-bg-active);
    color: var(--rail-text-active);
    font-weight: 600;
}

.rail-icon {
    width: 24px; height: 24px;
    border-radius: 8px;
    background: transparent;
    color: #6b6b66;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: color .15s ease, background .15s ease;
}
.rail-item.active .rail-icon { background: rgba(10,10,10,.06); }
/* Disattiva i colori inline degli icon container — palette neutra */
.rail-icon[style] { background: transparent !important; }
.rail-item:hover .rail-icon,
.rail-item.active .rail-icon { color: var(--rail-text-active); }

.rail-text {
    font-size: .88rem;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rail-item.active .rail-text { font-weight: 600; }

.rail-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 7px;
    background: #e9e9e7;
    color: #4a4a47;
    font-size: .68rem;
    font-weight: 700;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dcdcd8;
}

/* Pin toggle: non più rilevante (sidebar sempre estesa) */
.rail-pin-toggle { display: none !important; }

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(24,24,27,.4);
    backdrop-filter: blur(4px);
    z-index: 89;
}
body.mobile-sidebar-open .sidebar-overlay { display: block; }
body.mobile-sidebar-open .sidebar-rail {
    box-shadow: 8px 0 32px rgba(24,24,27,.18);
}

@media (max-width: 920px) {
    body.has-shell { padding-left: 0 !important; }
    .topbar-burger { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar-rail {
        transform: translateX(-100%);
        transition: transform .25s cubic-bezier(.4,0,.2,1);
    }
    body.mobile-sidebar-open .sidebar-rail { transform: translateX(0); }
    .topbar-search-wrap { display: none; }
}


/* ════════════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════════ */
.app-main {
    min-height: calc(100vh - var(--topbar-h));
    padding: 26px 32px 60px;
    max-width: 1700px;
    margin: 0 auto;
}
@media (max-width: 720px) {
    .app-main { padding: 20px 16px 60px; }
}


/* ════════════════════════════════════════════════════
   COMMAND PALETTE (Cmd+K)
═══════════════════════════════════════════════════ */
.cmd-palette {
    position: fixed;
    inset: 0;
    background: rgba(24,24,27,.45);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 12vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.cmd-palette.open {
    opacity: 1;
    pointer-events: auto;
}
.cmd-palette-box {
    width: 100%;
    max-width: 580px;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        0 16px 48px rgba(24,24,27,.22),
        0 0 0 1px rgba(24,24,27,.06);
    transform: translateY(-8px) scale(.98);
    transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.cmd-palette.open .cmd-palette-box {
    transform: translateY(0) scale(1);
}
.cmd-palette-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}
.cmd-palette-input-wrap i {
    color: var(--text-muted);
    font-size: 1.1rem;
}
.cmd-palette-input-wrap input {
    flex: 1;
    border: 0;
    background: transparent;
    font-size: 1rem;
    outline: 0;
    color: var(--text);
    font-weight: 500;
}
.cmd-palette-input-wrap kbd {
    background: #f1f5f9;
    color: var(--text-muted);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: .66rem;
    font-weight: 700;
    font-family: ui-monospace, monospace;
}
.cmd-palette-results {
    max-height: 380px;
    overflow-y: auto;
    padding: 8px;
}
.cmd-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: background .12s;
    margin-bottom: 2px;
}
.cmd-item:hover, .cmd-item.selected {
    background: #f4f4f3;
    color: #18181b;
}
.cmd-icon {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: transparent;
    color: #6b6b66;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}
.cmd-item:hover .cmd-icon, .cmd-item.selected .cmd-icon {
    color: #18181b;
}
.cmd-info { flex: 1; min-width: 0; }
.cmd-label {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text);
}
.cmd-desc {
    font-size: .76rem;
    color: var(--text-muted);
    margin-top: 1px;
}
.cmd-kind {
    font-size: .66rem;
    font-weight: 700;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.cmd-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}
.cmd-empty i { font-size: 2.4rem; opacity: .4; }
.cmd-empty div { margin-top: 10px; font-weight: 600; }
