/* trialcat — main stylesheet
 *
 * TRCL brand system (TRCL-BRAND-STYLE-GUIDE-11APR2026).
 * Colors locked; system fonts per "no typography until Phase 2" meta-rule.
 * Map layout: sidebar-left + map-right, full viewport height.
 */

:root {
    /* --- Brand palette (locked) --- */
    --c-purple: #4a0873;
    --c-purple-80: rgba(74, 8, 115, 0.80);
    --c-purple-60: rgba(74, 8, 115, 0.60);
    --c-purple-30: rgba(74, 8, 115, 0.30);
    --c-green: #5bb545;
    --c-green-soft: #c7e3b1;
    --c-yellow: #e8e52a;
    --c-orange: #f5841f;
    --c-cream: #FAFAF5;
    --c-cream-deep: #f5f1e8;
    --c-border: #e8e4d6;

    /* --- Type (system fonts per brand meta-rule) --- */
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", Monaco, "Cascadia Code", monospace;

    /* --- Layout --- */
    --sidebar-width: 280px;
    --header-height: 56px;
    --footer-height: 40px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--c-purple-80);
    background: var(--c-cream);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--c-purple);
    text-decoration: underline;
    text-decoration-color: var(--c-green);
    text-underline-offset: 2px;
}
a:hover { text-decoration-color: var(--c-orange); }

/* ==========================================================================
   HEADER
   ========================================================================== */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    background: var(--c-purple);
    border-bottom: none;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    height: 28px;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
}

.tagline {
    color: rgba(250, 250, 245, 0.70);
    display: none;
}
@media (min-width: 768px) {
    .tagline { display: inline; }
}

.trcl-link {
    color: rgba(250, 250, 245, 0.60);
    font-size: 12px;
    text-decoration: none;
    border: 1px solid rgba(250, 250, 245, 0.25);
    padding: 4px 10px;
    border-radius: 999px;
    transition: border-color 0.15s, color 0.15s;
}
.trcl-link:hover {
    border-color: var(--c-green);
    color: var(--c-green);
    text-decoration: none;
}

/* ==========================================================================
   APP LAYOUT — sidebar + map
   ========================================================================== */

.app-layout {
    display: flex;
    height: calc(100vh - var(--header-height) - var(--footer-height));
}

/* --- Sidebar --- */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    padding: 16px;
    background: var(--c-cream);
    border-right: 1px solid var(--c-border);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-title {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--c-purple);
}

.filter-group {
    margin-bottom: 12px;
}

.filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-purple-60);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-group select,
.filter-group input[type="date"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--c-border);
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--c-purple-80);
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--c-green);
    box-shadow: 0 0 0 2px rgba(91, 181, 69, 0.2);
}

.btn-apply {
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    background: var(--c-purple);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-apply:hover { background: #5e109a; }

.btn-reset {
    width: 100%;
    padding: 6px;
    margin-top: 6px;
    background: none;
    color: var(--c-purple-60);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.btn-reset:hover {
    border-color: var(--c-purple);
    color: var(--c-purple);
}

/* Sidebar stats summary */
.sidebar-stats {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--c-border);
}

.stats-summary {
    display: flex;
    gap: 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--c-purple);
    line-height: 1.1;
}

.stat-label {
    font-size: 11px;
    color: var(--c-purple-60);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Map --- */

.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(250, 250, 245, 0.85);
    color: var(--c-purple);
    font-weight: 600;
    font-size: 16px;
    z-index: 999;
    pointer-events: none;
}

/* ==========================================================================
   LEAFLET ATTRIBUTION — required for OSM tiles, styled subtler
   ========================================================================== */

.leaflet-control-attribution {
    font-size: 10px !important;
    background: rgba(250, 250, 245, 0.6) !important;
    color: var(--c-purple-60) !important;
    padding: 2px 6px !important;
}
.leaflet-control-attribution a {
    color: var(--c-purple-60) !important;
    text-decoration: none !important;
}

/* ==========================================================================
   POPUP STYLES (Leaflet popup override)
   ========================================================================== */

.trialcat-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(74, 8, 115, 0.15);
    border: 1px solid var(--c-border);
}

.trial-popup h3 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: var(--c-purple);
    font-weight: 700;
}

.trial-popup table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.trial-popup td {
    padding: 3px 8px 3px 0;
    vertical-align: top;
}

.trial-popup td:first-child {
    color: var(--c-purple-60);
    white-space: nowrap;
}

.trial-popup td:last-child {
    text-align: right;
    font-family: var(--font-mono);
}

.trial-popup .section-header {
    font-weight: 600;
    color: var(--c-purple);
    padding-top: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.popup-warning {
    margin: 8px 0 0 0;
    font-size: 11px;
    color: var(--c-orange);
    font-style: italic;
}

/* ==========================================================================
   DRILL-DOWN CONTROLS
   ========================================================================== */

/* Popup action buttons row */
.popup-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

/* "View by state" button inside the US popup */
.popup-drilldown {
    flex: 1;
    padding: 6px 12px;
    background: var(--c-purple);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: background 0.15s;
}
.popup-drilldown:hover { background: var(--c-green); color: var(--c-purple); }

/* "Export CSV" button */
.popup-export {
    flex: 1;
    padding: 6px 12px;
    background: none;
    color: var(--c-purple);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: border-color 0.15s, background 0.15s;
}
.popup-export:hover { border-color: var(--c-purple); background: var(--c-cream-deep); }

/* "Back to world" button on the map (Leaflet custom control) */
.back-to-world-btn {
    background: var(--c-purple);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: background 0.15s;
}
.back-to-world-btn:hover { background: var(--c-green); color: var(--c-purple); }

/* ==========================================================================
   FOOTER
   ========================================================================== */

.app-footer {
    min-height: var(--footer-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: var(--c-cream);
    border-top: 1px solid var(--c-border);
    font-size: 11px;
    color: var(--c-purple-60);
    gap: 2px;
}

.app-footer p {
    margin: 0;
    text-align: center;
    line-height: 1.4;
}

.donate-btn {
    display: inline-block;
    padding: 5px 16px;
    background: var(--c-green);
    color: var(--c-purple) !important;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none !important;
    border-radius: 999px;
    letter-spacing: 0.02em;
    transition: background 0.15s, transform 0.15s;
}
.donate-btn:hover {
    background: var(--c-orange);
    color: #fff !important;
    transform: translateY(-1px);
}

/* ==========================================================================
   RESPONSIVE — collapse sidebar on mobile
   ========================================================================== */

@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        min-width: unset;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--c-border);
    }
    .map-container {
        height: calc(100vh - var(--header-height) - var(--footer-height) - 200px);
    }
    .filter-group { display: inline-block; width: 48%; margin-right: 2%; }
    .btn-apply, .btn-reset { display: inline-block; width: 48%; }
    .sidebar-stats { display: none; }
}
