/**
 * ELM Custom Filter Styles
 */

/* Filter Widget Styles */
.elm-filter-widget-form {
    background: #f9f9f9;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 20px;
}

.elm-filter-form {
    position: relative;
}

.elm-filter-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.elm-filter-section:last-of-type {
    border-bottom: none;
    margin-bottom: 10px;
}

.elm-filter-section h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* Range Input Styles (used for both price and attribute ranges) */
.elm-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
}

.elm-range-input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
    min-width: 0; /* Prevent flex items from overflowing */
    max-width: calc(50% - 10px); /* Ensure inputs don't exceed container */
    box-sizing: border-box;
}

.elm-range-input:focus {
    outline: none;
    border-color: #3c1362;
    box-shadow: 0 0 0 1px #3c1362;
}

.elm-range-separator {
    color: #666;
    font-weight: bold;
    flex-shrink: 0;
    padding: 0 2px;
}

/* Attribute Filter Styles */
.elm-attribute-filter {
    margin-bottom: 15px;
}

.elm-attribute-filter label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 13px;
    color: #333;
}

.elm-attribute-filter select,
.elm-attribute-filter input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

.elm-checkbox-group {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 10px;
    background: #fff;
}

.elm-checkbox-label {
    display: block !important;
    margin-bottom: 8px !important;
    font-weight: normal !important;
    cursor: pointer;
    font-size: 13px !important;
}

.elm-checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    width: auto !important;
}

/* Filter Actions */
.elm-filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.elm-filter-submit,
.elm-filter-reset {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
}

.elm-filter-submit {
    background: #3c1362;
    color: #fff;
}

.elm-filter-submit:hover {
    background: #2a0d44;
    color: #fff;
}

.elm-filter-reset {
    background: #666;
    color: #fff;
}

.elm-filter-reset:hover {
    background: #444;
    color: #fff;
    text-decoration: none;
}

/* Loading State */
.elm-filter-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    z-index: 10;
}

.elm-filter-loading span {
    background: #3c1362;
    color: #fff;
    padding: 10px 20px;
    border-radius: 3px;
    font-size: 14px;
}

/* Filtered Products Indicator */
.elm-filtered-products .woocommerce-result-count::after {
    content: " (filtered)";
    color: #3c1362;
    font-weight: normal;
}

/* Active Filter Tags */
.elm-active-filters {
    margin-bottom: 20px;
    padding: 15px;
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 5px;
}

.elm-active-filters h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #3c1362;
}

.elm-filter-tag {
    display: inline-block;
    background: #3c1362;
    color: #fff;
    padding: 5px 10px;
    margin: 2px;
    border-radius: 15px;
    font-size: 12px;
    text-decoration: none;
}

.elm-filter-tag:hover {
    background: #2a0d44;
    color: #fff;
    text-decoration: none;
}

.elm-filter-tag .remove {
    margin-left: 5px;
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
    .elm-filter-widget-form {
        padding: 15px;
    }
    
    .elm-price-filter .elm-price-inputs {
        flex-direction: column;
        gap: 5px;
    }
    
    .elm-price-separator {
        display: none;
    }
    
    .elm-filter-actions {
        flex-direction: column;
    }
    
    .elm-checkbox-group {
        max-height: 120px;
    }
}

/* Admin Styles */
.elm-admin-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.elm-admin-main {
    flex: 2;
}

.elm-admin-sidebar {
    flex: 1;
}

.elm-admin-box {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.elm-admin-box h3 {
    margin-top: 0;
    color: #23282d;
}

.elm-admin-box ul {
    margin: 10px 0;
    padding-left: 20px;
}

.elm-admin-box code {
    background: #f1f1f1;
    padding: 2px 4px;
    border-radius: 2px;
}

.elm-attributes-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ccd0d4;
}

.elm-add-attribute {
    background: #f9f9f9;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 20px;
}

.elm-status-active {
    color: #46b450;
    font-weight: 600;
}

.elm-status-inactive {
    color: #dc3232;
    font-weight: 600;
}

/* Available Attributes Section */
.elm-available-attributes {
    background: #f9f9f9;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 30px;
}

.elm-available-attributes h3 {
    margin-top: 0;
    color: #23282d;
}

.elm-attributes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.elm-attribute-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    transition: all 0.2s ease;
}

.elm-attribute-card:hover {
    border-color: #3c1362;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.elm-attribute-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.elm-attribute-header h4 {
    margin: 0;
    color: #23282d;
    font-size: 14px;
}

