/**
 * Taxonomy Terms Accordion Widget Styles
 * Modern UI with Glassmorphism
 */

/* ========== CRITICAL: FORCE REMOVE ALL SEPARATORS AND PSEUDO ELEMENTS ========== */
/* This must be first to override any theme/plugin styles */

/* Remove ::after from all term-related elements (these cause comma/separator) */
.psm-term-item::after,
.psm-term-link::after,
.psm-term-name::after,
.psm-term-count::after,
.psm-terms-grid > .psm-term-item::after,
.psm-terms-columns-layout .psm-term-item::after,
div.psm-term-item::after,
a.psm-term-link::after,
span.psm-term-name::after,
span.psm-term-count::after {
    content: none !important;
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

/* Remove ::before from term items and names (but keep ::before on .psm-term-link for hover gradient) */
.psm-term-item::before,
.psm-term-name::before,
.psm-term-count::before {
    content: none !important;
    display: none !important;
    visibility: hidden !important;
}

/* ========== FORCE REMOVE ALL LIST STYLES AND PSEUDO ELEMENTS ========== */
.psm-taxonomy-accordion,
.psm-taxonomy-accordion *,
.psm-taxonomy-accordion *::before,
.psm-taxonomy-accordion *::after,
.psm-taxonomy-accordion *::marker {
    list-style: none !important;
    list-style-type: none !important;
    list-style-image: none !important;
    list-style-position: outside !important;
}

.psm-taxonomy-accordion ul,
.psm-taxonomy-accordion li {
    list-style: none !important;
    list-style-type: none !important;
}

/* Force remove all ::after pseudo-elements from term items */
.psm-term-item::after,
.psm-term-link::after,
.psm-term-name::after,
.psm-term-count::after,
.psm-terms-grid .psm-term-item::after,
.psm-terms-columns-layout .psm-term-item::after,
.psm-terms-column-wrapper .psm-term-item::after {
    content: none !important;
    display: none !important;
}

/* Force display none on markers */
::marker {
    display: none !important;
    content: "" !important;
}

/* ========== CONTAINER ========== */
.psm-taxonomy-accordion {
    width: 100%;
    position: relative;
}

/* ========== TWO COLUMN LAYOUT ========== */
.psm-layout-two-column .psm-two-column-layout {
    display: flex;
    align-items: flex-start;
    gap: 30px;
}

/* THREE COLUMN LAYOUT (when thumbnail is enabled) */
.psm-layout-two-column[data-show-thumbnail="yes"] .psm-two-column-layout {
    display: grid;
    grid-template-columns: 25% 45% 30%;
    gap: 20px;
    align-items: flex-start;
}

.psm-layout-two-column .psm-taxonomies-column {
    position: relative;
    overflow: hidden;
}

.psm-layout-two-column .psm-terms-column {
    position: relative;
    overflow: visible; /* Allow thumbnail to show outside */
    min-height: 300px;
}

/* Thumbnail Column */
.psm-thumbnail-column {
    position: sticky;
    top: 20px;
    height: fit-content;
}

/* Thumbnail Preview Container - All styles controlled via Elementor */

.psm-thumbnail-image {

    max-height: 350px !important;
    display: none !important; /* Hidden by default until hover */
    object-fit: contain !important;
    object-position: center !important;
    opacity: 1 !important;
}

.psm-thumbnail-image[src]:not([src=""]) {
    display: block !important; /* Show only when src is set */
}

/* Responsive thumbnail sizes */
@media (max-width: 1024px) {
    .psm-thumbnail-image {
        width: 100% !important;
        max-width: 100% !important;
        height: 286px !important;
        max-height: 286px !important;
    }
}

@media (max-width: 768px) {
    .psm-thumbnail-image {
        width: 100% !important;
        max-width: 100% !important;
        height: 200px !important;
        max-height: 200px !important;
    }
}

@media (max-width: 480px) {
    .psm-thumbnail-image {
        width: 100% !important;
        max-width: 100% !important;
        height: 150px !important;
        max-height: 150px !important;
    }
}

/* ========== TAXONOMY LIST ========== */
.psm-taxonomy-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px; /* افزایش فاصله بین آیتم‌ها از 8px پیش‌فرض */
}

