/* ================================================================
   PERSONAL ERP D4.2 — HOME & WORKSPACE REBUILD
   Richer personal dashboard while preserving Workspace Builder.
   ================================================================ */

.workspace-home-shell {
    display: grid;
    gap: 12px;
}

.workspace-home-hero {
    position: relative;
    display: grid;
    gap: 14px;
    overflow: hidden;
    padding: 18px;
    border: 1px solid var(--ui-border);
    border-radius: 22px;
    background:
        radial-gradient(
            circle at 92% 8%,
            color-mix(in srgb, var(--ui-primary) 12%, transparent),
            transparent 28%
        ),
        linear-gradient(
            135deg,
            color-mix(in srgb, var(--ui-primary-soft) 72%, var(--ui-surface)),
            var(--ui-surface) 52%
        );
    box-shadow: var(--ui-shadow-md);
}

.workspace-home-hero::after {
    position: absolute;
    top: -88px;
    right: -70px;
    width: 210px;
    height: 210px;
    border: 26px solid color-mix(in srgb, var(--ui-primary) 5%, transparent);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.workspace-home-hero-copy,
.workspace-home-actions,
.workspace-home-pulse {
    position: relative;
    z-index: 1;
}

.workspace-home-hero h1 {
    margin: 3px 0 5px;
    color: var(--ui-text);
    font-size: clamp(2.15rem, 7vw, 2.65rem);
    line-height: 1;
    letter-spacing: -.045em;
}

.workspace-home-intro {
    max-width: 650px;
    margin: 0;
    color: var(--ui-text-muted);
    font-size: .92rem;
    line-height: 1.5;
}

.workspace-home-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.workspace-home-customize,
.workspace-home-create {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 45px;
    padding: 0 12px;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.workspace-home-customize {
    background: color-mix(in srgb, var(--ui-surface) 86%, transparent);
    color: var(--ui-text);
}

.workspace-home-create {
    border-color: var(--ui-primary);
    background: var(--ui-primary);
    color: #fff;
}

.workspace-home-customize span,
.workspace-home-create span {
    font-size: 1.05rem;
}

.workspace-home-customize strong,
.workspace-home-create strong {
    font-size: .86rem;
}

.workspace-home-pulse {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.workspace-pulse-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    min-width: 0;
    min-height: 54px;
    padding: 7px 8px;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--ui-surface) 84%, transparent);
    color: var(--ui-text);
    text-decoration: none;
    backdrop-filter: blur(6px);
}

.workspace-pulse-item > span {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    border-radius: 9px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: .82rem;
    font-weight: 900;
}

.workspace-pulse-item small,
.workspace-pulse-item strong {
    display: block;
}

.workspace-pulse-item small {
    overflow: hidden;
    color: var(--ui-text-soft);
    font-size: .67rem !important;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-pulse-item strong {
    margin-top: 1px;
    color: var(--ui-text);
    font-size: 1rem;
    line-height: 1;
}

.workspace-pulse-item.attention.has-value > span,
.workspace-pulse-item.inbox.has-value > span {
    background: var(--ui-warning-soft);
    color: var(--ui-warning);
}

/* ----------------------------------------------------------------
   Dashboard hierarchy
   ---------------------------------------------------------------- */

.workspace-home-dashboard {
    gap: 10px !important;
}

.workspace-home-dashboard .workspace-widget {
    position: relative;
    overflow: hidden;
    padding: 14px !important;
    border-radius: 17px !important;
    box-shadow: var(--ui-shadow-sm);
}

.workspace-home-dashboard .workspace-widget::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    border-radius: 3px;
    background: transparent;
    content: "";
}

.workspace-home-dashboard .workspace-type-tasks::before {
    background: var(--ui-primary);
}

.workspace-home-dashboard .workspace-type-events::before {
    background: var(--ui-purple);
}

.workspace-home-dashboard .workspace-type-projects::before {
    background: var(--ui-primary);
}

.workspace-home-dashboard .workspace-type-documents::before {
    background: var(--ui-warning);
}

.workspace-home-dashboard .workspace-type-family_lists::before {
    background: var(--ui-success);
}

.workspace-home-dashboard .workspace-type-inbox::before {
    background: var(--ui-purple);
}

.workspace-home-dashboard .workspace-widget-header {
    align-items: center;
    margin-bottom: 10px !important;
}

