/*
 * Apollo GHL Extras — Estimates Table + Dashboard
 * Shares base variables with ghl-leads-table.css
 */

/* ------------------------------------------------------------------ */
/*  Estimates table wrapper                                            */
/* ------------------------------------------------------------------ */

.apollo-ghl-estimates-wrap {
    font-family: inherit;
    color: #1a1a1a;
    margin: 1.5rem 0;
}

/* Re-uses .apollo-ghl-* table + toolbar classes from ghl-leads-table.css */

/* ------------------------------------------------------------------ */
/*  Dashboard wrapper                                                  */
/* ------------------------------------------------------------------ */

.apollo-ghl-dashboard-wrap {
    font-family: inherit;
    color: #1a1a1a;
    margin: 1.5rem 0;
}

.apollo-dash-loading {
    text-align: center;
    padding: 2rem;
    color: #9ca3af;
    font-style: italic;
}

/* Header */
.apollo-dash-header { margin-bottom: 1.5rem; }
.apollo-dash-title {
    margin: 0 0 0.25rem;
    font-size: 1.35rem;
    font-weight: 700;
}
.apollo-dash-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
}

/* ------------------------------------------------------------------ */
/*  Metric cards                                                       */
/* ------------------------------------------------------------------ */

.apollo-dash-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.apollo-dash-card {
    flex: 1 1 110px;
    min-width: 100px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    text-align: center;
}

.apollo-dash-card-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.apollo-dash-card-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}

.apollo-dash-card-sub {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.2rem;
}

/* ------------------------------------------------------------------ */
/*  Charts row                                                         */
/* ------------------------------------------------------------------ */

.apollo-dash-charts {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

/* Coverage rate card */
.apollo-dash-coverage {
    flex: 1 1 220px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.apollo-dash-coverage-header {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
}

.apollo-dash-coverage-rate {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}

.apollo-dash-coverage-sub {
    font-size: 0.875rem;
    color: #374151;
}

.apollo-dash-alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.825rem;
    color: #b91c1c;
    font-weight: 600;
}

.apollo-dash-ok {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.825rem;
    color: #166534;
    font-weight: 600;
}

.apollo-dash-estimates-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: #374151;
    padding: 0.25rem 0;
    border-top: 1px solid #f3f4f6;
}

.apollo-dash-estimates-row strong {
    color: #111827;
}

/* Donut chart */
.apollo-dash-donut-wrap {
    flex: 1 1 260px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem;
}

.apollo-dash-donut-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    margin-bottom: 1rem;
}

.apollo-dash-donut {
    width: 180px;
    height: 180px;
    display: block;
    margin: 0 auto 1rem;
}

.apollo-donut-total-num {
    font-size: 1.4rem;
    font-weight: 800;
    fill: #111827;
}