.psm-taxonomy-item {
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    /* افزایش margin برای جدا کردن بیشتر box‌ها */
    margin-bottom: 4px;
    /* افزودن border برای مشخص‌تر شدن box */
   
}

.psm-taxonomy-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.psm-taxonomy-item.active::before,
.psm-taxonomy-item:hover::before {
    transform: scaleY(1);
}

/* افزودن hover effect واضح‌تر */
.psm-taxonomy-item:hover {
    border-color: rgba(102, 126, 234, 0.3) !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15) !important;
}

.psm-taxonomy-item.active {
    border-color: rgba(102, 126, 234, 0.5) !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25) !important;
}

.psm-taxonomy-title {
    display: block;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    /* افزایش padding برای box بزرگتر */
    padding: 16px 24px !important;
    min-height: 50px; /* حداقل ارتفاع برای target بزرگتر */
    display: flex;
    align-items: center;
}

/* ========== TERMS ========== */
.psm-terms-wrapper {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}

.psm-terms-wrapper.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.psm-terms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    position: relative;
    overflow: visible;
    font-size: 0; /* Remove whitespace between inline elements */
    list-style: none !important; /* Force no list style */
    padding: 0 !important;
    margin: 0 !important;
}

/* Nuclear option: Remove ALL pseudo-elements from grid items */
.psm-terms-grid * {
    list-style: none !important;
}

.psm-terms-grid *::before,
.psm-terms-grid *::after {
    content: none !important;
    display: none !important;
}

/* Except keep the hover gradient on links */
.psm-terms-grid .psm-term-link::before {
    content: "" !important;
    display: block !important;
}

.psm-terms-grid::before,
.psm-terms-grid::after,
.psm-terms-grid::marker {
    content: none !important;
    display: none !important;
}

/* Dynamic columns based on data attribute */
.psm-terms-column[data-columns="1"] .psm-terms-grid {
    grid-template-columns: repeat(1, 1fr);
}

.psm-terms-column[data-columns="2"] .psm-terms-grid {
    grid-template-columns: repeat(2, 1fr);
}

.psm-terms-column[data-columns="3"] .psm-terms-grid {
    grid-template-columns: repeat(3, 1fr);
}

.psm-terms-column[data-columns="4"] .psm-terms-grid {
    grid-template-columns: repeat(4, 1fr);
}

.psm-terms-column[data-columns="5"] .psm-terms-grid {
    grid-template-columns: repeat(5, 1fr);
}

.psm-terms-column[data-columns="6"] .psm-terms-grid {
    grid-template-columns: repeat(6, 1fr);
}

.psm-term-item {
    display: block !important; /* Force block display */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    font-size: 1rem !important; /* Reset font-size */
    list-style: none !important; /* Force no list style */
    list-style-type: none !important;
    list-style-image: none !important;
    list-style-position: outside !important;
    padding-left: 0 !important; /* Remove any padding that might show bullets */
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-right: 0 !important;
}

.psm-term-item::marker {
    display: none !important;
    content: "" !important;
    width: 0 !important;
    height: 0 !important;
}

/* Force no pseudo-element content - MAXIMUM SPECIFICITY */
div.psm-term-item::before,
div.psm-term-item::after,
.psm-terms-grid div.psm-term-item::before,
.psm-terms-grid div.psm-term-item::after,
.psm-terms-columns-layout div.psm-term-item::before,
.psm-terms-columns-layout div.psm-term-item::after,
.elementor-widget-container .psm-term-item::before,
.elementor-widget-container .psm-term-item::after {
    content: none !important;
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
}

/* ========== TERM LINK STYLES ========== */
.psm-term-link {
    display: inline-block;
    text-decoration: none;
    position: relative;
    overflow: visible;
    font-weight: 500;
    list-style: none !important;
    padding: 2px 0;
}

.psm-term-link::marker {
    display: none !important;
    content: none !important;
}

