/* ==================================================
   STYLES TREE - UNIQUE CSS CLASSES
   Each selector is unique and separately editable
   ================================================== */

/* ===== MAIN WRAPPER ===== */
.styles-tree-wrapper {
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

/* ===== BASE TREE NODE ===== */
.styles-tree-wrapper-tree-node {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
    clear: both;
}

/* ===== STYLE ITEM SPECIFIC ===== */
.styles-tree-style-item {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
    clear: both;
    margin-bottom: 8px;
    font-size: 16px;
    border-radius: 8px;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
    background: transparent;
}

.styles-tree-style-item:hover {
    background: #21262d;
    border-radius: 8px;
}

.styles-tree-style-item-header {
    display: flex !important;
    align-items: center;
    width: 100%;
    gap: 8px;
    padding: 8px;
    background: transparent;
    border-radius: 8px;
}

/* Legacy content wrapper - replaced by modular blocks */
.styles-tree-style-content-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

/* ===== TREE CHILDREN CONTAINERS ===== */
.styles-tree-regular-children-container {
    display: block;
    width: 100%;
    padding-left: 20px;
    box-sizing: border-box;
    clear: both;
    margin-left: 0;
    border-left: 1px solid #30363d;
}

.styles-tree-variable-children-container {
    display: block;
    width: 100%;
    padding-left: 0;
    box-sizing: border-box;
    clear: both;
    margin-left: 0;
    border-left: none;
}

.styles-tree-direct-value-children-container {
    display: block;
    width: 100%;
    margin-left: 8px;
    padding-left: 16px;
    box-sizing: border-box;
    clear: both;
    border-left: none;
}

/* ===== COLLAPSED STATES ===== */
.styles-tree-regular-children-container.collapsed,
.styles-tree-variable-children-container.collapsed,
.styles-tree-direct-value-children-container.collapsed {
    display: none;
}

/* ===== VARIABLE CHILD ITEMS ===== */
.styles-tree-variable-child-item {
    display: block !important;
    width: 100% !important;
    float: none !important;
    clear: both !important;
    box-sizing: border-box;
    margin-top: 2px;
    margin-bottom: 4px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
    position: relative;
}

.styles-tree-variable-child-item-enhanced {
    display: block !important;
    width: 100% !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
}

.styles-tree-variable-child-force-vertical {
    display: block !important;
    width: 100% !important;
    float: none !important;
    clear: both !important;
    position: static !important;
    flex: none !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    margin: 2px 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

/* ===== VARIABLE CHILD HEADERS ===== */
.styles-tree-variable-child-header {
    display: flex !important;
    width: 100% !important;
    padding: 4px 8px !important;
    margin: 0 !important;
    border-radius: 4px;
    background: rgba(33, 38, 45, 0.3);
    font-size: 0.9em;
    opacity: 0.85;
    cursor: pointer;
    box-sizing: border-box;
}

.styles-tree-variable-child-header:hover {
    background: rgba(33, 38, 45, 0.5);
}

.styles-tree-variable-child-header-generic {
    display: flex !important;
    width: 100% !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 4px 8px !important;
    margin: 0 !important;
    background: rgba(33, 38, 45, 0.3) !important;
    border-radius: 4px !important;
    font-size: 0.9em !important;
    box-sizing: border-box !important;
}

/* ===== VARIABLE CHILD LABELS ===== */
.styles-tree-variable-child-label {
    font-size: inherit;
    color: inherit;
}

.styles-tree-variable-child-label em {
    font-style: italic;
    opacity: 0.7;
    margin-left: 4px;
}

/* ===== VARIABLE CHILD SEPARATORS ===== */
.variable-child-separator {
    padding: 8px 12px 4px;
    margin: 4px 0 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.separator-title {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== DIRECT VALUE SPECIFIC ===== */
/* Direct value child styles inherit from variable child styles */

/* ===== LEGACY COMPATIBILITY (for elements still using old classes) ===== */
.styles-tree-wrapper .tree-node {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
    clear: both;
}

.styles-tree-wrapper .tree-node.style-item {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
    clear: both;
    margin-bottom: 8px;
    font-size: 16px;
    border-radius: 8px;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
    background: transparent;
}

.styles-tree-wrapper .tree-node.style-item:hover {
    background: #21262d;
    border-radius: 8px;
}

/* ===== ENHANCED TREE NODE STYLE ITEM BLOCKS ===== */
/* New modular block structure for better alignment and composition */

/* Main tree node header with improved block layout */
.styles-tree-wrapper .tree-node.style-item > .tree-node-header {
    display: flex !important;
    align-items: center;
    width: 100%;
    gap: 12px; /* Increased gap for better separation */
    padding: 8px;
    background: transparent;
    border-radius: 8px;
    justify-content: space-between; /* Better distribution */
}

/* 1. Main Content Block */
.style-main-content-block {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1; /* Takes remaining space */
    min-width: 0; /* Allow text truncation */
}

/* 1a. Visibility Block (checkbox) */
.style-visibility-block {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.style-visibility-block input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
}

/* 1b. Identity Block (indicator + label) */
.style-identity-block {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; /* Enable text truncation */
}

.style-identity-block .style-indicator {
    flex-shrink: 0; /* Prevent indicator from shrinking */
}

.style-identity-block .tree-node-label {
    flex: 1;
    min-width: 0; /* Enable text truncation */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* 2. Actions Block */
.style-actions-block {
    display: flex;
    align-items: center;
    gap: 8px; /* Increased gap between buttons */
    flex-shrink: 0; /* Prevent buttons from shrinking */
    min-width: 48px;
}

.style-actions-block button {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #8b949e;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, color 0.2s;
    opacity: 0;    padding: 4px;
}

/* Component usage button specific styling to match variables */
.style-actions-block .component-usage-icon {
    color: #8b949e;
    font-family: monospace;
    
}

.style-actions-block .component-usage-icon:hover {
    color: #f2994a;
    background: rgba(242, 153, 74, 0.1);
    
}

.style-actions-block .component-usage-icon:active {
    font-weight: regular;
}


/* Show buttons on style item hover - matching variables behavior */
.tree-node.style-item:hover .style-actions-block button {
    opacity: 1;
}

/* Solo button specific styling to match variables */
.style-actions-block .solo-mode-icon:hover {
    color: var(--accent-primary);
    background: var(--accent-primary-10);
}

.style-actions-block .solo-mode-icon.active {
    opacity: 1;
    color: var(--accent-error);
    background: var(--accent-error-10);
}

/* ===== BACKWARD COMPATIBILITY FOR SIMPLE STYLE ITEMS ===== */
/* Support for style items that don't use the new modular block structure */
.tree-node.style-item:not(:has(.tree-node-header)) {
    display: flex;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: 8px;
}

.tree-node.style-item:not(:has(.tree-node-header)):hover {
    background: #21262d;
}

.tree-node.style-item.active {
    background: rgba(33, 150, 243, 0.2);
    border-left: 3px solid #2196f3;
}

/* Responsive behavior for smaller spaces */
@media (max-width: 300px) {
    .style-main-content-block {
        gap: 4px;
    }
    
    .style-identity-block {
        gap: 4px;
    }
      .style-actions-block {
        gap: 2px;
    }
    
    .style-actions-block button {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

/* ===== EMPTY STATE STYLING ===== */
/* Ensure styles tree empty states are centered like variables tree */
.styles-tree-wrapper .tree-empty-state {
    padding: 32px 16px;
    text-align: center;
    color: #8b949e;
}

.styles-tree-wrapper .tree-empty-message {
    text-align: center;
}

.styles-tree-wrapper .tree-empty-message p {
    margin: 8px 0;
    font-size: 14px;
    text-align: center;
}

.styles-tree-wrapper .tree-empty-help {
    font-size: 12px;
    opacity: 0.7;
    font-style: italic;
    text-align: center;
}
