/* style.css - GIS Filter Bar Web Application Design System */

/* --- TYPOGRAPHY --- */
@font-face {
    font-family: 'Canaro';
    src: url('_fonts/Canaro-Light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'Canaro';
    src: url('_fonts/Canaro-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
}

/* --- VARIABLES & DESIGN TOKENS --- */
:root {
    --color-bg-bar: #54585A;
    --color-accent: #E0004D;
    --color-text-white: #FFFFFF;
    --color-btn-gray: #3F4345;
    /* New button gray color */

    /* Panel Specific Tokens (Light Theme) */
    --color-bg-panel: #FFFFFF;
    --color-text-dark: #1F2937;
    --color-text-muted: #6B7280;
    --color-border-light: #E5E7EB;
    --color-border-dark: #D1D5DB;
    --color-btn-hover-dark: #4E5254;
    --color-btn-hover-light: #F3F4F6;

    --font-family: 'Canaro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --header-height: 60px;
    --transition-speed: 0.3s;
    --transition-curve: cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.12);
    --shadow-dropdown: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* --- CORE RESET --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    width: 100%;
    height: 100%;
    font-family: var(--font-family);
    font-weight: 300;
    background-color: #111214;
    color: var(--color-text-dark);
    overflow: hidden;
}

button {
    font-family: var(--font-family);
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    outline: none;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- INITIAL / EMPTY STATE: BAR REMAINS VISIBLE, FLOATING DADES HIDDEN --- */
body.no-data #floating-dades-btn {
    display: none;
}

/* --- FLOATING DADES BUTTON --- */
.btn-floating {
    display: none;
    /* Only shown when body has no-data class */
    position: fixed;
    top: 22px;
    left: 28px;
    width: 42px;
    height: 42px;
    z-index: 999;
    background-color: var(--color-btn-gray);
    color: var(--color-text-white);
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    transition: all 0.25s var(--transition-curve);
    border: none;
    box-shadow: none;
}

.btn-floating:hover {
    background-color: var(--color-accent);
}

.btn-floating .icon-container svg {
    width: 24px;
    height: 24px;
    fill: var(--color-text-white);
    transition: fill 0.25s var(--transition-curve);
}

/* --- HEADER BAR (60px high) --- */
.header-bar {
    height: var(--header-height);
    background-color: var(--color-bg-bar);
    color: var(--color-text-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: relative;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: transform var(--transition-speed) var(--transition-curve);
    transform: translateY(0);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-grow: 1;
    min-width: 0;
}

/* Data Title */
.data-title {
    font-family: 'Canaro', sans-serif;
    font-weight: 500;
    /* Medium */
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
    transition: color var(--transition-speed);
}



/* --- HEADER ACTIONS & BUTTONS --- */
.btn-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.25s var(--transition-curve);
    position: relative;
}

.btn-icon .icon-container {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon svg {
    width: 24px;
    height: 24px;
    fill: var(--color-text-white);
    transition: fill 0.25s var(--transition-curve);
}

.btn-icon:hover {
    background-color: transparent;
}

.btn-icon:hover svg,
.btn-icon.active svg {
    fill: var(--color-accent);
}

/* Header Dades Button - Grey background, NO frame */
.header-dades-btn {
    background-color: var(--color-btn-gray) !important;
    border: none !important;
}

.header-dades-btn:hover {
    background-color: var(--color-accent) !important;
}

.header-dades-btn:hover svg {
    fill: var(--color-text-white) !important;
}

.header-dades-btn.active {
    background-color: var(--color-accent) !important;
}

.header-dades-btn.active svg {
    fill: var(--color-text-white) !important;
}

/* Header Actions container */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
}

/* --- GEOGRAPHIC FILTERS (DESKTOP) --- */
.header-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 24px;
}

/* --- CUSTOM SELECT DROPDOWNS --- */
.custom-dropdown {
    position: relative;
}