.psm-term-link::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background-color: #000;
    bottom: 0;
    left: 0;
    transform-origin: right;
    transform: scaleX(0);
    transition: transform 0.3s ease-in-out;
}

.psm-term-link:hover::before {
    transform-origin: left;
    transform: scaleX(1);
}

.psm-term-link::after {
    content: none !important;
    display: none !important;
}

/* ========== TERM NAME & COUNT ========== */
.psm-term-name {
    display: inline-block;
    position: relative;
    z-index: 1;
    font-size: 13px !important;
}

.psm-term-name::before,
.psm-term-name::after {
    content: none;
    display: none;
}

.psm-term-count {
    display: inline-block;
    font-size: 9px !important;
    opacity: 0.7;
    font-weight: 600;
    position: relative;
    z-index: 1;
    margin-left: 8px;
}

.psm-no-terms {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* ========== ACCORDION LAYOUT ========== */
.psm-layout-accordion .psm-accordion-items {
    display: flex;
    flex-direction: column;
}

.psm-accordion-item {
    overflow: hidden;
    transition: all 0.3s ease;
}

.psm-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.psm-accordion-icon {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform 0.3s ease;
}

.psm-accordion-item.active .psm-accordion-icon {
    transform: rotate(180deg);
}

.psm-accordion-content {
    display: none;
}

.psm-accordion-content.active {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

/* ========== HORIZONTAL LAYOUT ========== */
.psm-layout-horizontal .psm-taxonomies-row {
    display: flex;
    flex-wrap: wrap;
}

.psm-layout-horizontal .psm-taxonomy-item {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.psm-layout-horizontal .psm-taxonomy-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.psm-layout-horizontal .psm-taxonomy-item.active::after {
    transform: scaleX(1);
}

.psm-layout-horizontal .psm-terms-column {
    min-height: 200px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    /* Stack two-column layout on tablets */
    .psm-layout-two-column .psm-two-column-layout {
        flex-direction: column;
    }
    
    /* Three column grid becomes single column */
    .psm-layout-two-column[data-show-thumbnail="yes"] .psm-two-column-layout {
        grid-template-columns: 1fr;
    }
    
    .psm-layout-two-column .psm-taxonomies-column,
    .psm-layout-two-column .psm-terms-column {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Hover columns - adjust widths for tablets */
    .psm-parent-column {
        flex: 0 0 40%;
        max-width: 40%;
    }
    
    .psm-children-column {
        flex: 0 0 60%;
        max-width: 60%;
    }
    
    /* Reduce grid columns on tablets */
    .psm-terms-column[data-columns] .psm-terms-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 768px) {
    /* Horizontal layout becomes vertical */
    .psm-layout-horizontal .psm-taxonomies-row {
        flex-direction: column;
    }
    
    .psm-layout-horizontal .psm-taxonomy-item::after {
        display: none;
    }
    
    .psm-layout-horizontal .psm-taxonomy-item::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 3px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        transform: scaleY(0);
        transition: transform 0.3s ease;
    }
    
    .psm-layout-horizontal .psm-taxonomy-item.active::before {
        transform: scaleY(1);
    }
    
    /* Hide thumbnail column on mobile */
    .psm-thumbnail-column {
        display: none;
    }
    
    /* Hover columns - stack vertically on mobile */
    .psm-terms-columns-layout {
        flex-direction: column !important;
    }
    
    .psm-parent-column,
    .psm-children-column {
        flex: 1 1 100%;
        max-width: 100%;
        width: 100%;
    }
    
    /* Children appear below parent on mobile */
    .psm-children-column {
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    /* Reduce grid to 2 columns on mobile */
    .psm-terms-column[data-columns] .psm-terms-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    /* Reduce spacing */
    .psm-layout-two-column .psm-two-column-layout {
        gap: 20px;
    }
    
    .psm-taxonomy-list {
        gap: 8px;
    }
    
    .psm-taxonomy-item {
        margin-bottom: 2px;
    }
}

@media (max-width: 480px) {
    /* Single column grid on small mobile */
    .psm-terms-column[data-columns] .psm-terms-grid {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }
    
    /* Optimize font sizes for small screens */
    .psm-term-name {
        font-size: 12px !important;
    }
    
    .psm-term-count {
        font-size: 8px !important;
    }
    
    .psm-taxonomy-title {
        font-size: 14px !important;
    }
    
    /* Larger touch targets */
    .psm-taxonomy-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .psm-term-link {
        padding: 8px 0;
        min-height: 32px;
        display: flex;
        align-items: center;
    }
    
    /* Reduce layout gaps */
    .psm-layout-two-column .psm-two-column-layout {
        gap: 15px;
    }
    
    .psm-taxonomy-list {
        gap: 6px;
    }
}

/* ========== TERM THUMBNAIL - No longer using ::after pseudo-elements ========== */
/* Thumbnails are now displayed in a dedicated third column */

/* ========== COLUMNS LAYOUT (Vertical Stack) ========== */
.psm-terms-columns-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 30px; /* Default gap, can be overridden by column_gap control */
    width: 100%;
    font-size: 0; /* Remove whitespace between inline elements */
}

/* Nuclear option: Remove ALL pseudo-elements from columns layout */
.psm-terms-columns-layout *::before,
.psm-terms-columns-layout *::after {
    content: none !important;
    display: none !important;
}

/* Except keep the hover gradient on links */
.psm-terms-columns-layout .psm-term-link::before {
    content: "" !important;
    display: block !important;
}

.psm-terms-column-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Default gap, can be overridden by row_gap control */
    flex: 1;
    min-width: 0; /* Prevent flex items from overflowing */
    font-size: 1rem; /* Reset font-size for content */
}

.psm-parent-column {
    flex: 0 0 30%;
    max-width: 30%;
}

.psm-children-column {
    flex: 0 0 70%;
    max-width: 70%;
}

/* Terms inside columns layout */
.psm-terms-columns-layout .psm-term-item {
    display: block !important;
    width: 100%;
    list-style: none !important;
    font-size: 1rem !important; /* Reset font-size */
}

.psm-terms-columns-layout .psm-term-link {
    display: block !important;
    width: 100%;
    font-size: 1rem !important; /* Reset font-size */
}

/* Responsive columns layout */
@media (max-width: 1024px) {
    .psm-terms-columns-layout {
        flex-wrap: wrap;
    }
    
    .psm-terms-column-wrapper {
        flex: 1 1 calc(50% - 15px); /* 2 columns on tablets */
        min-width: 250px;
    }
}

@media (max-width: 768px) {
    .psm-terms-column-wrapper {
        flex: 1 1 100%; /* 1 column on mobile */
    }
}

/* ========== HOVER CHILDREN COLUMN ========== */
.psm-terms-columns-layout.psm-has-hover-children {
    position: relative;
}

/* Parent column */
.psm-parent-column .psm-term-item.psm-has-children {
    cursor: pointer;
    position: relative;
}

.psm-parent-column .psm-term-item.psm-has-children .psm-term-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Children indicator arrow */
.psm-has-children-indicator {
    opacity: 0.5;
    transition: all 0.3s ease;
    margin-left: auto;
    padding-left: 10px;
}

.psm-term-item.psm-has-children:hover .psm-has-children-indicator {
    opacity: 1;
    transform: translateX(3px);
}

/* Children column */
.psm-children-column {
  
    padding: 15px !important;
    min-height: 200px;
}

.psm-children-placeholder {
    color: #999;
    font-size: 14px;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.psm-children-content {
    display: none;
}

.psm-children-content.psm-active {
    display: block;
}

/* Hide children data */
.psm-children-data {
    display: none !important;
}

/* Active parent term */
.psm-term-item.psm-active {
    transform: translateX(2px);
}

/* Child terms styling */
.psm-child-term .psm-term-link {
    font-size: 0.95em;
}

.psm-child-level-2 .psm-term-link {
    font-size: 0.9em;
}

.psm-child-level-3 .psm-term-link {
    font-size: 0.85em;
}

.psm-child-indicator {
    opacity: 0.6;
    margin-right: 5px;
}

