/* =======================
   SEARCH FORM STYLES
   ======================= */

/* Container - Centered vs Top */
.center-form {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 180px);
    transition: all 0.3s ease;
}

.top-form {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10px;
    min-height: auto;
    transition: all 0.3s ease;
}

/* Top form adjustments - overrides pill form */
.top-form form {
    width: 95% !important;
    background-color: transparent !important;
    border: 1px solid #d3d3d3;
    border-radius: 8px !important;
    padding: 8px 10px;
    box-sizing: border-box;
}

/* Container styles */
.search-hdr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px; /* space between header and form */
}

/* Form styles (pill) */
.search-hdr-container form {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 20px;
    background-color: #f1f1f1;
    border-radius: 50px;
    width: 60%;
}

/* Header styles */
.search-header {
    text-align: center;
}

.search-header h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.search-header p {
    color: #666;
    font-size: 0.95rem;
    margin: 0;
}

/* === Input Groups === */
.input-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    background-color: inherit;
    border-radius: 25px;
    padding: 0 10px;
    height: 40px;
}

.input-group i {
    margin-right: 8px;
    font-size: 1.2rem;
    color: #555;
    display: flex;
    align-items: center;
}

.input-group input[type="text"] {
    border: none;
    outline: none;
    width: 100%;
    height: 100%;
    line-height: normal;
    background: transparent;
    font-size: 1rem;
    padding: 0 4px;
    font-family: "Inter", sans-serif;
}

.search-input {
    flex: 4.5;
}

.search-input input[type="text"] {
    width: 80%;
}

.select-container {
    flex: 2.4;
    position: relative;
}

.top-form .select-container {
    flex: 1;
}

.select-container select {
    border: none;
    outline: none;
    width: 80%;
    padding: 8px;
    font-size: 0.9rem;
    background: transparent;
    line-height: normal;
}

.search-btn {
    flex: 1;
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    white-space: nowrap;
    font-family: "Inter", sans-serif;
}

.search-btn:hover {
    background-color: #000080;
    color: white;
}

.top-form .search-btn {
    border-radius: 0;
    flex: 0.5;
    border-left: 1px solid darkgray;
    background-color: transparent;
    color: dimgray;
    transition: all 0.2s ease;
}

.top-form .search-btn:hover {
    color: black;
}

.search-hdr-container label {
    display: none;
}

.search-hdr-container .top-label {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    color: #333;
    font-family: 'IBM Plex Sans', sans-serif;
}

.clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    cursor: pointer;
    color: #555;
    font-size: 1rem;
    z-index: 2;
}

.clear-btn:hover {
    color: #C71D36;
}

.input-group.search-input input:not(:placeholder-shown) + .clear-btn {
    display: block;
}

/* =======================
   SEARCH RESULTS WRAPPER
   ======================= */
.search-results-wrapper.hidden {
    display: none;
}

.search-results-wrapper.visible {
    display: block;
    margin-top: 30px;
}

.filters-and-results {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    width: 95%;
    margin: 0 auto;
    padding-bottom: 20px;
}

.filters-pane {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
}

.filter-pane-hdr {
    margin-bottom: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
    font-family: "Inter", sans-serif;
}

/* =======================
   FILTER GROUPS
   ======================= */
.filter-group {
    margin-bottom: 24px;
}

.filter-hdr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    margin-bottom: 8px;
}

.filter-hdr-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #525252;
    text-transform: uppercase;
    margin-bottom: 8px;
    display: block;
    font-family: "Inter", sans-serif;
}

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

.filter-subgroup-item {
    margin-bottom: 12px;
}

.filter-sublabel {
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    margin-bottom: 6px;
    font-family: "Inter", sans-serif;
}

.filter-group:not(:last-child)::after {
    content: "";
    display: block;
    width: 30px;
    height: 2px;
    background: #f1f5f9;
    margin-top: 20px;
}

.active-filters-hdr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    margin-bottom: 12px;
}

/* =======================
   REGION TABS
   ======================= */
.filter-select-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select-btn:hover {
    border-color: #007bff;
    background: #f8f9fa;
}

.filter-select-btn.has-selection {
    border-color: #007bff;
    background-color: #f0f7ff;
    color: #007bff;
    font-weight: 600;
}

.filter-select-label {
    font-size: 14px;
    color: #333;
    font-family: "Inter", sans-serif;
}

.filter-select-btn.has-selection .filter-select-label {
    color: #007bff;
    font-weight: 500;
}

.filter-select-btn i {
    font-size: 12px;
    color: #666;
    font-family: "Inter", sans-serif;
}

/* =======================
   FLOATING DROPDOWN PANEL
   ======================= */
.filter-dropdown-panel {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 260px;
    max-height: 350px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: "Inter", sans-serif;
}

.filter-dropdown-panel.hidden {
    display: none;
}

/* =======================
   FILTER LISTS (No longer used for main display)
   ======================= */
.filter-list {
    display: none; /* Hidden since we're using select dropdowns */
}

/* =======================
   FILTER SEARCH BOX (Inside dropdown)
   ======================= */
.filter-search-box {
    padding: 0 0 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.filter-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
    font-family: "Inter", sans-serif;
}

.filter-search-input:focus {
    outline: none;
    border-color: #007bff;
}

/* =======================
   CHECKBOX ITEMS
   ======================= */
.filter-item {
    list-style: none;
    font-weight: 300;
    font-size: 0.9rem;
    margin: 2px 0;
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.9rem;
    color: #444;
}