/* Triggers - Grey background, NO frame */
.dropdown-trigger {
    height: 40px;
    padding: 0 16px;
    background-color: var(--color-btn-gray);
    border: none;
    border-radius: 8px;
    color: var(--color-text-white);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    font-weight: 300;
    transition: all 0.25s var(--transition-curve);
    white-space: nowrap;
    max-width: 350px;
}

.dropdown-trigger .trigger-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1;
}

.dropdown-trigger .arrow-icon {
    font-size: 0.65rem;
    transition: transform 0.25s var(--transition-curve);
    color: var(--color-text-white);
    opacity: 0.8;
}

.dropdown-trigger:hover {
    background-color: var(--color-accent);
}

.custom-dropdown.open .dropdown-trigger,
.dropdown-trigger.has-selection {
    background-color: var(--color-accent);
}

.custom-dropdown.open .dropdown-trigger .arrow-icon {
    transform: rotate(180deg);
    opacity: 1;
}

/* Dropdown Menu Overlay - White Background, Dark Text */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border-dark);
    border-radius: 12px;
    box-shadow: var(--shadow-dropdown);
    display: flex;
    flex-direction: column;
    z-index: 1010;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.25s var(--transition-curve);
    color: var(--color-text-dark);
}

.custom-dropdown.open .dropdown-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Dropdown Search Box */
.search-box {
    padding: 10px;
    border-bottom: 1px solid var(--color-border-light);
}

.dropdown-search {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    background-color: var(--color-btn-hover-light);
    border: 1px solid var(--color-border-dark);
    border-radius: 6px;
    color: var(--color-text-dark);
    font-family: var(--font-family);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
}

.dropdown-search:focus {
    border-color: var(--color-bg-bar);
    /* #54585A */
    box-shadow: none;
}

/* Dropdown Options List */
.options-list {
    max-height: 240px;
    overflow-y: auto;
    list-style: none;
    padding: 6px 0;
}

/* Custom Scrollbar for Options */
.options-list::-webkit-scrollbar {
    width: 6px;
}

.options-list::-webkit-scrollbar-track {
    background: transparent;
}

.options-list::-webkit-scrollbar-thumb {
    background: var(--color-border-dark);
    border-radius: 10px;
}

.options-list::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
}

/* Dropdown Item - Dark Text, Light Hover */
.dropdown-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
    user-select: none;
    color: var(--color-text-dark);
}

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

/* Custom Checkbox on Light Theme */
.dropdown-item input[type="checkbox"] {
    display: none;
}

/* Checkbox inside dropdown item is hidden by default (single-select) */
.custom-dropdown .dropdown-item .custom-cb {
    display: none;
}

/* Show checkbox only when dropdown has multiselect-enabled class */
.custom-dropdown.multiselect-enabled .dropdown-item .custom-cb {
    display: flex;
}

.dropdown-item .custom-cb {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border-dark);
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

/* Selected item highlight for single-select mode */
.custom-dropdown:not(.multiselect-enabled) .dropdown-item.selected {
    background-color: var(--color-btn-hover-light);
    color: var(--color-accent);
    font-weight: 500;
}

.dropdown-item input[type="checkbox"]:checked+.custom-cb {
    border-color: var(--color-accent);
    background-color: var(--color-accent);
}

.dropdown-item .custom-cb::after {
    content: "✓";
    font-size: 0.65rem;
    color: var(--color-text-white);
    display: none;
    font-weight: bold;
}

.dropdown-item input[type="checkbox"]:checked+.custom-cb::after {
    display: block;
}

.dropdown-item span.item-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dropdown Footer Actions - Light Gray Background */
.dropdown-footer {
    display: flex;
    align-items: center;
    padding: 10px;
    border-top: 1px solid var(--color-border-light);
    background-color: #F9FAFB;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    gap: 8px;
    height: 48px;
    box-sizing: border-box;
}

