/* ============================================
   Dashboards Page
   ============================================ */

/* ---- Page wrapper ---- */

.dash-page {
    min-height: 100vh;
    background: #e8ece6;
    position: relative;
    overflow: hidden;
}

.dash-bg-logo {
    position: absolute;
    inset: 0;
    background: url('/images/veriground-cloud-icon.png') center top / 100% auto repeat-y;
    opacity: 0.06;
    pointer-events: none;
}

/* ---- Dark hero header ---- */

.dash-header {
    background: linear-gradient(170deg, var(--vg-dark, #282a28) 0%, #1a1c1a 100%);
    padding: 6.5rem 2rem 3.5rem;
    position: relative;
    overflow: hidden;
}

.dash-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('/images/hero-cropfield.jpg') center/cover no-repeat;
    opacity: 0.08;
}

.dash-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, #e8ece6);
}

.dash-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

.dash-title {
    font-family: 'Work Sans', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #f0f0f0;
    margin: 0;
    letter-spacing: -0.02em;
}

.dash-subtitle {
    font-size: 0.9rem;
    color: var(--vg-text-light, #c2c2c2);
    margin: 0;
}

/* Shown to a visitor who isn't signed in. */
.dash-signin {
    font-size: 0.9rem;
    color: #f0f0f0;
    margin: 0.75rem 0 0;
}

.dash-signin a {
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
}

/* A search result can link to one card (/dashboards#chart-…): stop it below the fixed navbar. */
.dash-card {
    scroll-margin-top: 120px;
}

.dash-count {
    display: inline-block;
    background: rgba(94, 98, 95, 0.5);
    color: #c8c8c8;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    letter-spacing: 0.04em;
    margin-left: 0.25rem;
}

/* ---- Card grid ---- */

.dash-grid {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .dash-grid {
        grid-template-columns: 1fr;
        padding: 1rem 1rem 3rem;
    }
    /* 130px, not 5rem (70px at this size): the fixed navbar is 101px tall when the rotating tagline pushes
       the menu button onto a second row, and it would cover the title. */
    .dash-header {
        padding: 130px 1rem 2rem;
    }
    .dash-filter-bar {
        padding: 1.25rem 1rem 0;
    }
}

/* Shown when a subscriber's chart token could not be minted: the previews below are still current,
   only the live charts behind them are out of reach. */
.dash-unavailable-note {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 1.25rem auto 0;
    padding: 0.6rem 2rem;
    color: var(--vg-text-muted, #6E6E6E);
    font-size: 0.9rem;
}

/* ---- Category filter chips — shared by the index grid and the in-lightbox
   Dashboards panel, styled per-context below ---- */

.dash-filter-bar {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.25rem 2rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dash-filter-chip {
    font-family: 'Work Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--vg-dark, #282a28);
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 20px;
    padding: 0.35rem 0.9rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.dash-filter-chip:hover {
    border-color: var(--vg-success, #2a7a2a);
    color: var(--vg-success, #2a7a2a);
}

.dash-filter-chip.is-active {
    background: var(--vg-success, #2a7a2a);
    border-color: var(--vg-success, #2a7a2a);
    color: #fff;
}

/* ---- Staggered entrance ---- */

@keyframes dashCardIn {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dash-card {
    opacity: 0;
    animation: dashCardIn 0.45s ease forwards;
}

.dash-card:nth-child(1)  { animation-delay: 0.04s; }
.dash-card:nth-child(2)  { animation-delay: 0.08s; }
.dash-card:nth-child(3)  { animation-delay: 0.12s; }
.dash-card:nth-child(4)  { animation-delay: 0.16s; }
.dash-card:nth-child(5)  { animation-delay: 0.20s; }
.dash-card:nth-child(6)  { animation-delay: 0.24s; }
.dash-card:nth-child(7)  { animation-delay: 0.28s; }
.dash-card:nth-child(8)  { animation-delay: 0.32s; }
.dash-card:nth-child(9)  { animation-delay: 0.36s; }
.dash-card:nth-child(10) { animation-delay: 0.40s; }
.dash-card:nth-child(11) { animation-delay: 0.44s; }
.dash-card:nth-child(12) { animation-delay: 0.48s; }
.dash-card:nth-child(13) { animation-delay: 0.52s; }
.dash-card:nth-child(14) { animation-delay: 0.56s; }

/* ---- Card ---- */

.dash-card {
    cursor: pointer;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #d0d0d0;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

/* Pin the chart (and its ABOUT / GET API bar) to the bottom of the card so the
   bars line up across a row even when titles/descriptions wrap to different
   numbers of lines. Any extra space sits between the text and the chart. */
.dash-card-img-wrap {
    margin-top: auto;
}

.dash-card:hover,
.dash-card:focus-visible {
    transform: translateY(-3px);
}

.dash-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(94, 98, 95, 0.45);
}

.dash-card-img-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #f5f5f5;
    overflow: hidden;
    border-radius: 0 0 14px 14px;
    padding: 2mm;
}

.dash-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.dash-card:hover .dash-card-img,
.dash-card:focus-visible .dash-card-img {
    transform: scale(1.04);
}

.dash-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #aaa;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
}

/* Hover overlay */

.dash-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(2px);
}

.dash-card:hover .dash-card-overlay,
.dash-card:focus-within .dash-card-overlay {
    opacity: 1;
}

.dash-card-overlay-main {
    flex: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(40, 42, 40, 0.72);
    overflow: hidden;
    transition: background 0.15s ease;
}

/* Lighter than the About/GET API hover tint below — this is the primary
   action, so it reads as the brighter of the two hover states. */
.dash-card-overlay-main:hover,
.dash-card:focus-visible .dash-card-overlay-main {
    background: rgba(85, 165, 95, 0.7);
}

.dash-card-overlay-default {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.dash-card-about-text {
    display: none;
    color: #e8e8e8;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.55;
    text-align: center;
    padding: 0.75rem 1.1rem;
    margin: 0;
    white-space: pre-line; /* render \n\n in about text as paragraph breaks */
}

.dash-card.is-about .dash-card-overlay {
    opacity: 1;
}

/* In the About state, the blurb is a clean near-solid panel so the chart
   doesn't bleed through — keeps short and long blurbs looking consistent
   regardless of how bright the underlying thumbnail is. */
.dash-card.is-about .dash-card-overlay-main {
    background: rgba(28, 30, 28, 0.97);
}

.dash-card.is-about .dash-card-overlay-default {
    display: none;
}

.dash-card.is-about .dash-card-about-text {
    display: block;
}

.dash-card-about-text a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* A list in the About text (DashboardMarkup): shown as a list, left-aligned inside the centered panel, with the
   panel's pre-line breaks switched off so the items don't gain blank lines. The panel clips, so keep lists short. */
.dash-card-about-text ul,
.dash-card-about-text ol {
    text-align: left;
    white-space: normal;
    margin: 0.3rem 0;
    padding-left: 1.2rem;
}

.dash-card-about-text a:hover {
    text-decoration-thickness: 2px;
}

/* Bar — split 50/50 */

.dash-card-overlay-bar {
    flex: 1;
    min-height: 44px;
    display: flex;
    background: rgba(20, 22, 20, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.dash-card-overlay-about,
.dash-card-overlay-api {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 22, 20, 0.85);
    border: none;
    color: #d0d0d0;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.dash-card-overlay-about {
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.dash-card-overlay-about:hover,
.dash-card-overlay-about:focus-visible,
.dash-card-overlay-api:hover,
.dash-card-overlay-api:focus-visible {
    background: rgba(58, 125, 68, 0.7);
    color: #fff;
}

.dash-card-title {
    font-family: 'Work Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--vg-dark, #282a28);
    padding: 0.85rem 1rem 0.4rem;
    margin: 0;
}

.dash-card-desc {
    font-size: 0.8rem;
    color: var(--vg-text-muted, #6E6E6E);
    line-height: 1.5;
    padding: 0 1rem 0.6rem;
    margin: 0;
}

/* ---- Staff-only badge ----
   Not visible to real customers (HomeController filters StaffOnly dashboards out of
   their model entirely) — this flags, for staff viewing their own extra entries, which
   cards a customer signed into the same page would not see at all. */

.dash-card-staff {
    position: relative;
    overflow: visible;
    border-color: #a83232;
    border-top-width: 3px;
    box-shadow: 0 4px 24px rgba(168, 50, 50, 0.14);
}

.dash-card-staff .dash-card-title {
    padding-top: 1.75rem;
}

.dash-staff-badge {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    background: #a83232;
    color: #fff;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    padding: 0.28rem 0.85rem;
    border-radius: 0 0 8px 8px;
    white-space: nowrap;
}

/* ---- Lightbox ---- */

.dash-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
}

.dash-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.dash-lightbox-chrome {
    width: 92vw;
    height: 88vh;
    max-width: 1600px;
    background: #1a1a1a;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(140, 184, 135, 0.55),
        0 0 36px rgba(100, 180, 80, 0.22),
        0 0 72px rgba(80, 160, 60, 0.12),
        0 24px 64px rgba(0, 0, 0, 0.65);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.dash-lightbox.active .dash-lightbox-chrome {
    transform: scale(1);
}

.dash-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--vg-dark, #282a28);
    border-bottom: 1px solid #505550;
    flex-shrink: 0;
}

.dash-lightbox-title {
    font-family: 'Work Sans', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* Deliberately off-brand: a bright phosphor green, not --vg-accent — the
   readout motif calls for an actual "green screen" CRT color here. */
.dash-lightbox-title-bracket {
    color: #33ff33;
}

.dash-lightbox-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.dash-lightbox-btn,
.dash-lightbox-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 5px;
    color: #d0d0d0;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    padding: 0.4rem 0.65rem;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.dash-lightbox-nav {
    padding: 0.4rem;
    min-width: 44px;
    justify-content: center;
}

.dash-lightbox-btn:hover,
.dash-lightbox-nav:hover:not(:disabled) {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.12);
}

.dash-lightbox-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.dash-lightbox-btn.dash-lightbox-close:hover {
    border-color: rgba(220, 100, 100, 0.6);
}

.dash-lightbox-esc {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #666;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 5px;
    border-radius: 3px;
}

.dash-lightbox-body {
    flex: 1;
    position: relative;
    background: #fff;
}

.dash-lightbox-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ---- In-lightbox "Dashboards" panel ---- */

.dash-nav-panel {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    flex-direction: column;
    background: rgba(20, 22, 20, 0.97);
    backdrop-filter: blur(6px);
}

.dash-nav-panel.active {
    display: flex;
}

.dash-nav-panel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.dash-nav-panel-chips .dash-filter-chip {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.28);
    color: #d0d0d0;
}

.dash-nav-panel-chips .dash-filter-chip:hover {
    border-color: var(--vg-success-light, #8cb887);
    color: var(--vg-success-light, #8cb887);
}

.dash-nav-panel-chips .dash-filter-chip.is-active {
    background: var(--vg-success, #2a7a2a);
    border-color: var(--vg-success, #2a7a2a);
    color: #fff;
}

.dash-nav-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
}

.dash-nav-panel-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: none;
    border: none;
    border-radius: 6px;
    color: #e8e8e8;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.9rem;
    text-align: left;
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.dash-nav-panel-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.dash-nav-panel-item.is-current {
    background: rgba(58, 125, 68, 0.25);
    color: #fff;
    font-weight: 600;
}

/* ---- Lightbox loading spinner ---- */

.dash-lightbox-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.dash-lightbox-spinner.hidden {
    opacity: 0;
    pointer-events: none;
}

.dash-lightbox-spinner::after {
    content: '';
    width: 36px;
    height: 36px;
    border: 3px solid #ddd;
    border-top-color: var(--vg-accent, #5E625F);
    border-radius: 50%;
    animation: dashSpin 0.7s linear infinite;
}

@keyframes dashSpin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .dash-card {
        animation: none;
        opacity: 1;
    }
    .dash-lightbox-spinner::after {
        animation: none;
    }
}

/* ---- Mobile lightbox ---- */

@media (max-width: 768px) {
    .dash-lightbox-chrome {
        width: 98vw;
        height: 94vh;
        border-radius: 6px;
    }
    .dash-lightbox-header {
        padding: 0.6rem 0.75rem;
    }
    .dash-lightbox-actions {
        gap: 0.3rem;
    }
    .dash-btn-label {
        display: none;
    }
    .dash-lightbox-btn {
        padding: 0.4rem;
        min-width: 44px;
        justify-content: center;
    }
    .dash-nav-panel-chips {
        padding: 1rem 1rem 0.6rem;
    }
}
