/**
 * BridgeWorks — Dashboard area aziende
 * Bento layout · priorità attività · preview inbox
 */

body.company-dashboard-v2 {
    --cd2-hero-bg: linear-gradient(135deg, #1e293b 0%, #2a5c47 52%, #343b4a 100%);
    --cd2-hero-line: rgba(255, 255, 255, 0.14);
    --cd2-surface-glass: rgba(255, 255, 255, 0.08);
    --cd2-accent-glow: rgba(42, 92, 71, 0.22);
    overflow-x: clip;
}

body.company-dashboard-v2 .pd2-main.co-main.cd-page {
    padding-bottom: 48px;
    max-width: 100%;
    min-width: 0;
    overflow-x: clip;
}

body.company-dashboard-v2 .cd2-hero,
body.company-dashboard-v2 .cd2-bento,
body.company-dashboard-v2 .cd2-grid,
body.company-dashboard-v2 .cd2-grid__main,
body.company-dashboard-v2 .cd2-grid__side,
body.company-dashboard-v2 .cd2-panel,
body.company-dashboard-v2 .cd-alerts {
    max-width: 100%;
    min-width: 0;
}

/* Hero */
.cd2-hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr);
    gap: 24px;
    margin-bottom: 24px;
    padding: clamp(24px, 4vw, 32px);
    border-radius: 20px;
    background: var(--cd2-hero-bg);
    color: #fff;
    overflow: hidden;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.cd2-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 80% at 100% 0%, rgba(196, 168, 130, 0.22), transparent 55%),
        radial-gradient(ellipse 50% 60% at 0% 100%, rgba(255, 255, 255, 0.06), transparent 50%);
    pointer-events: none;
}

.cd2-hero > * {
    position: relative;
    z-index: 1;
}

.cd2-hero__eyebrow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.cd2-hero__plan {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    border: 1px solid var(--cd2-hero-line);
    background: var(--cd2-surface-glass);
    color: #fff;
}

.cd2-hero__plan--pro {
    border-color: rgba(196, 168, 130, 0.45);
    background: rgba(196, 168, 130, 0.18);
}

.cd2-hero__title {
    margin: 0;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.cd2-hero__desc {
    margin: 10px 0 0;
    max-width: 42ch;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.82);
}

.cd2-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.cd2-hero__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.cd2-hero__btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.cd2-hero__btn--primary {
    background: #fff;
    color: var(--cd-ink, #0f172a);
}

.cd2-hero__btn--primary:hover {
    background: #f8fafc;
    color: var(--cd-ink, #0f172a);
}

.cd2-hero__btn--ghost {
    border-color: var(--cd2-hero-line);
    background: var(--cd2-surface-glass);
    color: #fff;
}

.cd2-hero__btn--ghost:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.cd2-hero__panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--cd2-hero-line);
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(8px);
}

.cd2-hero__panel-title {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
}

.cd2-hero__stat-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.cd2-hero__stat {
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.cd2-hero__stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.cd2-hero__stat-label {
    display: block;
    margin-top: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
}

.cd2-hero__stat--accent {
    background: rgba(42, 92, 71, 0.35);
    border-color: rgba(255, 255, 255, 0.12);
}

/* Bento metrics */
.cd2-bento {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.cd2-kpi {
    grid-column: span 3;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--cd-border, rgba(15, 23, 42, 0.08));
    background: var(--cd-surface, #fff);
    box-shadow: var(--cd-shadow-xs, 0 1px 2px rgba(15, 23, 42, 0.04));
    min-height: 108px;
}

.cd2-kpi--wide {
    grid-column: span 3;
}

.cd2-kpi--accent {
    border-color: var(--cd-accent-line);
    background: linear-gradient(180deg, var(--cd-accent-soft) 0%, var(--cd-surface) 100%);
}

.cd2-kpi__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cd-ink-muted);
}

.cd2-kpi__value {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--cd-ink);
    font-variant-numeric: tabular-nums;
}

.cd2-kpi--accent .cd2-kpi__value {
    color: var(--cd-accent);
}

.cd2-kpi__hint {
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--cd-ink-muted);
}

.cd2-kpi__badge {
    display: inline-flex;
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 700;
    background: var(--cd-accent);
    color: #fff;
}

/* Main grid */
.cd2-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr);
    gap: 20px;
    align-items: start;
}

.cd2-panel {
    border-radius: 16px;
    border: 1px solid var(--cd-border);
    background: var(--cd-surface);
    box-shadow: var(--cd-shadow-xs);
    overflow: hidden;
}

.cd2-panel__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cd-border);
    background: var(--cd-surface-muted);
}

.cd2-panel__title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--cd-ink);
}

.cd2-panel__lead {
    margin: 4px 0 0;
    width: 100%;
    font-size: 0.8125rem;
    color: var(--cd-ink-muted);
}