/* Clear & Close Cross Button */
.btn-clear-close {
    background: transparent;
    border: none;
    font-size: 1.35rem;
    font-weight: 400;
    cursor: pointer;
    color: var(--color-text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    padding: 0;
    line-height: 1;
    margin-left: auto;
    transition: all 0.2s;
}

.btn-clear-close:hover {
    background-color: var(--color-btn-hover-light);
    color: var(--color-accent);
}



/* Multiselect toggle styles */
.multiselect-toggle-container {
    display: flex;
    align-items: center;
}

.multiselect-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-dark);
    user-select: none;
}

.multiselect-label input[type="checkbox"] {
    display: none;
}

/* Gray custom checkbox */
.custom-cb-gray {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border-dark);
    background-color: #E5E7EB; /* light gray fons */
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.multiselect-label input[type="checkbox"]:checked + .custom-cb-gray {
    border-color: var(--color-accent);
    background-color: var(--color-accent);
}

.custom-cb-gray::after {
    content: "✓";
    font-size: 0.65rem;
    color: var(--color-text-white);
    display: none;
    font-weight: bold;
}

.multiselect-label input[type="checkbox"]:checked + .custom-cb-gray::after {
    display: block;
}

/* Multiselect actions wrapper */
.multiselect-actions {
    display: flex;
    gap: 6px;
}

.dropdown-footer button {
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-reset,
.btn-select-all {
    padding: 4px 8px;
    border-radius: 4px;
    background-color: transparent;
    border: 1px solid var(--color-border-dark);
    color: var(--color-text-dark);
}

.btn-reset:not([disabled]):hover,
.btn-select-all:hover {
    background-color: var(--color-btn-hover-light);
    border-color: #9CA3AF;
}

.btn-reset[disabled] {
    color: var(--color-text-muted);
    border-color: var(--color-border-light);
    cursor: not-allowed;
}

/* --- MAIN CONTENT & IFRAME --- */
.content-area {
    height: calc(100% - var(--header-height));
    height: calc(100dvh - var(--header-height));
    width: 100%;
    position: relative;
    background-color: #111214;
    transition: height var(--transition-speed) var(--transition-curve);
}

#dashboard-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: transparent;
    display: block;
}

/* --- OVERLAY BACKDROPS --- */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--transition-curve);
}

body.drawer-open #dades-drawer-overlay,
body.sidebar-open #more-sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* --- DRAWER LEFT: DADES PANEL (White Background, Dark Text) --- */
.drawer-left {
    position: fixed;
    top: 0;
    left: 0;
    width: 420px;
    height: 100%;
    background-color: var(--color-bg-panel);
    color: var(--color-text-dark);
    z-index: 1600;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform var(--transition-speed) var(--transition-curve), width var(--transition-speed) var(--transition-curve);
    display: flex;
    flex-direction: column;
}

body.drawer-open .drawer-left {
    transform: translateX(0);
}

/* Pinned drawer styles */
body.drawer-pinned #dades-drawer-overlay {
    opacity: 0 !important;
    pointer-events: none !important;
}

body.drawer-pinned .drawer-left {
    transform: translateX(0);
    width: var(--pinned-drawer-width, 420px);
    transition: none;
}

body.drawer-pinned .header-bar,
body.drawer-pinned .content-area {
    margin-left: var(--pinned-drawer-width, 420px);
    width: calc(100% - var(--pinned-drawer-width, 420px));
    transition: margin-left var(--transition-speed) var(--transition-curve), width var(--transition-speed) var(--transition-curve);
}

/* Disable transitions during drag resizing for smooth performance */
body.resizing .header-bar,
body.resizing .content-area,
body.resizing .drawer-left {
    transition: none !important;
}

.drawer-header,
.sidebar-header {
    height: 68px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border-light);
}

.drawer-header h2,
.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--color-text-dark);
}

.drawer-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-header-title h2 {
    margin-left: -6px;
    margin-top: 2px;
}

.btn-home {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--color-text-muted);
    transition: all 0.2s;
    background-color: transparent;
    text-decoration: none;
    cursor: pointer;
    margin-left: -10px;
}

