/*
 * home.css — TPR-2 tenant home page
 *
 * Owns: /dashboard landing layout, widget cell grid, and the 6 home
 * widgets (KPI tiles, pending approvals, recent activity, compliance
 * snapshot, day-one checklist, recent uploads).
 *
 * Loaded after tenant-shell.css so that shell tokens
 * (--shell-surface, --shell-border, --topbar-height, …) cascade here.
 */

.home-page {
    padding: 24px 28px 48px;
    max-width: 1440px;
    margin: 0 auto;
    color: var(--text-primary, #e2e8f0);
}

.home-page__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.home-page__welcome {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary, #e2e8f0);
}

.home-page__greeting {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.home-page__tenant {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    margin-top: 4px;
}

.home-page__date {
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    font-variant-numeric: tabular-nums;
}

.home-page__grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}

.home-widget-cell {
    grid-column: span var(--home-cell-cols, 6);
    min-width: 0;
}

@media (max-width: 768px) {
    .home-widget-cell { grid-column: span 12; }
}

/* ── Shared widget chrome ──────────────────────────────────────────── */

.home-widget {
    background: rgba(21, 18, 46, 0.75);
    border: 1px solid var(--shell-border, rgba(196, 154, 60, 0.18));
    border-radius: 12px;
    padding: 16px 18px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 140px;
    overflow-wrap: break-word;
}

.home-widget__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.home-widget__title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary, #e2e8f0);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.home-widget__link,
.home-widget__subtitle {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
}

.home-widget__link {
    text-decoration: none;
}

.home-widget__link:hover {
    color: var(--color-primary, #6366f1);
}

.home-widget__body {
    flex: 1 1 auto;
    min-height: 0;
}

/* ── KPI tiles ─────────────────────────────────────────────────────── */

.home-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 768px) {
    .home-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

.home-kpi {
    background: rgba(15, 22, 41, 0.75);
    border: 1px solid var(--shell-border, rgba(196, 154, 60, 0.12));
    border-radius: 10px;
    padding: 14px 16px;
    min-height: 88px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.home-kpi__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #94a3b8);
}

.home-kpi__value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
    font-variant-numeric: tabular-nums;
}

.home-kpi__sub {
    font-size: 11px;
    color: var(--text-muted, #64748b);
}

/* ── IHD-2: Contextual Header ──────────────────────────────────────── */

.home-contextual-header {
    padding: 4px 0 6px;
}

.home-contextual-header__sentence {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.5;
}

/* ── IHD-2: KPI trend arrows + drill ──────────────────────────────── */

.home-kpi__trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    margin-top: 3px;
}

.home-kpi__trend--up   { color: var(--color-success, #22c55e); }
.home-kpi__trend--down { color: var(--color-danger,  #ef4444); }
.home-kpi__trend--flat { color: var(--text-muted,    #64748b); }

.home-kpi__trend-arrow { font-size: 12px; line-height: 1; }
.home-kpi__trend-delta { font-size: 11px; }

.home-kpi--clickable {
    cursor: pointer;
    text-decoration: none;
}

.home-kpi--clickable:hover,
.home-kpi--clickable:focus-visible {
    border-color: var(--shell-border-hover, rgba(196, 154, 60, 0.45));
    background: rgba(196, 154, 60, 0.06);
    outline: none;
}

/* ── Pending Approvals ─────────────────────────────────────────────── */

.home-approvals-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.home-approval {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(15, 22, 41, 0.45);
}

.home-approval__count {
    min-width: 28px;
    text-align: center;
}

.home-approval__label {
    font-size: 13px;
    color: var(--text-primary, #e2e8f0);
    text-decoration: none;
}

.home-approval__label:hover {
    color: var(--color-primary, #6366f1);
}

/* ── Recent Activity ───────────────────────────────────────────────── */

.home-activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.home-activity-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(196, 154, 60, 0.08);
}

.home-activity-item:last-child { border-bottom: none; }

.home-activity-item__actor {
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}

.home-activity-item__verb {
    color: var(--text-muted, #94a3b8);
}

.home-activity-item__target {
    color: var(--color-primary, #6366f1);
    font-family: var(--font-mono, monospace);
    font-size: 11px;
}

.home-activity-item__time {
    margin-left: auto;
    color: var(--text-muted, #64748b);
    font-size: 11px;
}

/* ── Compliance Snapshot ───────────────────────────────────────────── */

.home-compliance-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.home-compliance-item__head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
}

.home-compliance-item__name {
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}

.home-compliance-item__risk {
    font-size: 11px;
    color: var(--color-success, #22c55e);
}

.home-compliance-item__risk--alert {
    color: var(--color-warning, #f59e0b);
}

.home-compliance__bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    margin: 4px 0;
}

.home-compliance__bar-fill {
    height: 100%;
    transition: width 280ms ease;
}

.home-compliance__pct {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}

.home-compliance-item__drill {
    display: inline-block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--color-primary, #6366f1);
    text-decoration: none;
}

/* ── Day-One Checklist ─────────────────────────────────────────────── */

.home-widget--checklist { border-color: rgba(99, 102, 241, 0.35); }

.home-checklist__dismiss {
    background: none;
    border: none;
    color: var(--text-muted, #64748b);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.home-checklist__progress {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}

.home-checklist-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.home-checklist-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(15, 22, 41, 0.35);
    color: var(--text-primary, #e2e8f0);
}

.home-checklist-step--done {
    color: var(--color-success, #22c55e);
    text-decoration: line-through;
    opacity: 0.8;
}

.home-checklist-step__mark {
    width: 18px;
    text-align: center;
    font-family: var(--font-mono, monospace);
}

.home-checklist-step__detail {
    font-size: 11px;
    color: var(--text-muted, #64748b);
    margin-left: auto;
}

.home-checklist__banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    flex-wrap: wrap;
}

.home-checklist__banner--info   { background: rgba(59, 130, 246, 0.12); color: #93c5fd; border-left: 3px solid #3b82f6; }
.home-checklist__banner--amber  { background: rgba(245, 158, 11, 0.12); color: #fcd34d; border-left: 3px solid #f59e0b; }
.home-checklist__banner--danger { background: rgba(239, 68, 68, 0.12);  color: #fca5a5; border-left: 3px solid #ef4444; }

.home-checklist__banner-headline { font-weight: 600; }
.home-checklist__banner-subtext  { opacity: 0.85; margin-top: 2px; }
.home-checklist__banner-cta      { flex-shrink: 0; }

/* ── Recent Uploads ────────────────────────────────────────────────── */

.home-uploads-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.home-upload-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(15, 22, 41, 0.45);
}

.home-upload-item__name {
    flex: 1 1 auto;
    color: var(--text-primary, #e2e8f0);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-upload-item__name:hover { color: var(--color-primary, #6366f1); }

/* MR-5: enforce 44px minimum tap target on all widget links and file name links (WCAG 2.5.5) */
@media (max-width: 768px) {
    .home-widget__link,
    .home-widget__header-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    .home-upload-item__name {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    /* MR-5: dismiss button on DayOneChecklist widget (19x18 at runtime) */
    .home-checklist__dismiss {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
}

/* MR-5: P8 sub-12px metadata text in home dashboard — activity timestamps (11px),
   KPI trend deltas (11px) — bump to 12px minimum on mobile (WCAG 1.4.4) */
@media (max-width: 768px) {
    .home-activity-item__time,
    .home-kpi__trend-delta {
        font-size: 12px;
    }
}

/* ── Light theme overrides ─────────────────────────────────────────── */

[data-theme="light"] .home-widget {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.09);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

[data-theme="light"] .home-kpi {
    background: #F7F8FA;
    border-color: rgba(0, 0, 0, 0.09);
}

[data-theme="light"] .home-kpi--clickable:hover,
[data-theme="light"] .home-kpi--clickable:focus-visible {
    background: #EEF2FF;
    border-color: rgba(0, 137, 123, 0.30);
}

[data-theme="light"] .home-approval {
    background: #F7F8FA;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 8px;
}

[data-theme="light"] .home-activity-item {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .home-compliance__bar {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .home-checklist-step {
    background: #F7F8FA;
    border: 1px solid rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .home-checklist__banner--info {
    background: rgba(59, 130, 246, 0.10);
    color: #1D4ED8;
    border-left-color: #3B82F6;
}

[data-theme="light"] .home-checklist__banner--amber {
    background: rgba(245, 158, 11, 0.10);
    color: #B45309;
    border-left-color: #F59E0B;
}

[data-theme="light"] .home-checklist__banner--danger {
    background: rgba(239, 68, 68, 0.10);
    color: #B91C1C;
    border-left-color: #EF4444;
}

[data-theme="light"] .home-upload-item {
    background: #F7F8FA;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 6px;
}

[data-theme="light"] .home-widget--checklist {
    border-color: rgba(99, 102, 241, 0.25);
}

.home-upload-item__status { flex-shrink: 0; }

/* HDD-1.11: Home dashboard responsive grid — spec §7.5
   MR-130: canonical breakpoints 1024px and 768px (was 1023px and 767px — C2 non-canonical) */
@media (max-width: 1024px) {
    .home-page__grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .home-widget-cell[class*="home-widget--cols-"] {
        grid-column: span 6;
    }
}
@media (max-width: 768px) {
    .home-page__grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .home-widget-cell[class*="home-widget--cols-"] {
        grid-column: span 1;
    }
    .home-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
    /* MR-130: widget view toggle — mobile card below 768px (was 767px, non-canonical) */
    .widget-full-view  { display: none; }
    .widget-mobile-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
}
@media (min-width: 769px) {
    /* MR-130: full view above 768px (use 769px to avoid conflict with ≤768px above) */
    .widget-full-view  { display: block; }
    .widget-mobile-card { display: none; }
}

/* ── FLW-3 (PRD-043 §5 FLW-B): Login Details widget ───────────────────── */

.ldw-hint {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted, rgba(237, 232, 219, 0.58));
    margin: 0;
}

.ldw-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ldw-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, rgba(237, 232,219, 0.38));
}

.ldw-value-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ldw-value {
    font-family: var(--font-mono, "JetBrains Mono", monospace);
    font-size: 13px;
    color: var(--text-primary, #ede8db);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 4px 8px;
    word-break: break-all;
}

.ldw-copy-btn {
    flex-shrink: 0;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--shell-border, rgba(196, 154, 60, 0.25));
    background: transparent;
    color: var(--color-teal, #00b4a2);
    cursor: pointer;
    min-height: 32px;
}

.ldw-copy-btn:hover { background: rgba(0, 180, 162, 0.1); }
.ldw-copy-btn:focus-visible { outline: 2px solid var(--color-teal, #00b4a2); outline-offset: 2px; }

.ldw-actions { margin-top: 4px; }

.ldw-status {
    font-size: 12px;
    color: var(--color-teal, #00b4a2);
    min-height: 16px;
}

[data-theme="light"] .ldw-value {
    background: rgba(0, 0, 0, 0.05);
    color: #0f172a;
}