.elm-attribute-source {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

.elm-source-woocommerce {
    background: #96588a;
    color: white;
}

.elm-source-custom {
    background: #3c1362;
    color: white;
}

.elm-attribute-details {
    font-size: 12px;
    color: #666;
}

.elm-attribute-details p {
    margin: 5px 0;
}

.elm-attribute-details code {
    background: #f1f1f1;
    padding: 1px 3px;
    border-radius: 2px;
    font-size: 11px;
}

/* Configuration Builder */
.elm-config-builder {
    background: white;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 30px;
}

.elm-config-builder h3 {
    margin-top: 0;
    color: #23282d;
}

.elm-config-form {
    margin-top: 20px;
}

.elm-config-basic {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 25px;
}

.elm-config-basic .form-table {
    margin: 0;
}

.elm-config-basic .form-table th {
    width: 200px;
    padding: 15px 10px 15px 0;
    vertical-align: top;
}

.elm-config-basic .form-table td {
    padding: 15px 0;
}

.elm-config-basic .form-table th label {
    font-weight: 600;
    color: #23282d;
}

.elm-config-basic .form-table input[type="text"] {
    width: 100%;
    max-width: 400px;
}

.elm-config-basic .form-table .description {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.elm-config-basic .form-table input[type="checkbox"] {
    margin-right: 8px;
}

/* Layer Configuration */
.elm-config-layers {
    margin-bottom: 20px;
}

.elm-config-layers h4 {
    margin-bottom: 10px;
    color: #23282d;
}

.elm-add-layer {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.elm-layer-form {
    margin: 0;
}

.elm-layer-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.elm-layer-select {
    min-width: 200px;
    flex: 1;
}

.elm-layer-stack {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.elm-layer-stack-empty {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    background: #fafafa;
}

.elm-layer-stack-empty .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.elm-layer-stack-empty p {
    margin: 0;
    font-size: 14px;
}

/* Layer Table */
.elm-layers-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.elm-layers-table th {
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #23282d;
    font-size: 13px;
}

.elm-layers-table td {
    padding: 15px;
    border-bottom: 1px solid #f1f1f1;
    vertical-align: middle;
}

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

.elm-layers-table tr:hover {
    background: #f9f9f9;
}

.elm-layer-order {
    background: #3c1362;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    margin-right: 10px;
}

.elm-layer-attribute-name {
    font-weight: 600;
    color: #23282d;
    margin-bottom: 3px;
}

.elm-layer-attribute-key {
    font-size: 11px;
    color: #666;
    font-family: monospace;
    background: #f1f1f1;
    padding: 2px 6px;
    border-radius: 3px;
}

.elm-layer-display-type {
    background: #f1f1f1;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
    display: inline-block;
}

.elm-remove-layer {
    color: #dc3232;
    cursor: pointer;
    padding: 5px;
    border: none;
    background: none;
    font-size: 16px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.elm-remove-layer:hover {
    color: #a00;
    background: #f9f9f9;
}

.elm-drag-handle {
    color: #ccc;
    cursor: move;
    padding: 5px;
    margin-right: 5px;
}

.elm-drag-handle:hover {
    color: #3c1362;
}

.elm-config-actions {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.elm-config-actions .button {
    margin-right: 10px;
}

/* Draggable Attribute Cards */
.elm-attribute-card.draggable {
    cursor: move;
    user-select: none;
}

.elm-attribute-card.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

/* Dropped Attribute Items */
.elm-config-attribute-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.elm-config-attribute-item.sortable-ghost {
    opacity: 0.4;
}

.elm-config-attribute-item .elm-attribute-info {
    flex: 1;
}

.elm-config-attribute-item .elm-attribute-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.elm-config-attribute-item .elm-display-type-select {
    min-width: 150px;
}

.elm-config-attribute-item .elm-remove-attribute {
    color: #dc3232;
    cursor: pointer;
    padding: 5px;
}

.elm-config-attribute-item .elm-drag-handle {
    cursor: move;
    color: #666;
    padding: 5px;
}

.elm-config-attribute-item .elm-drag-handle:hover {
    color: #3c1362;
}

/* WooCommerce Integration */
.woocommerce .elm-filter-widget-form {
    margin-bottom: 30px;
}

.woocommerce-products-header + .elm-filter-widget-form {
    margin-top: 20px;
}

/* Shortcode Styles */
.elm-filter-shortcode {
    margin-bottom: 30px;
}

.elm-filter-shortcode .elm-filter-widget-form {
    margin-bottom: 0;
}

/* Product Count in Filter Options */
.elm-option-count {
    color: #666;
    font-size: 11px;
    margin-left: 5px;
}

/* Filter Toggle for Mobile */
.elm-filter-toggle {
    display: none;
    background: #3c1362;
    color: #fff;
    border: none;
    padding: 10px 15px;
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 15px;
    width: 100%;
}

/* Multi-Select Styles */
.elm-multiselect-group {
    position: relative;
}

.elm-multiselect-toggle {
    width: 100%;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.elm-multiselect-toggle:hover {
    border-color: #3c1362;
}

.elm-toggle-arrow {
    transition: transform 0.2s ease;
}

.elm-multiselect-toggle.open .elm-toggle-arrow {
    transform: rotate(180deg);
}

.elm-multiselect-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 3px 3px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.elm-multiselect-option {
    display: block;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    font-size: 14px;
}

.elm-multiselect-option:hover {
    background-color: #f5f5f5;
}

.elm-multiselect-option:last-child {
    border-bottom: none;
}

.elm-multiselect-option input[type="checkbox"] {
    margin-right: 8px;
}

/* Range Input Styles */
.elm-range-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.elm-range-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

.elm-range-separator {
    color: #666;
    font-weight: bold;
}

.elm-range-display {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

@media (max-width: 768px) {
    .elm-filter-toggle {
        display: block;
    }
    
    .elm-filter-widget-form .elm-filter-form {
        display: none;
    }
    
    .elm-filter-widget-form.elm-filter-open .elm-filter-form {
        display: block;
    }
    
    .elm-range-inputs {
        flex-direction: column;
        gap: 5px;
    }
    
    .elm-range-input {
        width: 100%;
    }
    
    .elm-multiselect-options {
        position: static;
        max-height: 150px;
        border: 1px solid #ddd;
        border-radius: 3px;
        margin-top: 5px;
    }
    
    /* Range inputs responsive styles */
    .elm-range-inputs {
        gap: 6px;
    }
    
    .elm-range-input {
        padding: 8px 6px;
        font-size: 16px; /* Prevent zoom on iOS */
        max-width: calc(50% - 8px);
    }
    
    .elm-range-separator {
        font-size: 14px;
    }
}