.btn-home:hover {
    color: var(--color-accent);
    background-color: transparent;
}

.btn-home .icon-container {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-home svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: fill 0.25s var(--transition-curve);
}

.drawer-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-pin {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--color-text-muted);
    transition: all 0.2s;
    background-color: transparent;
    margin-top: 6px;
}

.btn-pin:hover {
    color: var(--color-accent);
    background-color: transparent;
}

.btn-pin.active {
    color: var(--color-accent);
}

.btn-pin svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: color 0.25s var(--transition-curve);
}

.btn-close {
    font-size: 1.8rem;
    color: var(--color-text-muted);
    transition: color 0.2s;
    line-height: 1;
}

.btn-close:hover {
    color: var(--color-accent);
}

/* Resize Handle */
.resize-handle {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 1700;
    background-color: transparent;
    transition: background-color 0.2s;
}

.resize-handle:hover,
.resize-handle.resizing {
    background-color: var(--color-accent);
}

.drawer-pinned .resize-handle {
    display: block;
}

/* Filter Grup pills */
.grup-filter-wrapper {
    padding: 20px 24px 12px;
}

.grup-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: #EEEEEE;
    border: 1px solid #E0E0E0;
    color: var(--color-bg-bar);
    /* #54585A */
    transition: all 0.2s;
    white-space: nowrap;
}

.pill:hover {
    background-color: #E2E4E6;
    border-color: #D1D5DB;
    color: var(--color-bg-bar);
}

.pill.active {
    background-color: var(--color-bg-bar);
    /* #54585A */
    border-color: var(--color-bg-bar);
    color: var(--color-text-white);
    font-weight: 500;
}

/* Search input */
.cercador-dades-wrapper {
    padding: 8px 24px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.search-input {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    background-color: var(--color-btn-hover-light);
    border: 1px solid var(--color-border-dark);
    border-radius: 8px;
    color: var(--color-text-dark);
    font-family: var(--font-family);
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--color-bg-bar);
    /* #54585A */
    box-shadow: none;
}

/* Drawer Items List */
.drawer-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.drawer-body::-webkit-scrollbar {
    width: 6px;
}

.drawer-body::-webkit-scrollbar-track {
    background: transparent;
}

.drawer-body::-webkit-scrollbar-thumb {
    background: var(--color-border-dark);
    border-radius: 10px;
}

.dades-list-items {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Data List Item */
.dada-item {
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    background-color: var(--color-bg-panel);
    overflow: hidden;
    transition: all 0.25s var(--transition-curve);
}

.dada-item:hover {
    border-color: #CBD5E1;
    background-color: #e2e4e6;
}

.dada-item.selected {
    border-color: var(--color-bg-bar);
    /* Charcoal gray #54585A */
    background-color: rgba(84, 88, 90, 0.03);
    /* Subtle grey selection tint */
}

.dada-item.selected .dada-name {
    color: var(--color-accent) !important;
    /* Pink/accent color #E0004D */
}

.dada-item-row {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.dada-item-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex-grow: 1;
}

.dada-grup-tag {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--color-bg-bar);
    /* #54585A */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 12px;
}

.dada-name {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--color-text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s;
}

/* Expander Button (mes.svg) */
.btn-expand {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    flex-shrink: 0;
    margin-left: 8px;
}

.btn-expand svg {
    width: 18px;
    height: 18px;
    fill: var(--color-text-muted);
    transition: all 0.25s var(--transition-curve);
}

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

.btn-expand:hover svg {
    fill: var(--color-accent) !important;
    /* Pink/accent color #E0004D */
}

.dada-item.expanded .btn-expand svg {
    transform: rotate(45deg);
    fill: var(--color-accent);
}

/* Expanded Detail panel */
.dada-expanded-panel {
    display: none;
    border-top: 1px solid var(--color-border-light);
    padding: 14px 16px;
    background-color: #F9FAFB;
}