.cd2-panel__link {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cd-accent);
    text-decoration: none;
    white-space: nowrap;
}

.cd2-panel__link:hover {
    text-decoration: underline;
}

/* Priority tips */
.cd2-tips {
    display: flex;
    flex-direction: column;
}

.cd2-tip {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cd-border);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.cd2-tip:last-child {
    border-bottom: none;
}

.cd2-tip:hover {
    background: var(--cd-surface-muted);
    text-decoration: none;
}

.cd2-tip__icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--cd-surface-inset);
    color: var(--cd-ink-soft);
}

.cd2-tip--accent .cd2-tip__icon {
    background: var(--cd-accent-soft);
    color: var(--cd-accent);
}

.cd2-tip__body {
    min-width: 0;
    flex: 1;
}

.cd2-tip__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 4px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--cd-ink);
}

.cd2-tip__desc {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--cd-ink-muted);
}

.cd2-tip__cta {
    flex-shrink: 0;
    align-self: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cd-accent);
}

/* Activity preview */
.cd2-feed {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cd2-feed__item {
    border-bottom: 1px solid var(--cd-border);
}

.cd2-feed__item:last-child {
    border-bottom: none;
}

.cd2-feed__link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.cd2-feed__link:hover {
    background: var(--cd-surface-muted);
    text-decoration: none;
}

.cd2-feed__avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--cd-accent-soft);
    color: var(--cd-accent);
    font-size: 0.75rem;
    font-weight: 700;
}

.cd2-feed__body {
    min-width: 0;
    flex: 1;
}

.cd2-feed__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 8px;
    margin-bottom: 2px;
}

.cd2-feed__type {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--cd-ink-muted);
}

.cd2-feed__time {
    font-size: 0.6875rem;
    color: var(--cd-ink-faint);
}

.cd2-feed__title {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cd-ink);
    line-height: 1.35;
}

.cd2-feed__preview {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--cd-ink-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cd2-feed__item--unread .cd2-feed__title {
    color: var(--cd-accent);
}

/* Quick links */
.cd2-quick {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--cd-border);
}

.cd2-quick__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--cd-surface);
    text-decoration: none;
    color: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    transition: background 0.15s ease;
}

.cd2-quick__link:hover {
    background: var(--cd-surface-muted);
    text-decoration: none;
}

.cd2-quick__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--cd-surface-inset);
    color: var(--cd-ink-soft);
}

.cd2-quick__badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--cd-accent);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* Jobs sidebar */
.cd2-jobs {
    display: flex;
    flex-direction: column;
}

.cd2-job {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--cd-border);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.cd2-job:last-child {
    border-bottom: none;
}

.cd2-job:hover {
    background: var(--cd-surface-muted);
    text-decoration: none;
}

.cd2-job__title {
    margin: 0 0 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cd-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cd2-job__meta {
    margin: 0;
    font-size: 0.6875rem;
    color: var(--cd-ink-muted);
}

.cd2-empty {
    padding: 32px 20px;
    text-align: center;
}

.cd2-empty p {
    margin: 0 0 16px;
    font-size: 0.875rem;
    color: var(--cd-ink-muted);
}

/* Alerts in v2 */
body.company-dashboard-v2 .cd-alerts {
    margin-bottom: 20px;
}

/* Motion */
@media (prefers-reduced-motion: no-preference) {
    .cd2-hero,
    .cd2-kpi,
    .cd2-panel {
        animation: cd2-rise 0.45s ease both;
    }

    .cd2-kpi:nth-child(2) { animation-delay: 0.04s; }
    .cd2-kpi:nth-child(3) { animation-delay: 0.08s; }
    .cd2-kpi:nth-child(4) { animation-delay: 0.12s; }
    .cd2-panel:nth-child(2) { animation-delay: 0.06s; }
}

@keyframes cd2-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 1100px) {
    .cd2-bento {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .cd2-kpi {
        grid-column: span 3;
    }
}

@media (max-width: 900px) {
    .cd2-hero {
        grid-template-columns: 1fr;
    }

    .cd2-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .cd2-bento {
        grid-template-columns: 1fr 1fr;
    }

    .cd2-kpi,
    .cd2-kpi--wide {
        grid-column: span 1;
    }

    .cd2-kpi--wide {
        grid-column: 1 / -1;
    }

    .cd2-quick {
        grid-template-columns: 1fr;
    }

    .cd2-hero {
        padding: 20px 16px;
        border-radius: 16px;
    }

    .cd2-hero__actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .cd2-hero__btn {
        flex: none;
        width: 100%;
    }

    .cd2-tip__cta {
        display: none;
    }

    .cd2-panel__head {
        padding: 14px 16px;
    }

    .cd2-feed__link,
    .cd2-job,
    .cd2-quick__link,
    .cd2-tip {
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cd2-hero,
    .cd2-kpi,
    .cd2-panel {
        animation: none;
    }
}
