/*
 * Job Hub — unified jobs + crew view for the /plans landing page.
 * Replaces the old "Blueprints Vault" card. Shows:
 *   - a live "crew online" strip (who is active + on which job)
 *   - "My Jobs" (jobs you / your team own)
 *   - "Shared with me" (jobs you were invited to)
 *
 * Namespace: .jobhub-*  (do NOT confuse with the unrelated .crew-app /
 * body.crew-page field-worker feature in crew.css).
 * Palette follows the plans.css premium dark theme + Twilio navy accents.
 */

.jobhub-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    max-height: clamp(480px, calc(100vh - var(--app-header-height, 56px) - clamp(2.75rem, 5vw, 4.75rem)), 820px);
    overflow: hidden;
}

.jobhub-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: hidden;
    min-height: 0;
    flex: 1;
}

/* ------------------------------------------------------------------ */
/* Tab switcher                                                        */
/* ------------------------------------------------------------------ */
.jobhub-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.7rem 1rem 0;
    border-bottom: 1px solid var(--t-border, rgba(255, 255, 255, 0.08));
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.jobhub-tabs::-webkit-scrollbar { display: none; }

.jobhub-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 0.95rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.6));
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.jobhub-tab:hover {
    color: var(--t-text, #f6f7ff);
}

.jobhub-tab.is-active {
    color: var(--t-text, #f6f7ff);
    border-bottom-color: #60a5fa;
}

.jobhub-tab-count {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.02rem 0.42rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.7));
    min-width: 1.1rem;
    text-align: center;
}

.jobhub-tab.is-active .jobhub-tab-count {
    background: rgba(96, 165, 250, 0.22);
    color: #bfdbfe;
}

.jobhub-panels {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 1rem 1.15rem 1.15rem;
}

.jobhub-panel[hidden] { display: none; }

/* ------------------------------------------------------------------ */
/* Live crew strip                                                     */
/* ------------------------------------------------------------------ */
.jobhub-crew {
    border: 1px solid var(--t-border, rgba(255, 255, 255, 0.08));
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(16, 185, 129, 0.06), rgba(13, 17, 34, 0.4));
    padding: 0.85rem 1rem;
}

.jobhub-crew-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
}

.jobhub-crew-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--t-text, #f6f7ff);
    margin: 0;
}

.jobhub-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
    animation: jobhub-pulse 2s infinite;
    flex-shrink: 0;
}

@keyframes jobhub-pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
    70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.jobhub-crew-count {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.6));
}

.jobhub-crew-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.jobhub-crew-empty {
    font-size: 0.8rem;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.55));
    padding: 0.25rem 0;
}

.jobhub-crew-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.jobhub-crew-row:hover {
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.28);
    transform: translateY(-1px);
}

.jobhub-avatar {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(150deg, #1c273a, #121c2d);
    border: 1px solid rgba(255, 255, 255, 0.14);
    flex-shrink: 0;
    overflow: visible;
}

.jobhub-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.jobhub-avatar-status {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid #0d1122;
    background: #64748b;
}

.jobhub-avatar-status.is-online { background: #34d399; }
.jobhub-avatar-status.is-recent { background: #fbbf24; }

.jobhub-crew-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.jobhub-crew-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--t-text, #f6f7ff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jobhub-crew-sub {
    font-size: 0.74rem;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.62));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jobhub-crew-sub strong {
    color: #93c5fd;
    font-weight: 600;
}

.jobhub-crew-go {
    font-size: 0.7rem;
    font-weight: 600;
    color: #60a5fa;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.jobhub-crew-row:hover .jobhub-crew-go { opacity: 1; }

/* ------------------------------------------------------------------ */
/* Section headings + job lists                                        */
/* ------------------------------------------------------------------ */
.jobhub-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.55));
    margin: 0 0 0.6rem;
}

.jobhub-section-title .jobhub-pill {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: rgba(96, 165, 250, 0.16);
    color: #93c5fd;
    letter-spacing: 0;
}

.jobhub-jobs {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem;
}