.apollo-donut-total-lbl {
    font-size: 0.7rem;
    fill: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Legend */
.apollo-dash-legend {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.apollo-dash-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.apollo-dash-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.apollo-dash-legend-label {
    flex: 1;
    color: #374151;
}

.apollo-dash-legend-count {
    font-weight: 700;
    color: #111827;
}

/* ------------------------------------------------------------------ */
/*  Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 1024px) {
    /* Dashboard cards — compact grid */
    .apollo-dash-cards { gap: 0.5rem; }
    .apollo-dash-card  { flex: 1 1 70px; min-width: 70px; padding: 0.6rem 0.4rem; }
    .apollo-dash-card-value { font-size: 1.25rem; }
    .apollo-dash-card-label { font-size: 0.6rem; line-height: 1.2; letter-spacing: 0.03em; }

    /* Hide pill buttons on mobile, show select instead */
    .apollo-dash-toolbar .apollo-dash-range-btn { display: none; }
    .apollo-dash-range-select {
        display: block;
        width: 100%;
        height: 38px;
        padding: 0 0.75rem;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        background: #fff;
        font-size: 0.9rem;
        color: #374151;
        cursor: pointer;
        margin-bottom: 0.5rem;
        appearance: auto;
    }

    /* Coverage + donut go full width, stacked */
    .apollo-dash-charts { flex-direction: column; }
    .apollo-dash-coverage,
    .apollo-dash-donut-wrap { flex: 1 1 100%; width: 100%; }
    .apollo-dash-donut { width: 150px; height: 150px; }

    /* Estimates table — shares .apollo-ghl-row styles from ghl-leads-table.css */
    .apollo-ghl-estimates-wrap .apollo-ghl-table-wrap { border: none !important; background: transparent; box-shadow: none; overflow-x: unset; }
    .apollo-ghl-estimates-wrap .apollo-ghl-table { display: block; }
    .apollo-ghl-estimates-wrap .apollo-ghl-table thead { display: none; }
    .apollo-ghl-estimates-wrap .apollo-ghl-table tbody { display: flex; flex-direction: column; gap: 0; }
    /* Estimates: stack label above value so long labels never wrap awkwardly */
    .apollo-ghl-estimates-wrap .apollo-ghl-table td {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
        padding: 0.3rem 0;
    }
    .apollo-ghl-estimates-wrap .apollo-ghl-table td::before {
        min-width: 0;
        white-space: nowrap;
    }
}

/* ------------------------------------------------------------------ */
/*  Dashboard drill-down panel                                         */
/* ------------------------------------------------------------------ */

.apollo-dash-drilldown {
    margin-top: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.apollo-dash-drilldown-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.875rem 1.25rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 1rem;
}

.apollo-dash-drilldown-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.apollo-dash-drilldown-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 0 0.25rem;
}
.apollo-dash-drilldown-close:hover { color: #111; }

.apollo-dash-drilldown-body {
    padding: 1rem 1.25rem;
}

.apollo-dash-drilldown-count {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0 0 0.75rem;
}

.apollo-dash-drilldown-table {
    width: 100%;
}

.apollo-dash-drilldown-pages {
    font-size: 0.875rem;
    color: #6b7280;
    padding: 0 0.5rem;
}

.apollo-dash-donut-hint {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 400;
}

.apollo-donut-slice {
    transition: opacity 0.15s;
}
.apollo-donut-slice:hover { opacity: 0.8; }

.apollo-dash-legend-item:hover .apollo-dash-legend-label,
.apollo-dash-legend-item:hover .apollo-dash-legend-count { color: #111827; }

/* ------------------------------------------------------------------ */
/*  Dashboard date range toolbar                                       */
/* ------------------------------------------------------------------ */

.apollo-dash-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
    align-items: center;
}

.apollo-dash-range-btn {
    padding: 0.35rem 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: #fff;
    font-size: 0.825rem;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.apollo-dash-range-btn:hover { background: #f3f4f6; border-color: #9ca3af; }
.apollo-dash-range-btn.is-active { background: #e0611c; border-color: #e0611c; color: #fff; font-weight: 600; }
.apollo-dash-range-btn.is-primary { background: #e0611c; border-color: #e0611c; color: #fff; }

.apollo-dash-advanced {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.apollo-dash-date-input {
    height: 34px;
    padding: 0 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.apollo-dash-date-sep { font-size: 0.875rem; color: #6b7280; }

/* ------------------------------------------------------------------ */
/*  Drill-down modal                                                   */
/* ------------------------------------------------------------------ */

.apollo-dash-drill-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
    padding-bottom: 1rem;
    overflow-y: auto;
}

.admin-bar .apollo-dash-drill-overlay { padding-top: 132px; }

.apollo-dash-drill-modal {
    background: #fff;
    border-radius: 12px;
    width: 1400px;
    max-width: 98vw;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

/* Smaller font for the drill-down table to fit all columns */
.apollo-dash-drill-table {
    font-size: 0.8rem;
}
.apollo-dash-drill-table th {
    font-size: 0.75rem;
    padding: 0.6rem 0.75rem;
}
.apollo-dash-drill-table td {
    padding: 0.6rem 0.75rem;
}
.apollo-dash-drill-row { border-bottom: 1px solid #f3f4f6; }
.apollo-dash-drill-row:last-child { border-bottom: none; }
.apollo-dash-drill-row:hover { background: #fef5f0; }

/* Drill-down table card view on mobile */
@media (max-width: 1024px) {
    .apollo-dash-drill-table { display: block; font-size: 0.82rem; }
    .apollo-dash-drill-table thead { display: none; }
    .apollo-dash-drill-table tbody { display: flex; flex-direction: column; gap: 0; }
    .apollo-dash-drill-row {
        display: block;
        border: none;
        border-bottom: 1px solid #e5e7eb;
        padding: 0.75rem 0.5rem;
    }
    .apollo-dash-drill-row:first-child { border-top: 1px solid #e5e7eb; }
    .apollo-dash-drill-table td {
        display: flex;
        align-items: baseline;
        gap: 0.4rem;
        padding: 0.2rem 0;
        border: none;
        font-size: 0.825rem;
    }
    .apollo-dash-drill-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #9ca3af;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        min-width: 56px;
        flex-shrink: 0;
    }
}

.apollo-dash-drill-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 1rem;
    z-index: 1;
}

.apollo-dash-drill-body {
    padding: 1rem 1.25rem;
    flex: 1;
}

@media (max-width: 1024px) {
    .apollo-dash-drill-overlay { padding-top: 0; align-items: flex-end; }
    .apollo-dash-drill-modal { max-height: 92vh; border-radius: 12px 12px 0 0; width: 100vw; max-width: 100vw; }
}

/* ================================================================== */
/*  Brand Color Overrides — Estimates & Dashboard                      */
/* ================================================================== */

/* ---- Links in estimates table and dashboard drill-down ---- */
.apollo-ghl-estimates-wrap a,
.apollo-dash-drill-modal a,
.apollo-dash-drill-body a {
    color: #e0611c;
    text-decoration: none;
}
.apollo-ghl-estimates-wrap a:hover,
.apollo-dash-drill-modal a:hover,
.apollo-dash-drill-body a:hover {
    color: #b84d16;
    text-decoration: underline;
}

/* ---- PDF links in estimates ---- */
.apollo-ghl-estimates-wrap .apollo-ghl-pdf-link {
    background: #fdeee6;
    color: #e0611c !important;
    border-color: #f4b894;
}
.apollo-ghl-estimates-wrap .apollo-ghl-pdf-link:hover {
    background: #e0611c !important;
    color: #fff !important;
    border-color: #e0611c;
}

/* ---- Dashboard date range pill buttons ---- */
.apollo-dash-range-btn.is-active,
.apollo-dash-range-btn.is-primary {
    background: #e0611c !important;
    border-color: #e0611c !important;
    color: #fff !important;
}
.apollo-dash-range-btn:hover:not(.is-active):not(.is-primary) {
    border-color: #e0611c;
    color: #e0611c;
}

/* ---- Drill-down modal row hover ---- */
.apollo-dash-drill-row:hover {
    background: #fef5f0 !important;
}

/* ---- Dashboard metric card hover ---- */
.apollo-dash-card[data-status]:hover {
    background: #fef5f0;
    border-color: #f4b894;
}

/* ---- Legend item hover ---- */
.apollo-dash-legend-item:hover .apollo-dash-legend-label,
.apollo-dash-legend-item:hover .apollo-dash-legend-count {
    color: #e0611c;
}

/* ---- Estimates table pagination (shared class, reinforced) ---- */
.apollo-ghl-estimates-wrap .apollo-ghl-page-btn:hover:not([disabled]) {
    background: #e0611c;
    border-color: #e0611c;
    color: #fff;
}
.apollo-ghl-estimates-wrap .apollo-ghl-page-btn.is-current {
    background: #e0611c;
    border-color: #e0611c;
    color: #fff;
}

/* ---- Drill-down modal header dot + close ---- */
.apollo-dash-drill-close:hover {
    color: #e0611c;
}
/* Range select only shows on mobile */
.apollo-dash-range-select { display: none; }
@media (max-width: 768px) {
    .apollo-dash-range-select { display: block; }
}