
/* app/static/design.css */

/* ==========================================================================
   1. Design System & Variables
   ========================================================================== */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --font-display: 'Plus Jakarta Sans', var(--font-sans);
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Light Theme */
    --bg-primary: #FAFAF9;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F4F4F3;

    --text-primary: #1A1A1A;
    --text-secondary: #757575;
    --text-tertiary: #9C9B99;

    --border-primary: #EDEDED;
    --border-secondary: #F4F4F3;

    /* Brand */
    --brand-cyan: #01B6BD;
    --brand-blue: #0690D9;
    --brand-tint: #D0F2F3;
    --brand-mist: #EDEDED;
    --brand-slate: #9C9B99;
    --brand-smoke: #757575;
    --brand-ink: #000000;
    --brand-gradient: linear-gradient(90deg, var(--brand-blue) 0%, var(--brand-cyan) 100%);

    --accent-primary: var(--brand-blue);
    --accent-primary-hover: var(--brand-cyan);
    --accent-secondary: #10B981; /* emerald-500, unrelated success color, kept as-is */

    --shadow-sm: 0 1px 2px 0 rgba(6,45,54,0.06), 0 1px 3px 0 rgba(6,45,54,0.06);
    --shadow-md: 0 4px 12px -2px rgba(6,45,54,0.10), 0 2px 6px -2px rgba(1,182,189,0.08);
    --shadow-lg: 0 12px 28px -6px rgba(6,45,54,0.14), 0 4px 10px -4px rgba(1,182,189,0.12);
    --shadow-xl: 0 20px 40px -8px rgba(6,45,54,0.18), 0 8px 16px -6px rgba(1,182,189,0.14);
    --shadow-glow: 0 0 0 1px rgba(6,144,217,0.10), 0 8px 24px -6px rgba(1,182,189,0.35);

    --radius-sm: 0.375rem; /* 6px */
    --radius-md: 0.5rem; /* 8px */
    --radius-lg: 0.75rem; /* 12px */
    --radius-xl: 1rem; /* 16px */

    --ease-brand: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   2. Base & Typography
   ========================================================================== */

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.font-tabular, .tabular-nums {
    font-variant-numeric: tabular-nums;
}

::selection {
    background: var(--brand-tint);
    color: #023A44;
}

/* Brand focus ring, used in place of Tailwind's default indigo/blue ring so
   every focusable control matches the palette without per-element classes. */
:focus-visible {
    outline: 2px solid var(--brand-blue);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ==========================================================================
   3. Skip Link (WCAG 2.4.1)
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: var(--brand-gradient);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: top 0.15s var(--ease-brand);
}
.skip-link:focus {
    top: 1rem;
}

/* ==========================================================================
   4. Dashboard Layout
   ========================================================================== */

.card-body--flush {
    padding: 0;
}

/* ==========================================================================
   5. Card Component
   ========================================================================== */

.card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s var(--ease-brand), transform 0.25s var(--ease-brand), border-color 0.25s var(--ease-brand);
    display: flex;
    flex-direction: column;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: #E3F6F7;
}

.card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-secondary);
}

.card-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
}

.card-body {
    padding: 1.25rem;
    flex-grow: 1;
}

.card-footer {
    padding: 1rem 1.25rem;
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-secondary);
    border-bottom-left-radius: var(--radius-xl);
    border-bottom-right-radius: var(--radius-xl);
}

/* ==========================================================================
   6. Attention Feed
   ========================================================================== */

.attention-feed-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 640px) {
    .attention-feed-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .attention-feed-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.attention-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
    border-left-width: 4px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s var(--ease-brand), transform 0.2s var(--ease-brand);
    overflow: hidden;
    position: relative;
}