.jobhub-job {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    min-width: 0;
    border: 1px solid var(--t-border, rgba(255, 255, 255, 0.08));
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    padding: 0.7rem 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.jobhub-job:hover {
    background: rgba(96, 165, 250, 0.08);
    border-color: rgba(96, 165, 250, 0.28);
    transform: translateY(-1px);
}

/* Left column: text + crew. Right column: thumbnail. */
.jobhub-job-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Plan thumbnail on the right of the card. */
.jobhub-job-thumb {
    flex-shrink: 0;
    /* Landscape rectangle (4:3-ish) instead of a tall skinny sliver. */
    width: 104px;
    height: 74px;
    align-self: center;
    border-radius: 9px;
    overflow: hidden;
    background: var(--t-surface-soft, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--t-border, rgba(255, 255, 255, 0.08));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.jobhub-job-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}
.jobhub-job-thumb.is-loading::after {
    content: "";
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid var(--t-border-medium, rgba(255,255,255,0.18));
    border-top-color: #60a5fa;
    animation: jobhub-spin 0.7s linear infinite;
}
.jobhub-job-thumb.is-empty::after {
    content: "";
    width: 22px; height: 22px;
    background: currentColor;
    color: var(--t-text-tertiary, rgba(148,163,184,0.5));
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M3 7l9-4 9 4v10l-9 4-9-4z'/><path d='M3 7l9 4 9-4'/><line x1='12' y1='11' x2='12' y2='21'/></svg>") center/contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M3 7l9-4 9 4v10l-9 4-9-4z'/><path d='M3 7l9 4 9-4'/><line x1='12' y1='11' x2='12' y2='21'/></svg>") center/contain no-repeat;
    opacity: 0.5;
}

.jobhub-job-top {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.jobhub-job-name {
    font-size: 0.92rem;
    font-weight: 650;
    color: var(--t-text, #f6f7ff);
    margin: 0;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Compact rename pencil — muted, centered in the row, brightens on hover. */
.jobhub-job-rename {
    flex: 0 0 auto;
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.1);
    color: rgba(226, 232, 240, 0.62);
    cursor: pointer;
    opacity: 0.72;
    transition: opacity .12s, background .12s, color .12s;
}
.jobhub-job:hover .jobhub-job-rename { opacity: 0.85; }
.jobhub-job-rename:hover { opacity: 1; background: rgba(148, 163, 184, 0.16); color: var(--t-text, #f6f7ff); }
.jobhub-rename-input {
    flex: 1;
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 650;
    line-height: 1.25;
    padding: 2px 6px;
    border: 1px solid rgba(126, 179, 255, 0.6);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.6);
    color: var(--t-text, #f6f7ff);
    outline: none;
}
[data-theme="light"] .jobhub-job-rename { color: #64748b; }
[data-theme="light"] .jobhub-rename-input { background: #fff; color: #0f172a; border-color: rgba(59, 130, 246, 0.5); }

.jobhub-status {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    flex-shrink: 0;
    background: rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
}

.jobhub-status--estimating { background: rgba(129, 140, 248, 0.18); color: #c7d2fe; }
.jobhub-status--bidding { background: rgba(251, 191, 36, 0.18); color: #fde68a; }
.jobhub-status--won { background: rgba(52, 211, 153, 0.18); color: #6ee7b7; }
.jobhub-status--active { background: rgba(96, 165, 250, 0.18); color: #bfdbfe; }
.jobhub-status--on_hold { background: rgba(148, 163, 184, 0.2); color: #e2e8f0; }
.jobhub-status--lost { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }
.jobhub-status--completed { background: rgba(45, 212, 191, 0.16); color: #99f6e4; }
.jobhub-status--archived { background: rgba(100, 116, 139, 0.2); color: #cbd5e1; }

.jobhub-job-sub {
    font-size: 0.75rem;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.58));
    margin: 0.28rem 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jobhub-job-bottom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.6rem;
}

/* Stacked collaborator avatars */
.jobhub-stack {
    display: flex;
    align-items: center;
}

.jobhub-stack .jobhub-avatar {
    width: 26px;
    height: 26px;
    font-size: 0.6rem;
    margin-left: -8px;
    border: 2px solid #0d1122;
}

.jobhub-stack .jobhub-avatar:first-child { margin-left: 0; }

.jobhub-stack-more {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.7));
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid #0d1122;
    margin-left: -8px;
}

.jobhub-job-online {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #6ee7b7;
}

.jobhub-job-online .jobhub-live-dot {
    width: 7px;
    height: 7px;
}

.jobhub-job-meta {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.5));
    flex-shrink: 0;
}

.jobhub-job-pending {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: #fcd34d;
}

/* States */
.jobhub-empty {
    font-size: 0.82rem;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.55));
    padding: 0.5rem 0;
}

.jobhub-retry-btn {
    margin-left: 0.4rem;
    padding: 0.25rem 0.7rem;
    border-radius: 7px;
    border: 1px solid var(--t-border-accent, rgba(96, 165, 250, 0.4));
    background: rgba(96, 165, 250, 0.14);
    color: var(--t-text, #e5edf8);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.jobhub-retry-btn:hover { background: rgba(96, 165, 250, 0.24); }

.jobhub-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--t-text-secondary, rgba(246, 247, 255, 0.55));
    padding: 1rem 0;
}

.jobhub-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: jobhub-spin 0.7s linear infinite;
}

@keyframes jobhub-spin { to { transform: rotate(360deg); } }

.jobhub-section[hidden] { display: none; }

/* ------------------------------------------------------------------ */
/* Light theme                                                         */
/* ------------------------------------------------------------------ */
[data-theme="light"] .jobhub-crew {
    background: linear-gradient(160deg, rgba(16, 185, 129, 0.06), #f2f6f9);
    border-color: #dee8f0;
}

[data-theme="light"] .jobhub-crew-row,
[data-theme="light"] .jobhub-job {
    background: #ffffff;
    border-color: #dee8f0;
}

[data-theme="light"] .jobhub-crew-row:hover,
[data-theme="light"] .jobhub-job:hover {
    background: #f2f6f9;
    border-color: #93c5fd;
}

[data-theme="light"] .jobhub-crew-title,
[data-theme="light"] .jobhub-crew-name,
[data-theme="light"] .jobhub-job-name {
    color: #121c2d;
}

[data-theme="light"] .jobhub-crew-sub,
[data-theme="light"] .jobhub-job-sub,
[data-theme="light"] .jobhub-section-title,
[data-theme="light"] .jobhub-empty,
[data-theme="light"] .jobhub-crew-count,
[data-theme="light"] .jobhub-crew-empty,
[data-theme="light"] .jobhub-job-meta {
    color: #566074;
}

[data-theme="light"] .jobhub-avatar-status {
    border-color: #ffffff;
}

[data-theme="light"] .jobhub-stack .jobhub-avatar,
[data-theme="light"] .jobhub-stack-more {
    border-color: #ffffff;
}

/* Tab switcher — counts (11 / 0) were washed-out in light mode */
[data-theme="light"] .jobhub-tabs {
    border-bottom-color: #dee8f0;
}

[data-theme="light"] .jobhub-tab {
    color: #566074;
}

[data-theme="light"] .jobhub-tab:hover,
[data-theme="light"] .jobhub-tab.is-active {
    color: #121c2d;
}

[data-theme="light"] .jobhub-tab.is-active {
    border-bottom-color: #2563eb;
}

[data-theme="light"] .jobhub-tab-count {
    background: #e6edf5;
    color: #334155;
}

[data-theme="light"] .jobhub-tab.is-active .jobhub-tab-count {
    background: rgba(37, 99, 235, 0.16);
    color: #1d4ed8;
}

/* ------------------------------------------------------------------ */
/* Embedded variant (inside the projects workspace / War Room)         */
/* ------------------------------------------------------------------ */
.jobhub-embed {
    border: 1px solid var(--t-border, rgba(255, 255, 255, 0.08));
    border-radius: 12px;
    background: rgba(13, 17, 34, 0.35);
    padding: 0.85rem 0.95rem;
    margin-bottom: 0.9rem;
}

.jobhub-embed .jobhub-section-title {
    margin-bottom: 0.55rem;
}

@media (max-width: 640px) {
    .jobhub-card { max-height: none; }
    .jobhub-body { padding: 0; gap: 0; }
    .jobhub-tabs { padding: 0.6rem 0.75rem 0; gap: 0.15rem; }
    .jobhub-tab { padding: 0.55rem 0.6rem; font-size: 0.82rem; gap: 0.35rem; }
    .jobhub-panels { padding: 0.85rem 0.75rem 1rem; }
    .jobhub-jobs { gap: 0.5rem; }
    .jobhub-job { padding: 0.75rem 0.8rem; }
    .jobhub-job-name { font-size: 0.9rem; white-space: normal; }
    .jobhub-crew-row { padding: 0.55rem 0.55rem; }
    .jobhub-crew-go { display: none; }
    .jobhub-job-bottom { flex-wrap: wrap; gap: 0.5rem; }
    .jobhub-job-meta { margin-left: 0; }
}
