/* ==========================================================================
   CSMAP — Citizen Science Kaart Oost-Nederland
   Design System
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */

:root {
    /* Brand colors */
    --color-primary: #226666;
    --color-primary-light: #2d8080;
    --color-primary-dark: #1a4f4f;
    --color-secondary-1: #EFC155;
    --color-secondary-2: #7A8D60;
    --color-secondary-2-light: #8fa073;
    --color-accent: #FFBF00;

    /* Neutrals */
    --color-neutral-light: #F2F2F2;
    --color-neutral-medium: #888888;
    --color-neutral-dark: #333333;
    --color-white: #FFFFFF;

    /* Haklay level colors (markers + badges) */
    --color-level-1: #A0D8D8;
    --color-level-2: #4CB7B7;
    --color-level-3: #E6A700;
    --color-level-4: #B8443B;
    --color-level-unknown: #CCCCCC;

    /* Semantic */
    --color-yes: #d4edda;
    --color-yes-text: #155724;
    --color-maybe: #fff3cd;
    --color-maybe-text: #856404;
    --color-no: #f8d7da;
    --color-no-text: #721c24;

    /* Typography */
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Open Sans', sans-serif;

    /* Spacing & shapes */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 20px;
    --shadow-subtle: 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-float: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-neutral-dark);
    background: var(--color-neutral-light);
    height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-neutral-dark);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.app-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: var(--color-white);
    color: var(--color-neutral-dark);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    z-index: 1000;
}

.app-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.app-logo {
    height: 52px;
    width: auto;
}

