/* Base Styles */
.taxonomy-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;

    overflow: hidden;
    width: 100%;
    margin: auto;
}

/* Grid Layout */
.taxonomy-display.display-grid {
    display: grid;
    gap: 1rem;
}

.taxonomy-display.columns-1 { grid-template-columns: 1fr; }
.taxonomy-display.columns-2 { grid-template-columns: repeat(2, 1fr); }
.taxonomy-display.columns-3 { grid-template-columns: repeat(3, 1fr); }
.taxonomy-display.columns-4 { grid-template-columns: repeat(4, 1fr); }
.taxonomy-display.columns-5 { grid-template-columns: repeat(5, 1fr); }
.taxonomy-display.columns-6 { grid-template-columns: repeat(6, 1fr); }

/* Item Styles */
.taxonomy-item {
    padding: 1rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    border: 1px solid #eee;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.taxonomy-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

/* Hover animations */
.taxonomy-item::before {
    content: '';
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.03);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 0.5s ease-out;
}

.taxonomy-item:hover::before {
    transform: scaleX(1);
}

.taxonomy-item:hover .taxonomy-icon img {
    transform: scale(1.1);
}

/* Icon Positioning */
.taxonomy-icon img {
    max-width: 100%;
    display: block;
    transition: transform 0.3s ease;
}

/* Left Icon Layout */
.taxonomy-item.icon-left {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.taxonomy-item.icon-left .taxonomy-icon {
    margin-left: 0;
    margin-right: 1rem;
}

.taxonomy-item.icon-left .taxonomy-content {
    flex: 1;
}

/* Right Icon Layout */
.taxonomy-item.icon-right {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
}

.taxonomy-item.icon-right .taxonomy-icon {
    margin-right: 0;
    margin-left: 1rem;
}

.taxonomy-item.icon-right .taxonomy-content {
    flex: 1;
}

/* Top Icon Layout */
.taxonomy-item.icon-top {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.taxonomy-item.icon-top .taxonomy-icon {
    margin: 0 auto 1rem auto;
}

/* Bottom Icon Layout */
.taxonomy-item.icon-bottom {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
}

.taxonomy-item.icon-bottom .taxonomy-icon {
    margin: 1rem auto 0 auto;
}

/* Content Styling */
.taxonomy-content {
    width: 100%;
}

.taxonomy-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    direction: rtl;
}

.taxonomy-name {
    font-weight: 500;
}

.term-count {
    margin-right: 0.5rem;
    font-size: 0.9em;
    color: #666;
}

/* Text Alignment */
.taxonomy-item.text-align-left .taxonomy-content {
    text-align: left;
}

.taxonomy-item.text-align-center .taxonomy-content {
    text-align: center;
}

.taxonomy-item.text-align-center .taxonomy-link {
    justify-content: center;
}

.taxonomy-item.text-align-right .taxonomy-content {
    text-align: right;
}

.taxonomy-item.text-align-right .taxonomy-link {
    justify-content: flex-end;
}

/* Smart mode: parent + context header */
.mohtavanegar-taxonomy-smart-wrap {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.taxonomy-smart-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    direction: rtl;
    text-align: right;
}

.taxonomy-smart-mother-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.85rem;
    background: linear-gradient(135deg, rgba(0, 115, 170, 0.08) 0%, rgba(0, 115, 170, 0.02) 100%);
    border-radius: 10px;
    border: 1px solid rgba(0, 115, 170, 0.12);
}

