/*
 * cockpit-rep-home.css — styling for the rep "Aujourd'hui" home.
 *
 * Plain language: this is the morning-driver page for a sales rep.
 * Quiet single-column layout, generous spacing, no tables. Default
 * density is Simple. The page uses BEM class names so a tutorial
 * engine (banked) can target every interactive element by class.
 *
 * Phase 4 / Agent 4A. Lead sheet §13.
 */

/* ============================================================
 * Layout — single 720px column, generous whitespace.
 * ============================================================ */

.cockpit-rep-home {
    /* Plain language: the page is a single column, max 720px wide,
       centred. Matches Jean home width so reps and managers feel
       they're in the same product. */
    width: 100%;
    min-height: calc(100vh - 64px);
    padding: 32px 24px 120px;  /* bottom padding leaves room for the
                                  Vite-fait floating button */
    background: var(--bg, #fafaf7);
    color: var(--ink, #1a1a18);
    font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
    box-sizing: border-box;
}

.cockpit-rep-home__column {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* ============================================================
 * Salutation strip
 * ============================================================ */

.cockpit-rep-home__salutation {
    /* Plain language: the warm "Bonjour Sophie" + alert count. Big
       text so it's the first thing the rep reads. */
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cockpit-rep-home__salutation-title {
    font-size: 28px;
    line-height: 1.2;
    margin: 0;
    font-weight: 600;
    color: var(--ink, #1a1a18);
}

.cockpit-rep-home__salutation-line {
    font-size: 16px;
    line-height: 1.5;
    margin: 0;
    color: var(--ink-soft, #4a4a45);
}

/* ============================================================
 * Refresh row + button
 * ============================================================ */

.cockpit-rep-home__refresh-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

.cockpit-rep-home__refresh-button {
    /* Big French primary button. Tooltip on hover (title attr on the
       parent .cockpit-rep-home__refresh-row could read "Force la
       relecture des alertes" but we keep it inline on the button so
       the rep doesn't hunt). */
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--accent, #2563eb);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.06s ease;
}

.cockpit-rep-home__refresh-button:hover {
    background: var(--accent-strong, #1d4fc4);
}

.cockpit-rep-home__refresh-button:active {
    transform: translateY(1px);
}

.cockpit-rep-home__refresh-button[disabled] {
    opacity: 0.7;
    cursor: progress;
}

.cockpit-rep-home__refresh-button--loading {
    background: var(--accent-soft, #5482e0);
}

.cockpit-rep-home__refresh-stamp {
    font-size: 13px;
    color: var(--ink-soft, #6c6c66);
}

.cockpit-rep-home__spinner {
    /* Plain French loading spinner (the screen-reader text comes from
       the surrounding sr-only span). */
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cockpit-rep-home-spin 0.7s linear infinite;
}

@keyframes cockpit-rep-home-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
 * Inbox stack
 * ============================================================ */

.cockpit-rep-home__inbox {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cockpit-rep-home__inbox-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Empty state — soft French nudge + CTA. */
.cockpit-rep-home__empty-state {
    background: var(--surface, #fff);
    border: 1px dashed var(--rule, #d8d8d2);
    border-radius: 12px;
    padding: 28px 24px;
    text-align: center;
    color: var(--ink-soft, #6c6c66);
}

.cockpit-rep-home__empty-headline {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink, #1a1a18);
}

.cockpit-rep-home__empty-subline {
    margin: 0 0 16px;
    font-size: 14px;
}

.cockpit-rep-home__empty-cta {
    display: inline-block;
    padding: 8px 18px;
    background: var(--ink, #1a1a18);
    color: #fff;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
}

.cockpit-rep-home__empty-cta:hover {
    background: var(--ink-soft, #2a2a25);
    color: #fff;
}

/* Loading skeleton */
.cockpit-rep-home__inbox-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cockpit-rep-home__skeleton-row {
    display: block;
    height: 64px;
    background: linear-gradient(90deg,
        var(--rule, #f0f0eb) 25%,
        var(--rule-strong, #e6e6df) 50%,
        var(--rule, #f0f0eb) 75%);
    background-size: 200% 100%;
    border-radius: 10px;
    animation: cockpit-rep-home-shimmer 1.4s ease-in-out infinite;
}

@keyframes cockpit-rep-home-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error state */
.cockpit-rep-home__inbox--error {
    background: var(--surface, #fff);
}

.cockpit-rep-home__error-state {
    background: var(--surface, #fff);
    border: 1px solid var(--danger-soft, #f6c6c2);
    border-radius: 12px;
    padding: 24px;
    color: var(--ink, #1a1a18);
}

.cockpit-rep-home__error-state p {
    margin: 0 0 12px;
}

.cockpit-rep-home__error-retry {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--ink, #1a1a18);
    border-radius: 8px;
    cursor: pointer;
    color: var(--ink, #1a1a18);
    font-weight: 500;
}

/* Nudge card — the alert from the cron */
.cockpit-rep-home__nudge-card {
    background: var(--surface, #fff);
    border: 1px solid var(--rule, #e8e8e2);
    border-left-width: 4px;
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: border-color 0.16s ease, transform 0.08s ease;
}

.cockpit-rep-home__nudge-card:hover {
    border-color: var(--ink-soft, #6c6c66);
}

/* Severity colors. Red = action urgente. Amber = à surveiller.
   Neutre = informationnel. */
.cockpit-rep-home__nudge-card--red {
    border-left-color: #d63a3a;
}

.cockpit-rep-home__nudge-card--amber {
    border-left-color: #d6892e;
}

.cockpit-rep-home__nudge-card--neutral {
    border-left-color: #6c6c66;
}

.cockpit-rep-home__nudge-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cockpit-rep-home__nudge-card-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.cockpit-rep-home__nudge-card--red .cockpit-rep-home__nudge-card-icon {
    background: #d63a3a;
}

.cockpit-rep-home__nudge-card--amber .cockpit-rep-home__nudge-card-icon {
    background: #d6892e;
}

.cockpit-rep-home__nudge-card--neutral .cockpit-rep-home__nudge-card-icon {
    background: #6c6c66;
}

.cockpit-rep-home__nudge-card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    color: var(--ink, #1a1a18);
}

.cockpit-rep-home__nudge-card-age {
    font-size: 12px;
    color: var(--ink-soft, #6c6c66);
    background: var(--rule, #f0f0eb);
    padding: 2px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.cockpit-rep-home__nudge-card-body {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink-soft, #4a4a45);
}

.cockpit-rep-home__nudge-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cockpit-rep-home__nudge-action {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    background: var(--ink, #1a1a18);
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.16s ease;
}

.cockpit-rep-home__nudge-action:hover {
    background: var(--ink-soft, #2a2a25);
    color: #fff;
}

.cockpit-rep-home__nudge-action--secondary {
    background: transparent;
    color: var(--ink, #1a1a18);
    border: 1px solid var(--rule-strong, #d8d8d2);
}

.cockpit-rep-home__nudge-action--secondary:hover {
    background: var(--rule, #f0f0eb);
    color: var(--ink, #1a1a18);
}

/* ============================================================
 * Suggested action card
 * ============================================================ */

.cockpit-rep-home__suggested {
    background: var(--surface-soft, #f5f5ee);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============================================================
 * Pinned deals
 * ============================================================ */

.cockpit-rep-home__pinned {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cockpit-rep-home__section-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--ink, #1a1a18);
}

.cockpit-rep-home__pinned-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cockpit-rep-home__pinned-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface, #fff);
    border: 1px solid var(--rule, #e8e8e2);
    border-radius: 8px;
    color: var(--ink, #1a1a18);
    text-decoration: none;
    align-items: center;
    transition: border-color 0.14s ease;
}

.cockpit-rep-home__pinned-row:hover {
    border-color: var(--ink-soft, #6c6c66);
}

.cockpit-rep-home__pinned-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cockpit-rep-home__pinned-stage {
    font-size: 12px;
    color: var(--ink-soft, #6c6c66);
    background: var(--rule, #f0f0eb);
    padding: 2px 8px;
    border-radius: 999px;
}

.cockpit-rep-home__pinned-money {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--ink-soft, #4a4a45);
}

.cockpit-rep-home__pinned-empty {
    margin: 0;
    padding: 16px;
    background: var(--surface, #fff);
    border: 1px dashed var(--rule, #d8d8d2);
    border-radius: 10px;
    color: var(--ink-soft, #6c6c66);
    font-size: 13px;
}

/* ============================================================
 * Toast (local fallback when window.Toast is missing)
 * ============================================================ */

.cockpit-rep-home__toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink, #1a1a18);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    z-index: 9000;
    animation: cockpit-rep-home-toast-in 0.2s ease;
}

.cockpit-rep-home__toast--success { background: #2c7a4a; }
.cockpit-rep-home__toast--error { background: #b53b3b; }

.cockpit-rep-home__toast.is-leaving {
    animation: cockpit-rep-home-toast-out 0.4s ease forwards;
}

@keyframes cockpit-rep-home-toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes cockpit-rep-home-toast-out {
    to { opacity: 0; transform: translate(-50%, 8px); }
}

/* ============================================================
 * Accessibility helpers
 * ============================================================ */

.cockpit-rep-home__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ============================================================
 * Density-aware overrides — Standard adds two more rows of detail
 * per nudge card. Expert exposes the raw cron source.
 * ============================================================ */

.cockpit-density-standard .cockpit-rep-home__nudge-card-body {
    -webkit-line-clamp: unset;
}

.cockpit-density-expert .cockpit-rep-home__nudge-card::after {
    /* Expert mode shows the raw cron source as a tiny chip so a
       power user can debug what fired the alert. Hidden by default
       in Simple / Standard. */
    content: attr(data-card-kind);
    display: inline-block;
    font-size: 10px;
    color: var(--ink-soft, #6c6c66);
    background: var(--rule, #f0f0eb);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    align-self: flex-start;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================================
 * Responsive — stacks on mobile.
 * ============================================================ */

@media (max-width: 640px) {
    .cockpit-rep-home {
        padding: 20px 14px 100px;
    }
    .cockpit-rep-home__salutation-title { font-size: 24px; }
    .cockpit-rep-home__pinned-row {
        grid-template-columns: 1fr auto;
    }
    .cockpit-rep-home__pinned-money {
        grid-column: span 2;
        font-size: 12px;
    }
}