.attention-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.attention-card--critical { border-left-color: #DC2626; } /* red-600 */
.attention-card--high     { border-left-color: #D97706; } /* amber-600 */
.attention-card--medium   { border-left-color: #045C8C; } /* deep brand blue */
.attention-card--low      { border-left-color: #0A6468; } /* deep brand cyan */

/* Refined status label: a small dot carries the color, the text stays a
   legible neutral — avoids the "pastel pill everywhere" look where every
   card is a different bright background. */
.attention-card__tag {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}
.attention-card__tag-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag--critical .attention-card__tag-dot,
.tag--critical { color: #B91C1C; }
.tag--critical .attention-card__tag-dot { background-color: #DC2626; }
.tag--high, .tag--high .attention-card__tag-dot { color: #B45309; }
.tag--high .attention-card__tag-dot { background-color: #D97706; }
.tag--medium, .tag--medium .attention-card__tag-dot { color: #045C8C; }
.tag--medium .attention-card__tag-dot { background-color: #045C8C; }
.tag--low, .tag--low .attention-card__tag-dot { color: #0A6468; }
.tag--low .attention-card__tag-dot { background-color: #0A6468; }

/* Stagger the attention feed + kanban card entrance so the page feels
   choreographed rather than dumped on screen at once. Capped so a long list
   doesn't leave late cards waiting a visible half-second. */
.attention-feed-grid > *,
.pipeline-card,
.kpi-tile {
    animation: fadeInUp 0.4s var(--ease-brand) both;
    animation-delay: calc(var(--stagger, 0) * 40ms);
}

/* The entrance animation above promotes every .kpi-tile AND every
   .pipeline-card to its own stacking context (an animation naming a
   keyframe that touches transform/opacity does this permanently, not just
   while running) — so a dropdown's z-index (e.g. the Issues tile's
   <details> panel) only wins against elements inside the same stacking
   context. Two separate fixes are needed:
   1. Raise the open tile above its *sibling* kpi-tiles within the KPI strip. */
details.kpi-tile[open] {
    z-index: 20;
}
/* 2. The KPI strip's own wrapper (.relative.z-10 on the grid in
   account_pipeline_board.html) raises the whole strip — dropdown included —
   above the Kanban board section that follows it in the DOM, whose
   .pipeline-card items would otherwise paint on top of an open dropdown
   despite it being z-10/20 internally, since that z-index only resolved
   against the tile's own stacking context, not the unrelated one each
   pipeline-card gets from the same animation rule. */
@media (prefers-reduced-motion: reduce) {
    .attention-feed-grid > *, .pipeline-card, .kpi-tile, .card { animation: none !important; transition: none !important; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   7. Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-lg);
    transition: transform 0.15s var(--ease-brand), box-shadow 0.2s var(--ease-brand), filter 0.2s ease, background-position 0.4s ease;
    white-space: nowrap;
    cursor: pointer;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    color: #fff;
    background-image: var(--brand-gradient);
    background-size: 160% 100%;
    background-position: 0% 0%;
    box-shadow: var(--shadow-glow);
}
.btn-primary:hover { background-position: 100% 0%; filter: saturate(1.08); }

.btn-secondary {
    color: var(--text-primary);
    background-color: #fff;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--brand-cyan); background-color: var(--brand-tint); }

.btn-ghost {
    color: var(--text-secondary);
    background-color: transparent;
}
.btn-ghost:hover { background-color: var(--bg-tertiary); color: var(--text-primary); }

/* ==========================================================================
   8. Loaders
   ========================================================================== */

/* Top-of-page route progress bar — driven by app.js htmx listeners. Signature
   motion element: the brand gradient "in transit" between pages, echoing the
   product's own subject (freight always moving along a route). */
#route-loader {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0%;
    z-index: 9999;
    background-image: var(--brand-gradient);
    background-size: 200% 100%;
    animation: gradientX 2s linear infinite;
    box-shadow: 0 0 8px rgba(1,182,189,0.6);
    transition: width 0.3s var(--ease-brand), opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
}
#route-loader.is-active { opacity: 1; }
@keyframes gradientX {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Branded spinner: dual-tone conic ring, replaces plain gray htmx spinners. */
.loader-ring {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 2.5px solid var(--brand-tint);
    border-top-color: var(--brand-blue);
    border-right-color: var(--brand-cyan);
    animation: spin 0.7s linear infinite;
}
.loader-ring--sm { width: 1rem; height: 1rem; border-width: 2px; }
.loader-ring--lg { width: 2rem; height: 2rem; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton shimmer for loading placeholders */
.skeleton {
    position: relative;
    overflow: hidden;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
}
.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
    animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ==========================================================================
   9. Sidebar nav — active pill + hover
   ========================================================================== */

.nav-link {
    position: relative;
    color: rgba(255,255,255,0.72);
    transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-link:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.06);
}
.nav-link.is-active {
    color: #fff;
    background-image: var(--brand-gradient);
    box-shadow: 0 6px 16px -4px rgba(1,182,189,0.45);
}

/* ==========================================================================
   10. Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 9999px;
}
.badge-brand { background-color: var(--brand-tint); color: #045C8C; }

/* ==========================================================================
   10b. Mode switch (Customers / Suppliers header toggle)
   ========================================================================== */

.mode-switch {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem;
    border-radius: 9999px;
    background-color: var(--bg-tertiary, #F1F1EF);
    border: 1px solid var(--border-primary);
    gap: 0.15rem;
}
.mode-switch-option {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    color: var(--text-secondary);
    background: transparent;
    transition: color 0.2s ease, background-color 0.2s ease;
}
.mode-switch-option:hover:not(:disabled) {
    color: var(--text-primary);
}
.mode-switch-option:disabled {
    color: #fff;
    background-image: var(--brand-gradient);
    cursor: default;
}

/* ==========================================================================
   11. Login / auth ambient background
   ========================================================================== */

.auth-mesh {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-color: #FAFDFD;
    background-image:
        radial-gradient(55% 55% at 15% 10%, rgba(6,144,217,0.10) 0%, rgba(6,144,217,0) 65%),
        radial-gradient(45% 45% at 85% 25%, rgba(1,182,189,0.10) 0%, rgba(1,182,189,0) 65%),
        radial-gradient(65% 55% at 50% 100%, rgba(1,182,189,0.07) 0%, rgba(1,182,189,0) 65%);
    overflow: hidden;
}
.auth-mesh__orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.35;
    animation: floatSlow 8s ease-in-out infinite;
}
@keyframes floatSlow {
    0%, 100% { transform: translate3d(0,0,0); }
    50% { transform: translate3d(0,-16px,0); }
}
