/* CRM Admin Layout - 2 Column Layout with Top Filters */

/* Apply only to CRM app pages */
.app-crm .change-list {
    /* Override the default flex layout */
    display: block !important;
}

/* Top filters container */
.app-crm #changelist-filter-top {
    background: var(--darkened-bg);
    border: 1px solid var(--hairline-color);
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Filter header (always visible) */
.app-crm .filter-header {
    padding: 12px 15px;
    cursor: pointer;
    user-select: none;
    background: var(--primary);
    color: var(--primary-fg);
    transition: background-color 0.2s ease;
}

.app-crm .filter-header:hover {
    background: var(--secondary);
}

.app-crm .filter-header h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
}

/* Toggle icon */
.app-crm .filter-toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    display: inline-block;
    width: 12px;
}

/* Active filters count indicator */
.app-crm .active-filters-count {
    font-size: 0.75rem;
    font-weight: normal;
    opacity: 0.9;
    margin-left: auto;
}

/* Filter content (collapsible) */
.app-crm .filter-content {
    padding: 15px;
    max-height: 1000px;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

/* Collapsed state */
.app-crm #changelist-filter-top.collapsed .filter-content {
    max-height: 0;
    opacity: 0;
    padding: 0 15px;
    overflow: hidden;
}

/* Expanded state */
.app-crm #changelist-filter-top.expanded .filter-content {
    max-height: 1000px;
    opacity: 1;
    padding: 15px;
}

/* Horizontal filter layout */
.app-crm .filter-horizontal {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

.app-crm .filter-item {
    flex: 0 0 auto;
    min-width: 200px;
}

.app-crm .filter-item h3,
.app-crm .filter-item details summary {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--body-fg);
    font-size: 0.875rem;
}

.app-crm .filter-item ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-crm .filter-item li {
    margin: 0;
    padding: 2px 0;
}

.app-crm .filter-item a {
    display: inline-block;
    color: var(--body-quiet-color);
    text-decoration: none;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.8125rem;
}

.app-crm .filter-item a:hover {
    background-color: var(--primary);
    color: var(--primary-fg);
}

.app-crm .filter-item li.selected a {
    background-color: var(--link-selected-fg);
    color: var(--primary-fg);
    font-weight: 500;
}

/* Filter controls styling */
.app-crm .filter-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--hairline-color);
}

.app-crm .facet-toggle a,
.app-crm #changelist-filter-clear a {
    font-size: 0.8125rem;
    text-decoration: none;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.app-crm .facet-toggle a {
    color: var(--link-fg);
    background-color: var(--body-bg);
    border: 1px solid var(--border-color);
}

.app-crm .facet-toggle a:hover {
    background-color: var(--primary);
    color: var(--primary-fg);
}

.app-crm #changelist-filter-clear a {
    color: var(--error-fg);
    background-color: rgba(186, 33, 33, 0.1);
    border: 1px solid var(--error-fg);
}

.app-crm #changelist-filter-clear a:hover {
    background-color: var(--error-fg);
    color: white;
}

/* Hide the original right sidebar filter */
.app-crm #changelist-filter {
    display: none !important;
}

/* Adjust main content area to use full width */
.app-crm #changelist {
    display: flex !important;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0;
}

.app-crm #changelist .changelist-form-container {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
}

/* Ensure table uses full available width */
.app-crm #changelist table {
    width: 100% !important;
    table-layout: auto;
}

/* Improve table column spacing */
.app-crm #changelist table th,
.app-crm #changelist table td {
    padding: 8px 12px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .app-crm .filter-horizontal {
        flex-direction: column;
        gap: 15px;
    }

    .app-crm .filter-item {
        min-width: 100%;
    }

    .app-crm .filter-header h2 {
        font-size: 0.85rem;
    }
}

@media (max-width: 767px) {
    .app-crm .filter-header {
        padding: 10px 12px;
    }

    .app-crm .filter-content {
        padding: 12px;
    }

    .app-crm #changelist-filter-top.collapsed .filter-content {
        padding: 0 12px;
    }

    .app-crm #changelist-filter-top.expanded .filter-content {
        padding: 12px;
    }

    .app-crm .filter-horizontal {
        gap: 10px;
    }

    .app-crm .filter-item {
        min-width: 100%;
    }

    .app-crm .filter-header h2 {
        font-size: 0.8rem;
    }
}

/* Details/summary styling for collapsible filters */
.app-crm .filter-item details > summary {
    list-style-type: none;
    cursor: pointer;
    position: relative;
    padding-left: 20px;
}

.app-crm .filter-item details > summary::-webkit-details-marker {
    display: none;
}

.app-crm .filter-item details > summary::before {
    content: '▶';
    position: absolute;
    left: 0;
    top: 0;
    font-size: 0.75rem;
    color: var(--link-hover-color);
    transition: transform 0.2s ease;
}

.app-crm .filter-item details[open] > summary::before {
    transform: rotate(90deg);
}

/* Improve spacing for filter content */
.app-crm .filter-item details > div {
    margin-top: 8px;
    padding-left: 20px;
}