.workspace-widget-heading-copy {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.workspace-widget-heading-copy > div {
    min-width: 0;
}

.workspace-widget-kind-icon {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border-radius: 10px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: .95rem;
    font-weight: 900;
}

.workspace-type-events .workspace-widget-kind-icon,
.workspace-type-inbox .workspace-widget-kind-icon {
    background: color-mix(in srgb, var(--ui-purple) 12%, transparent);
    color: var(--ui-purple);
}

.workspace-type-documents .workspace-widget-kind-icon {
    background: var(--ui-warning-soft);
    color: var(--ui-warning);
}

.workspace-type-family_lists .workspace-widget-kind-icon {
    background: var(--ui-success-soft);
    color: var(--ui-success);
}

.workspace-type-attention .workspace-widget-kind-icon {
    background: var(--ui-danger-soft);
    color: var(--ui-danger);
}

.workspace-widget-heading-copy .eyebrow {
    margin: 0 0 2px;
    font-size: .65rem !important;
    letter-spacing: .065em;
}

.workspace-home-dashboard .workspace-widget-header h2 {
    margin: 0;
    overflow: hidden;
    color: var(--ui-text);
    font-size: 1rem !important;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-widget-header-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.workspace-widget-count {
    display: grid;
    min-width: 29px;
    height: 29px;
    place-items: center;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: .72rem;
    font-weight: 900;
}

.workspace-widget-open {
    display: grid;
    min-height: 29px;
    place-items: center;
    padding: 0 8px;
    border-radius: 8px;
    color: var(--ui-primary);
    font-size: .73rem;
    font-weight: 850;
    text-decoration: none;
}

.workspace-home-dashboard .workspace-widget-settings {
    width: 29px;
    height: 29px;
    flex-basis: 29px;
    border: 0;
    background: var(--ui-bg-subtle);
}

/* Attention is a compact horizontal priority lane */
.workspace-home-dashboard .workspace-type-attention {
    border-color: color-mix(in srgb, var(--ui-primary) 12%, var(--ui-border));
    background:
        linear-gradient(
            135deg,
            color-mix(in srgb, var(--ui-primary-soft) 46%, var(--ui-surface)),
            var(--ui-surface) 62%
        );
}

.workspace-home-dashboard .workspace-type-attention .workspace-attention-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 7px;
}

.workspace-home-dashboard .workspace-attention-item {
    min-height: 50px !important;
    padding: 7px 9px;
    background: color-mix(in srgb, var(--ui-surface) 86%, transparent);
}

.workspace-home-dashboard .workspace-attention-item strong {
    width: 34px;
    height: 34px;
    font-size: .95rem;
}

.workspace-home-dashboard .workspace-attention-item span {
    font-size: .82rem;
}

.workspace-home-dashboard .workspace-calm-state {
    min-height: 50px;
    padding: 8px 10px;
}

.workspace-home-dashboard .workspace-calm-state > span {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
}

.workspace-home-dashboard .workspace-calm-state strong {
    font-size: .84rem;
}

.workspace-home-dashboard .workspace-calm-state small {
    font-size: .73rem !important;
}

/* Object lists look like a workspace, not a settings table */
.workspace-home-dashboard .workspace-object-list {
    gap: 4px;
}

.workspace-home-dashboard .workspace-object-list > a {
    min-height: 48px;
    padding: 6px 7px;
    border-radius: 10px;
}

.workspace-home-dashboard .workspace-object-list > a:hover {
    background: var(--ui-surface-soft);
}

.workspace-home-dashboard .workspace-object-icon {
    width: 31px;
    height: 31px;
    border-radius: 9px;
}

.workspace-home-dashboard .workspace-object-list strong {
    font-size: .83rem !important;
}

.workspace-home-dashboard .workspace-object-list small {
    margin-top: 2px;
    font-size: .71rem !important;
}

/* Events get a slightly more distinct surface */
.workspace-home-dashboard .workspace-type-events {
    background:
        linear-gradient(
            150deg,
            color-mix(in srgb, var(--ui-purple) 5%, var(--ui-surface)),
            var(--ui-surface) 60%
        );
}

.workspace-home-dashboard .workspace-type-events .workspace-object-list > a:first-child {
    border-color: color-mix(in srgb, var(--ui-purple) 14%, var(--ui-border));
    background: color-mix(in srgb, var(--ui-purple) 6%, var(--ui-surface));
}

/* Overview modules are intentionally compact when empty */
.workspace-empty-compact {
    display: grid;
    min-height: 64px !important;
    place-items: center;
    align-content: center;
    gap: 2px;
    padding: 10px !important;
    border: 0 !important;
    background: var(--ui-surface-soft);
}

.workspace-empty-compact .workspace-empty-dot {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 50%;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-soft);
    font-size: 1rem;
}

.workspace-empty-compact strong {
    color: var(--ui-text-muted);
    font-size: .79rem;
}

.workspace-empty-compact small {
    color: var(--ui-text-soft);
    font-size: .7rem !important;
}

/* Quick actions: compact utility rail rather than another huge card */
.workspace-home-dashboard .workspace-type-quick_actions {
    padding: 10px !important;
    background: color-mix(in srgb, var(--ui-surface) 82%, var(--ui-bg));
}

.workspace-home-dashboard .workspace-type-quick_actions .workspace-widget-header {
    margin-bottom: 7px !important;
}

.workspace-home-dashboard .workspace-quick-actions {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
}

.workspace-home-dashboard .workspace-quick-actions > a {
    min-height: 52px !important;
    gap: 3px;
    padding: 6px;
    border: 0;
    background: var(--ui-surface);
}

.workspace-home-dashboard .workspace-quick-actions > a span {
    font-size: 1rem;
}