.app-nav {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.app-nav a {
    color: var(--color-neutral-medium);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.app-nav a:hover {
    background: var(--color-neutral-light);
    color: var(--color-neutral-dark);
}

.app-nav a.active {
    background: var(--color-primary);
    color: var(--color-white);
}

.stats-summary {
    font-size: 12px;
    color: var(--color-neutral-medium);
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Map layout: left sidebar + map + right sidebar
   -------------------------------------------------------------------------- */

.map-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.map-container {
    flex: 1;
    min-height: 0;
}

/* --------------------------------------------------------------------------
   Sidebars
   -------------------------------------------------------------------------- */

.sidebar {
    width: 300px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 16px;
}

.sidebar-left {
    background: var(--color-neutral-light);
    border-right: none;
}

.sidebar-right {
    width: 380px;
    background: var(--color-white);
    border-left: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.04);
}

.sidebar-right.hidden {
    display: none;
}

.sidebar h2 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   Filter controls
   -------------------------------------------------------------------------- */

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

.filter-group > label {
    display: block;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-neutral-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.filter-group input[type="text"],
.filter-group input[type="number"] {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 13px;
    background: var(--color-white);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-group input[type="text"]:focus,
.filter-group input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(34, 102, 102, 0.15);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checkbox-group label,
.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.range-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.range-group input {
    width: 80px !important;
}

.filter-results {
    margin-top: 12px;
    font-size: 13px;
    color: var(--color-neutral-dark);
    padding: 10px;
    background: var(--color-white);
    border-radius: var(--radius-md);
}

.filter-results .hint {
    font-size: 11px;
    color: var(--color-neutral-medium);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-white);
    width: 100%;
    margin-bottom: 6px;
}

.btn-primary:hover {
    background: var(--color-primary-light);
}

.btn-secondary {
    background: var(--color-white);
    color: var(--color-neutral-dark);
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.btn-secondary:hover {
    background: var(--color-neutral-light);
}

.btn-accent {
    background: var(--color-accent);
    color: var(--color-neutral-dark);
}

.btn-accent:hover {
    background: #e6ac00;
}

.btn-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--color-primary);
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--color-neutral-medium);
    line-height: 1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}

.btn-close:hover {
    color: var(--color-neutral-dark);
    background: var(--color-neutral-light);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Triage badges */
.badge-yes   { background: var(--color-yes); color: var(--color-yes-text); }
.badge-maybe { background: var(--color-maybe); color: var(--color-maybe-text); }
.badge-no    { background: var(--color-no); color: var(--color-no-text); }

/* Haklay level badges */
.badge-level1  { background: var(--color-level-1); color: #1a5555; }
.badge-level2  { background: var(--color-level-2); color: #fff; }
.badge-level3  { background: var(--color-level-3); color: #5c4300; }
.badge-level4  { background: var(--color-level-4); color: #fff; }
.badge-unknown { background: var(--color-level-unknown); color: #555; }

/* Axis badge */
.badge-axis { background: var(--color-secondary-2); color: #fff; }

.detail-source { font-size: 0.85rem; color: #666; margin: 0.75rem 0 0.25rem; }
.loc-source { font-size: 0.75rem; color: #888; font-style: italic; margin-left: 0.15rem; }

/* Record type badges */
.badge-type-research_output { background: #5B8FB9; color: #fff; }
.badge-type-active_project  { background: #4CB7B7; color: #fff; }
.badge-type-open_call       { background: #E6A700; color: #5c4300; }
.badge-type-resource        { background: #8B6AAE; color: #fff; }

/* --------------------------------------------------------------------------
   Detail panel content
   -------------------------------------------------------------------------- */

#detail-content h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    padding-right: 30px; /* room for close button */
    color: var(--color-primary);
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.detail-meta .date {
    font-size: 12px;
    color: var(--color-neutral-medium);
}

.triage-reason {
    font-size: 12px;
    color: var(--color-neutral-dark);
    font-style: italic;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: var(--color-neutral-light);
    border-radius: var(--radius-md);
}

.confidence-bar {
    height: 20px;
    background: var(--color-neutral-light);
    border-radius: var(--radius-pill);
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-pill);
    transition: width 0.3s;
}

.confidence-bar span {
    position: absolute;
    top: 2px;
    left: 10px;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-neutral-dark);
}

.abstract-toggle {
    margin-bottom: 10px;
}

.abstract-toggle summary {
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 13px;
    color: var(--color-primary);
}

.abstract-toggle p {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--color-neutral-dark);
    max-height: 200px;
    overflow-y: auto;
}

#detail-content h4 {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-neutral-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 14px 0 6px;
}

.author-list {
    list-style: none;
    font-size: 13px;
}

.author-list li {
    padding: 3px 0;
}

.author-list .inst {
    font-size: 11px;
    color: var(--color-neutral-medium);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(34, 102, 102, 0.08);
    color: var(--color-primary);
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   List view
   -------------------------------------------------------------------------- */

.list-layout {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
}

.list-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.list-toolbar input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--color-white);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.list-toolbar input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(34, 102, 102, 0.15);
}

.list-toolbar select {
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--color-white);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-subtle);
}

.data-table th {
    text-align: left;
    padding: 12px 14px;
    background: var(--color-neutral-light);
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-neutral-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 13px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(34, 102, 102, 0.03);
}

.data-table a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.data-table a:hover {
    text-decoration: underline;
}

.list-stats {
    margin-top: 14px;
    font-size: 12px;
    color: var(--color-neutral-medium);
}

.placeholder-text {
    text-align: center;
    color: var(--color-neutral-medium);
    padding: 24px;
}

/* --------------------------------------------------------------------------
   Leaflet overrides
   -------------------------------------------------------------------------- */

.marker-svg {
    background: none !important;
    border: none !important;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-float) !important;
}

.leaflet-popup-content {
    font-family: var(--font-body) !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

.leaflet-popup-content strong {
    font-family: var(--font-heading);
    font-size: 13px;
    color: var(--color-neutral-dark);
}

.leaflet-popup-content em {
    font-size: 11px;
    color: var(--color-neutral-medium);
}

/* --------------------------------------------------------------------------
   Marker cluster overrides
   -------------------------------------------------------------------------- */

.marker-cluster {
    background: none !important;
}

.marker-cluster div {
    width: 36px !important;
    height: 36px !important;
    margin-left: 2px !important;
    margin-top: 2px !important;
    border-radius: 50% !important;
    font-family: var(--font-heading) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--color-white) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.marker-cluster-small {
    background: none !important;
}
.marker-cluster-small div {
    background: var(--color-level-1) !important;
    color: #1a5555 !important;
}

.marker-cluster-medium {
    background: none !important;
}
.marker-cluster-medium div {
    background: var(--color-level-2) !important;
}

.marker-cluster-large {
    background: none !important;
}
.marker-cluster-large div {
    background: var(--color-primary) !important;
}

.marker-cluster-custom {
    background: none !important;
    border: none !important;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .sidebar-left {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .sidebar-right {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        z-index: 2000;
        box-shadow: var(--shadow-float);
    }

    .map-layout {
        flex-direction: column;
    }
}

/* --------------------------------------------------------------------------
   Disclaimer bar
   -------------------------------------------------------------------------- */

.disclaimer-bar {
    background: var(--color-neutral-light);
    color: var(--color-neutral-medium);
    font-family: var(--font-body);
    font-size: 12px;
    text-align: center;
    padding: 6px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.disclaimer-bar a {
    color: var(--color-primary);
    text-decoration: underline;
}
