/* labels.css */
/**
 * Styles for Labels Management Module
 * Updated to avoid conflicts with rank modal
 */

/* Labels Header - inherits from .menu-option */
.menu-option.labels-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    gap: 8px;
    font-weight: bold;
    width: 100%;
    box-sizing: border-box;
}

/* Ensure the span has the same properties as other menu options */
.menu-option.labels-header span {
    font-size: 14px;
    flex: 1;
    text-align: left;
}

/* Add Label Button - aligned with the row */
.add-label-btn {
    background: transparent;
    border: 1px solid var(--text-tertiary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
    color: var(--text-tertiary);
    flex-shrink: 0;
    margin-left: auto;
}

.add-label-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background: var(--highlight-bg);
    transform: scale(1.05);
}

.add-label-btn:active {
    transform: scale(0.95);
}

.add-label-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2.5;
}

/* Labels List */
.labels-list {
    padding: 4px 8px 4px 36px;
    min-height: 100px; /* Minimum height */
    max-height: var(--labels-height, 300px) !important; /* Use !important to override existing rule */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    margin-top: 0;
    transition: max-height 0.1s ease; /* Smooth resize */
}

.labels-list::-webkit-scrollbar {
    width: 4px;
}

.labels-list::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.labels-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 2px;
}

/* Label Items */
.label-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 2px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    font-size: 14px;
    position: relative;
}

.label-item:hover {
    background: var(--link-hover-bg);
    color: var(--accent-color);
}

.label-item .label-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    flex-shrink: 0;
}

.label-item .label-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Delete Label Button */
.label-delete-btn {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-tertiary);
    opacity: 0;
    transition: all 0.2s ease;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.label-item:hover .label-delete-btn {
    opacity: 0.6;
}

.label-delete-btn:hover {
    opacity: 1 !important;
    color: var(--error-color);
    background: rgba(255, 107, 107, 0.1);
}

.label-delete-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}

/* Messages */
.labels-loading,
.no-labels-message {
    padding: 8px 12px;
    text-align: left;
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 13px;
    margin: 0;
}

/* Label Modal - Using unique class names to avoid conflicts with rank modal */
.label-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.label-modal-dialog {
    width: 400px;
    max-width: 90%;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
}

.label-modal-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.label-modal-header h3 {
    color: var(--accent-color);
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.label-modal-body {
    padding: 0;
    margin-bottom: 12px;
}

.label-modal-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0;
    margin: 0;
}

.label-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    padding: 0;
}

.label-modal-close:hover {
    color: var(--text-primary);
}

/* Label Input Field */
.label-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.label-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.label-input::placeholder {
    color: var(--text-tertiary);
    font-style: italic;
}

.label-input-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: right;
}

/* Create button - assuming you have these styles elsewhere */
.label-modal-footer .circular-button {
    margin-top: 8px;
}

.label-modal-footer .button-label {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Loading state for create button */
.circular-button.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Dark theme adjustments */
[data-theme="dark"] .label-item {
    color: var(--text-primary);
}

[data-theme="dark"] .label-item:hover {
    background: var(--link-hover-bg);
    color: var(--accent-color);
}

[data-theme="dark"] .label-input {
    background: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .label-modal-dialog {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .label-modal-dialog {
        width: 90%;
        max-width: 360px;
    }
    
    .labels-list {
        max-height: 200px;
    }
}

/* Label icon positioning */
/* Label icon positioning - updated without border */
.thread-label-icon {
    position: absolute;
    top: 10px;
    right: 40px; /* Space for delete button */
    background: transparent;
    border: none; /* Removed border */
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-tertiary);
}

.thread-label-icon.labeled {
    /* Removed border-color, just change icon color */
    color: var(--accent-color);
}

.thread-label-icon:hover {
    background: var(--highlight-bg);
    transform: scale(1.05);
}

/* Label display in card - works for both parent and child items */
.thread-label-display {
    display: block;
    font-size: 12px;
    color: #ff8c00; /* Orange color */
    margin-bottom: 3px;
    font-weight: 500;
}

/* Ensure proper spacing for child chains with labels */
.chain-item .thread-label-display {
    margin-top: 2px; /* Small spacing after timestamp */
}

/* Label selector dropdown */
.label-selector-dropdown {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 4px 12px var(--shadow-color);
    min-width: 150px;
    max-width: 250px;
    max-height: 200px;
    overflow-y: auto;
}

.label-option {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.label-option:hover {
    background: var(--link-hover-bg);
    color: var(--accent-color);
}

.label-option.selected {
    background: var(--highlight-bg);
    color: var(--accent-color);
    font-weight: 500;
}

.label-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}