.workspace-home-dashboard .workspace-quick-actions > a strong {
    font-size: .72rem;
}

.workspace-home-dashboard .workspace-widget-footer {
    margin-top: 7px;
    padding-top: 7px;
    font-size: .7rem !important;
}

/* ----------------------------------------------------------------
   Home footer tools
   ---------------------------------------------------------------- */

.workspace-home-footer-tools {
    display: grid;
    gap: 7px;
    margin-top: 2px;
}

.workspace-home-footer-tools > a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 9px 10px;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    background: var(--ui-surface);
    color: var(--ui-text);
    text-decoration: none;
}

.workspace-home-footer-tools > a > span {
    grid-row: 1 / span 2;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 9px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: .9rem;
}

.workspace-home-footer-tools strong,
.workspace-home-footer-tools small {
    display: block;
}

.workspace-home-footer-tools strong {
    font-size: .8rem;
}

.workspace-home-footer-tools small {
    color: var(--ui-text-muted);
    font-size: .7rem !important;
}

/* ----------------------------------------------------------------
   Non-home workspace pages keep the same builder semantics but receive
   the improved widget header language too.
   ---------------------------------------------------------------- */

.workspace-dashboard:not(.workspace-home-dashboard) .workspace-widget-heading-copy {
    gap: 8px;
}

.workspace-dashboard:not(.workspace-home-dashboard) .workspace-widget-kind-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
}

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */

@media (max-width: 649px) {
    .workspace-home-shell {
        gap: 9px;
    }

    .workspace-home-hero {
        gap: 12px;
        padding: 15px;
        border-radius: 18px;
    }

    .workspace-home-hero h1 {
        font-size: 2.2rem;
    }

    .workspace-home-intro {
        font-size: .88rem;
    }

    /* Mobile uses the global FAB as create. Keep only customization. */
    .workspace-home-actions {
        grid-template-columns: 1fr;
    }

    .workspace-home-create {
        display: none;
    }

    .workspace-home-customize {
        justify-self: start;
        min-height: 40px;
        padding: 0 11px;
    }

    .workspace-home-pulse {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
    }

    .workspace-pulse-item {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 3px;
        min-height: 64px;
        padding: 6px 3px;
        text-align: center;
    }

    .workspace-pulse-item > span {
        width: 27px;
        height: 27px;
        font-size: .75rem;
    }

    .workspace-pulse-item small {
        max-width: 70px;
        font-size: .61rem !important;
    }

    .workspace-pulse-item strong {
        font-size: .9rem;
    }

    .workspace-home-dashboard .workspace-widget {
        padding: 12px !important;
        border-radius: 15px !important;
    }

    .workspace-widget-kind-icon {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .workspace-home-dashboard .workspace-widget-header h2 {
        font-size: .96rem !important;
    }

    .workspace-widget-open {
        display: none;
    }

    .workspace-home-dashboard .workspace-type-attention .workspace-attention-grid {
        grid-template-columns: 1fr;
    }

    .workspace-home-dashboard .workspace-attention-item {
        min-height: 47px !important;
    }

    .workspace-home-dashboard .workspace-calm-state {
        min-height: 48px;
    }

    .workspace-home-dashboard .workspace-object-list > a {
        min-height: 46px;
    }

    .workspace-home-dashboard .workspace-quick-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .workspace-home-dashboard .workspace-quick-actions > a {
        min-height: 48px !important;
    }

    .workspace-home-footer-tools {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 380px) {
    .workspace-home-hero {
        padding: 13px;
    }

    .workspace-home-pulse {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .workspace-pulse-item {
        grid-template-columns: auto minmax(0, 1fr);
        justify-items: stretch;
        min-height: 48px;
        padding: 6px 7px;
        text-align: left;
    }
}

@media (min-width: 650px) {
    .workspace-home-hero {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .workspace-home-pulse {
        grid-column: 1 / -1;
    }

    .workspace-home-actions {
        grid-template-columns: auto auto;
        justify-self: end;
    }

    .workspace-home-customize,
    .workspace-home-create {
        min-width: 124px;
    }

    .workspace-home-footer-tools {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1040px) {
    .workspace-home-shell {
        gap: 11px;
    }

    .workspace-home-hero {
        padding: 19px 20px;
    }

    .workspace-home-hero h1 {
        font-size: 2.6rem;
    }

    .workspace-home-intro {
        font-size: .9rem;
    }

    .workspace-home-pulse {
        max-width: 720px;
    }

    .workspace-home-dashboard .workspace-widget {
        min-height: 0;
    }

    .workspace-home-dashboard .workspace-type-tasks,
    .workspace-home-dashboard .workspace-type-events {
        min-height: 210px;
    }

    .workspace-home-dashboard .workspace-type-projects,
    .workspace-home-dashboard .workspace-type-documents,
    .workspace-home-dashboard .workspace-type-family_lists,
    .workspace-home-dashboard .workspace-type-inbox {
        min-height: 160px;
    }
}