.dada-item.expanded .dada-expanded-panel {
    display: block;
    animation: slide-down 0.25s var(--transition-curve);
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dada-img-preview {
    width: 100%;
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid var(--color-border-light);
    object-fit: cover;
    max-height: 160px;
    background-color: #E5E7EB;
}

.dada-detail-text {
    font-size: 0.85rem;
    color: var(--color-text-dark);
    line-height: 1.45;
    margin-bottom: 10px;
}

.dada-font-text {
    font-size: 0.75rem;
    font-style: italic;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

/* Expanded Detail actions */
.dada-expanded-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-action-link {
    height: 38px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
    background-color: #EEEEEE;
    border: 1px solid #E0E0E0;
    color: var(--color-bg-bar);
    /* #54585A */
}

.btn-action-link svg {
    width: 18px;
    height: 18px;
    fill: var(--color-bg-bar);
    transition: fill 0.2s;
}

.btn-action-link:hover {
    background-color: #E2E4E6;
    border-color: #D1D5DB;
    color: var(--color-bg-bar);
}

.btn-action-link:hover svg {
    fill: var(--color-bg-bar);
}

.external-arrow {
    margin-left: auto;
    color: #9CA3AF;
    font-weight: bold;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.btn-action-link:hover .external-arrow {
    color: var(--color-bg-bar);
}

/* --- SIDEBAR RIGHT: MÉS MENU (White Background, Dark Text) --- */
.sidebar-right {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    height: 100%;
    background-color: var(--color-bg-panel);
    color: var(--color-text-dark);
    z-index: 1600;
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform var(--transition-speed) var(--transition-curve);
    display: flex;
    flex-direction: column;
}

body.sidebar-open .sidebar-right {
    transform: translateX(0);
}

.sidebar-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
}

.sidebar-divider {
    height: 1px;
    background-color: var(--color-border-light);
    margin: 20px 0;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* Options Menu List */
.more-options-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-item-btn {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--color-text-dark);
    background-color: #F9FAFB;
    border: 1px solid var(--color-border-light);
    transition: all 0.2s var(--transition-curve);
    text-align: left;
}

.menu-item-btn .icon-container svg {
    width: 22px;
    height: 22px;
    fill: var(--color-text-muted);
    stroke: var(--color-text-muted);
    transition: fill 0.2s, stroke 0.2s;
}

.menu-item-btn:hover {
    background-color: var(--color-btn-hover-light);
    border-color: var(--color-border-dark);
}

.menu-item-btn:hover .icon-container svg {
    fill: var(--color-accent);
    stroke: var(--color-accent);
}

.menu-item-btn:hover .external-arrow {
    color: var(--color-accent);
}

/* Disabled comparador style */
#btn-menu-comparador[disabled],
#btn-menu-comparador-territorial[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: dashed;
    background-color: transparent;
    border-color: var(--color-border-light);
}

#btn-menu-comparador[disabled]:hover,
#btn-menu-comparador-territorial[disabled]:hover {
    background-color: transparent;
    border-color: var(--color-border-light);
}

#btn-menu-comparador[disabled] svg,
#btn-menu-comparador-territorial[disabled] svg {
    fill: var(--color-text-muted) !important;
    stroke: var(--color-text-muted) !important;
}

/* Dynamic Tags */
.tag-soon {
    font-size: 0.6rem;
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 4px;
    background-color: #E5E7EB;
    color: #4B5563;
    margin-left: auto;
}

/* --- SHARE POPUP MODAL --- */
.modal-wrapper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 2000;
    width: 480px;
    max-width: 90%;
    background-color: var(--color-bg-panel);
    color: var(--color-text-dark);
    border: 1px solid var(--color-border-dark);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s var(--transition-curve);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

body.modal-open .modal-wrapper {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

body.modal-open .modal-overlay {
    opacity: 1;
    pointer-events: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 500;
}

.modal-body {
    padding: 24px;
}

.share-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 14px;
}