.taxonomy-smart-mother-icon img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.taxonomy-smart-mother-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.taxonomy-smart-kicker {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

.taxonomy-smart-mother-name {
    font-size: 1rem;
    font-weight: 600;
    color: #0073aa;
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.taxonomy-smart-mother-name:hover {
    color: #005a87;
    opacity: 0.92;
}

.taxonomy-smart-current-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e8ecf0;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.taxonomy-smart-current-card:hover {
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
    border-color: #dce3ea;
}

.taxonomy-smart-current-icon img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.taxonomy-smart-current-body {
    flex: 1;
    min-width: 0;
}

.taxonomy-smart-current-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.taxonomy-smart-current-title {
    margin: 0 0 0.35rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.35;
    color: #0f172a;
}

.taxonomy-smart-current-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.taxonomy-smart-current-title a:hover {
    color: #0073aa;
}

.taxonomy-smart-current-desc {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.55;
    color: #475569;
}

.taxonomy-smart-empty {
    margin: 0;
    padding: 1rem 0.5rem;
    text-align: center;
    color: #64748b;
    font-size: 0.95rem;
}

.taxonomy-display.display-grid .taxonomy-smart-empty {
    grid-column: 1 / -1;
}

/* —— Tree view —— */
.display-tree.taxonomy-display {
    display: block;
    width: 100%;
}

.taxonomy-tree-wrap {
    width: 100%;
    direction: rtl;
}

.taxonomy-tree-branch {
    list-style: none;
    margin: 0;
    padding: 0;
}

.taxonomy-tree-branch .taxonomy-tree-branch {
    margin-inline-start: 0.5rem;
    padding-inline-start: 1.1rem;
    border-inline-start: 2px solid rgba(0, 115, 170, 0.18);
    margin-top: 0.25rem;
}

.taxonomy-tree-item {
    margin: 0.2rem 0;
}

.taxonomy-tree-details {
    margin: 0;
    border-radius: 10px;
    overflow: hidden;
}

.taxonomy-tree-details > summary {
    list-style: none;
    cursor: pointer;
    outline: none;
}

.taxonomy-tree-details > summary::-webkit-details-marker {
    display: none;
}

.taxonomy-tree-details > summary::marker {
    display: none;
    content: '';
}

.taxonomy-tree-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.85rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid #e8ecf0;
    border-radius: 10px;
    background: #fafbfc;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.taxonomy-tree-row:hover {
    background: #fff;
    border-color: #d0dae4;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

.taxonomy-tree-row-parent {
    font-weight: 600;
}

.taxonomy-tree-row-inner {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex: 1;
    min-width: 0;
    width: 100%;
}

.taxonomy-tree-icon {
    flex-shrink: 0;
}

.taxonomy-tree-icon a {
    display: block;
    line-height: 0;
}

.taxonomy-tree-line {
    width: 3px;
    align-self: stretch;
    min-height: 1.5rem;
    border-radius: 3px;
    background: linear-gradient(180deg, rgba(0, 115, 170, 0.35), rgba(0, 115, 170, 0.08));
    flex-shrink: 0;
}

.taxonomy-tree-row-leaf .taxonomy-tree-line {
    background: linear-gradient(180deg, rgba(100, 116, 139, 0.25), rgba(100, 116, 139, 0.06));
}

.taxonomy-tree-link {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    text-decoration: none;
    min-width: 0;
}

.taxonomy-tree-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.taxonomy-tree-count {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: rgba(0, 115, 170, 0.1);
    color: #0073aa;
}

.taxonomy-tree-chevron {
    flex-shrink: 0;
    width: 0.5rem;
    height: 0.5rem;
    margin-inline-start: 0.25rem;
    border-inline-end: 2px solid #64748b;
    border-block-end: 2px solid #64748b;
    transform: rotate(-45deg);
    transition: transform 0.22s ease;
}

.taxonomy-tree-details[open] > summary .taxonomy-tree-chevron {
    transform: rotate(45deg);
}

.taxonomy-tree-details .taxonomy-tree-branch {
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
}

.taxonomy-tree-row:focus-within {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15);
}

.taxonomy-tree-row.text-align-center .taxonomy-tree-row-inner {
    justify-content: center;
}

.taxonomy-tree-row.text-align-center .taxonomy-tree-link {
    justify-content: center;
}

.taxonomy-tree-row.text-align-left .taxonomy-tree-row-inner {
    justify-content: flex-start;
    direction: ltr;
}

/* در حالت RTL والد، «راست» یعنی ابتدای خط؛ flex-start همان لبهٔ راست است */
.taxonomy-tree-row.text-align-right .taxonomy-tree-row-inner {
    justify-content: flex-start;
}