.filter-checkbox-label:hover {
    background-color: #f5f7fb;
}

.filter-checkbox {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #007bff;
}

.filter-label-text {
    flex: 1;
    font-size: 14px;
}

.filter-count {
    margin-left: auto;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    color: #777;
}

/* =======================
   CHECKBOX ITEMS
   ======================= */
.filter-item {
    list-style: none;
    font-weight: 300;
    font-size: 0.9rem;
    margin: 2px 0;
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.filter-checkbox-label:hover {
    background-color: #f5f5f5;
}

.filter-checkbox {
    cursor: pointer;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.filter-label-text {
    flex: 1;
    font-size: 14px;
}

.filter-count {
    font-size: 12px;
    color: #666;
    background-color: #e9ecef;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
    font-weight: 500;
}

/* =======================
   NESTED SECTIONS (for hierarchical regions)
   ======================= */
.filter-nested-section {
    margin: 4px 0;
    border-bottom: 1px solid #f0f0f0;
}

.filter-nested-section:last-child {
    border-bottom: none;
}

.filter-nested-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    font-weight: 500;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 4px;
    transition: background-color 0.15s;
}

.filter-nested-header:hover {
    background-color: #e9ecef;
}

.filter-nested-header span {
    font-size: 13px;
    color: #495057;
}

.filter-nested-header i {
    font-size: 12px;
    color: #6c757d;
}

.filter-nested-content {
    padding-left: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.filter-nested-content.collapsed {
    display: none;
}

/* Nested sections inside nested content */
.filter-nested-content .filter-nested-section {
    margin-left: 8px;
}

.filter-nested-content .filter-nested-header {
    background: transparent;
    font-weight: 400;
    font-size: 12px;
    padding: 6px;
}



/* =======================
   SEARCH RESULTS PANE
   ======================= */
.results-pane {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-left: 20px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

/* Each series link wrapper */
.series-item-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: all 0.2s ease;
}

/* Hide smoothly when filtered */
.series-item-link.hidden {
    opacity: 0;
    transform: scale(0.97);
    pointer-events: none;
    visibility: hidden;
    transition: all 0.2s ease-in-out;
}

/* Individual series card */
.series-item {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    height: 100%;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #ccc;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    word-break: break-word;
}

.s-item-series-code {
    font-weight: 600;
    font-size: 0.8rem;
    font-family: "IBM Plex Sans", sans-serif;
    color: #969696;
}

.s-item-series-title {
    font-family: "Inter", sans-serif;
    font-size: 0.95rem;
}

.s-item-latest {
    margin-top: 10px;
}

.s-item-latest-value {
    font-family: "JetBrains Mono", monospace;
    font-weight: 600;
    color: #000080;
}

.s-item-latest-date {
    font-family: "Inter", sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
}

.s-item-compare {
    font-size: 0.8rem;
    margin-top: 10px;
}

.s-item-trend.up { color: green; }
.s-item-trend.down { color: red; }
.s-item-trend.neutral { color: grey; }

.s-item-change {
    font-family: "JetBrains Mono", monospace;
    font-weight: 500;
}

.s-item-period-compared {
    font-family: "Inter", sans-serif;
}

.series-item:hover {
    background: #F8F9F9;
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

/* =======================
   FILTER TAGS / ACTIVE FILTERS
   ======================= */
.active-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Header stays on top */
.active-filters-hdr {
    font-weight: 600;
}

/* Tags container (inline flow) */
.active-filters-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

/* Hide Active Filters section when there are no tags */
.active-filters:not(:has(.filter-tag)) {
    display: none;
}

.filter-tag {
    background: white;
    color: #3B3B3B;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #8EC5FF;
    font-family: "Inter", sans-serif;
}

.filter-tag:hover {
    background: #F9FAFB;
}

.filter-tag i {
    margin-left: 5px;
    cursor: pointer;
    font-size: 1.4em;
}

.filter-tag i:hover {
    color: #dc2626;
    cursor: pointer;
}

/* =======================
   PAGINATION
   ======================= */
.series-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.series-pagination a,
.series-pagination span {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #ccc;
    border-radius: 0;
    text-decoration: none;
    color: #000;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.series-pagination a:hover {
    background-color: #d3d3d3;
    color: black;
    border-color: #ccc;
}

.series-pagination span.active {
    background-color: #000;
    color: #fff;
    border-color: #000;
    cursor: default;
}

.series-pagination span.disabled {
    color: #aaa;
    border-color: #eee;
    cursor: not-allowed;
}

.series-pagination i.bi {
    font-size: 0.9rem;
}

/* =======================
   LOADING PLACEHOLDERS
   ======================= */
.loading-placeholder {
    background: linear-gradient(100deg, #f0f0f0 40%, #e0e0e0 50%, #f0f0f0 60%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite linear;
    border-radius: 8px;
    height: 120px;
    opacity: 0.8;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* =======================
   UTILITY CLASSES
   ======================= */
.disabled-filter {
    display: none !important;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 1.1rem;
}

/* =======================
   CLEAR ALL BUTTON STYLES
   ======================= */
.active-filters-hdr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.clear-all-btn {
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    margin-right: 12px;
}

.clear-all-btn:hover {
    background: #fff5f5;
    text-decoration: underline;
}

/* Hide header section entirely if no tags exist */
.active-filters:not(:has(.filter-tag)) {
    display: none;
}