.share-url-container {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

#share-url-input {
    flex-grow: 1;
    height: 40px;
    padding: 0 12px;
    background-color: var(--color-btn-hover-light);
    border: 1px solid var(--color-border-dark);
    border-radius: 8px;
    color: var(--color-text-dark);
    font-family: var(--font-family);
    font-size: 0.8rem;
    outline: none;
}

.btn-accent {
    background-color: var(--color-accent);
    color: var(--color-text-white);
    padding: 0 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-accent:hover {
    background-color: #ff1c6b;
}

/* Toast for URL copied */
.share-toast {
    font-size: 0.8rem;
    color: #10B981;
    text-align: right;
    margin-bottom: 20px;
    height: 18px;
    opacity: 0;
    transition: opacity 0.2s;
}

.share-toast.show {
    opacity: 1;
}

.share-social-title {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.share-social-icons {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.social-btn {
    width: 44px;
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0;
}

.social-btn .icon-container {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-btn svg {
    width: 32px;
    height: 32px;
    fill: var(--color-bg-bar);
    /* #54585A */
    transition: fill 0.2s;
}

.social-btn::after {
    content: "";
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background-color: transparent;
    transition: background-color 0.2s;
}

.social-btn:hover {
    transform: none !important;
}

.social-btn:hover svg {
    fill: #84BD00 !important;
    transform: none !important;
}

.social-btn:hover::after {
    background-color: #84BD00 !important;
}

/* --- RESPONSIVE ADAPTABILITY --- */
.mobile-only {
    display: none;
}

.mobile-filter-indicator {
    display: none;
}

/* --- MOBILE LAYOUT (< 990px) --- */
@media (max-width: 989px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block;
    }

    .mobile-filter-indicator {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        justify-content: center;
        text-align: right;
        color: var(--color-text-white);
        font-size: 0.9rem;
        font-weight: 500;
        line-height: 1.2;
        margin-right: -2px;
        max-width: 38vw;
        height: 42px;
        overflow: hidden;
        cursor: pointer;
        user-select: none;
        transition: color 0.2s, opacity 0.2s;
    }

    .mobile-filter-indicator:hover {
        color: var(--color-accent);
        opacity: 0.95;
    }

    .mobile-filter-indicator-item {
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: right;
        font-weight: 500;
    }

    /* Header layout changes */
    .header-bar {
        padding: 0 12px;
    }

    .data-title {
        font-size: 0.9rem;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.1;
    }

    /* Hide desktop filter navigation */
    .header-filters {
        display: none !important;
    }

    /* Mobile Drawer sizes */
    .drawer-left {
        width: 100%;
        max-width: 320px;
    }

    .sidebar-right {
        width: 100%;
        max-width: 320px;
    }

    /* Floating button resizing and positioning */
    .btn-floating {
        top: 11px;
        left: 12px;
        width: 42px;
        height: 42px;
        padding: 0;
    }

    /* Accordion Filters inside Sidebar */
    .mobile-filters-accordion {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 16px;
    }

    .mobile-filters-accordion .header-filters {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin: 0 !important;
        width: 100% !important;
    }

    /* Custom Dropdown adjustments inside sidebar */
    .mobile-filters-accordion .custom-dropdown {
        width: 100%;
    }

    .mobile-filters-accordion .dropdown-trigger {
        width: 100%;
        max-width: none;
        background-color: var(--color-btn-gray);
        border: none;
    }

    .mobile-filters-accordion .custom-dropdown.open .dropdown-trigger,
    .mobile-filters-accordion .dropdown-trigger.has-selection {
        background-color: var(--color-accent) !important;
    }

    .mobile-filters-accordion .dropdown-menu {
        position: static;
        width: 100%;
        opacity: 1;
        pointer-events: auto;
        transform: none;
        display: none;
        /* Controlled by open class */
        margin-top: 6px;
        border-color: var(--color-border-light);
        box-shadow: none;
        background-color: #F9FAFB;
    }

    .mobile-filters-accordion .custom-dropdown.open .dropdown-menu {
        display: flex;
    }

    .mobile-filters-accordion .options-list {
        max-height: 180px;
    }

    /* Mobile Sidebar Actions */
    .mobile-actions-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .btn-sidebar-action {
        width: 100%;
        height: 44px;
        padding: 0 16px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 0.85rem;
        background-color: #F9FAFB;
        border: 1px solid var(--color-border-light);
        color: var(--color-text-dark);
    }

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

    .btn-sidebar-action svg {
        width: 20px;
        height: 20px;
        fill: var(--color-text-muted);
    }

    .btn-sidebar-action:hover svg {
        fill: var(--color-accent);
    }
}

/* --- ESTILITZACIÓ DE CAMPS NOUS (ESTAT, ZONA, INE) --- */
.dada-item-right-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Badges de l'estat */
.dada-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    font-family: var(--font-family);
}

.badge-star {
    color: #54585A; /* Color gris de la barra demanat pel client */
    font-size: 1.15rem;
    padding: 0;
    font-weight: normal;
    text-transform: none;
}

.badge-beta {
    background-color: transparent;
    color: #E0004D;
    border: none;
    padding: 0;
    font-weight: 500;
}

.badge-nou {
    background-color: transparent;
    color: #84BD00;
    border: none;
    padding: 0;
    font-weight: 500;
}

/* Botó inline CAT al selector de dades */
.btn-dada-zone-cat {
    background-color: #EEEEEE;
    color: var(--color-bg-bar);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s var(--transition-curve);
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #E0E0E0;
    line-height: 1;
    margin-right: -3px; /* mogut 3px més a la dreta, més a prop del més */
}

.btn-dada-zone-cat:hover {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-white);
}

/* Selector de Zona a la barra de filtres */
.zone-selector-wrapper {
    display: flex;
    background-color: var(--color-btn-gray);
    border-radius: 8px;
    padding: 2px;
    align-items: center;
    flex-shrink: 0;
}

.btn-zone {
    height: 36px;
    padding: 0 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-white);
    border-radius: 6px;
    transition: all 0.2s var(--transition-curve);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-zone:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.btn-zone.active {
    background-color: var(--color-accent);
    color: var(--color-text-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Banner d'avís INE al menú de la dreta */
.ine-warning-banner {
    background-color: #FEF2F2;
    border-left: 4px solid var(--color-accent);
    color: #991B1B;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 16px 24px;
    font-weight: 500;
    display: none;
}

/* Nou Sub-filtre (CAT, ★, NOU) */
.sub-filter-wrapper {
    padding: 0 24px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.sub-pill {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    background-color: transparent;
    border: 1px solid #D1D5DB;
    color: var(--color-text-muted);
    transition: all 0.2s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sub-pill:hover {
    background-color: #F3F4F6;
    border-color: #9CA3AF;
    color: var(--color-text-dark);
}

.sub-pill.active {
    background-color: var(--color-bg-bar); /* #54585A */
    border-color: var(--color-bg-bar);
    color: var(--color-text-white);
}

.sub-pill[data-filter="STAR"] {
    font-size: 0.9rem;
    padding: 4px 10px;
    color: #54585A; /* gris de la barra */
    border-color: #D1D5DB;
}

.sub-pill[data-filter="STAR"]:hover {
    background-color: rgba(84, 88, 90, 0.05);
}

.sub-pill[data-filter="STAR"].active {
    background-color: var(--color-bg-bar);
    color: var(--color-text-white);
    border-color: var(--color-bg-bar);
}

/* --- EMBED / COMPARATOR UTILITIES --- */
body.no-header .header-bar {
    display: none !important;
}
body.no-header .content-area {
    height: 100vh !important;
    height: 100dvh !important;
}

body.only-mun #dropdown-espais-wrapper,
body.only-mun #dropdown-comarca-wrapper,
body.only-mun #dropdown-municipi-wrapper,
body.only-mun #zone-selector,
body.only-mun .header-actions,
body.only-mun .multiselect-toggle-container {
    display: none !important;
}