/* FrontCat Modern Category Selector - Refactored */
.fcs-cat-selector-wrapper {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.fcs-cat-selector-wrapper * {
    box-sizing: border-box;
}

/* Reset CSS for inner elements to prevent theme interference */
.fcs-cat-selector-wrapper button,
.fcs-cat-selector-wrapper input[type="text"],
.fcs-cat-selector-wrapper input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    box-shadow: none;
    text-shadow: none;
    outline: none;
    margin: 0;
}

/* --- Input Area --- */
.fcs-cat-input-area {
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    padding: 4px 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.fcs-cat-input-area:hover {
    border-color: #94a3b8;
}

.fcs-cat-input-area.active {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.fcs-cat-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.fcs-pill {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fcs-pill-remove {
    cursor: pointer;
    color: #94a3b8;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    transition: background 0.2s;
}

.fcs-pill-remove:hover {
    background: #fee2e2;
    color: #ef4444;
}

.fcs-cat-search-input {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 6px !important;
    flex: 1;
    min-width: 120px;
    font-size: 14px;
    outline: none !important;
    color: #334155;
    height: auto !important;
    line-height: normal !important;
}

.fcs-cat-arrow {
    margin-left: auto;
    color: #94a3b8;
    display: flex;
    align-items: center;
    padding-right: 4px;
}

/* --- Dropdown --- */
.fcs-cat-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 99999 !important; /* Force high z-index */
    display: none;
    overflow: hidden;
    /* animation: fcsFadeIn 0.2s ease-out; Removed animation to prevent display issues */
}

@keyframes fcsFadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- List & Tree --- */
.fcs-cat-list-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}

.fcs-cat-tree-level {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fcs-cat-children {
    padding-left: 24px; /* Indentation */
    border-left: 1px solid #f1f5f9;
    margin-left: 11px; /* Align line with parent icon center */
}

.fcs-cat-item {
    display: block;
}

.fcs-cat-item-row {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    transition: background 0.15s;
    border-radius: 4px;
    margin: 0 4px;
}

.fcs-cat-item-row:hover {
    background: #f8fafc;
}

.fcs-cat-item-row.is-highlighted {
    background: #f1f5f9; /* For keyboard nav or search highlight */
}

.fcs-cat-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    margin-right: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.fcs-cat-toggle:hover {
    background: #e2e8f0;
    color: #475569;
}

.fcs-cat-toggle.open svg {
    transform: rotate(90deg);
}

.fcs-cat-toggle svg {
    transition: transform 0.2s;
}

.fcs-cat-spacer {
    width: 24px; /* Matches toggle width + margin */
    flex-shrink: 0;
}

.fcs-cat-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin: 0;
    font-weight: 400;
    color: #334155;
    font-size: 14px;
}

.fcs-cat-checkbox {
    width: 16px !important;
    height: 16px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    cursor: pointer;
    margin-right: 8px !important;
    position: static !important;
    /* Revertendo para estilo nativo com accent-color para evitar quebra */
    appearance: auto !important; 
    -webkit-appearance: auto !important;
    -moz-appearance: auto !important;
    accent-color: #2271b1;
    display: inline-block !important;
    background-color: transparent !important;
    flex-shrink: 0 !important;
}

/* Removendo estilos customizados complexos que podem estar quebrando */
.fcs-cat-checkbox:checked {
    background-color: transparent !important;
    border-color: #cbd5e1 !important;
}

.fcs-cat-checkbox:checked::after {
    display: none !important;
}

.fcs-btn-show-add {
    width: auto !important; /* Não ocupar 100% se não necessário, ou manter block com padding */
    display: block !important;
    padding: 8px 12px !important;
    border: 1px dashed #cbd5e1 !important;
    background: #fff !important;
    color: #2271b1 !important; /* Azul por padrão para parecer link */
    border-radius: 6px !important;
    cursor: pointer;
    font-size: 13px !important;
    transition: all 0.2s;
    text-align: center;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    margin-top: 4px !important;
}

.fcs-btn-show-add:hover {
    border-color: #2271b1 !important;
    background: #f0f6fc !important;
}

.fcs-btn-add-sub {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    background: transparent !important;
    color: #cbd5e1 !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    font-size: 18px !important;
    line-height: 1 !important;
    opacity: 0;
    transition: all 0.2s;
    padding: 0 !important;
    margin-left: 8px !important; /* Espaçamento lateral */
}

.fcs-cat-item-row:hover .fcs-btn-add-sub {
    opacity: 1;
}

.fcs-btn-add-sub:hover {
    background: #f0f6fc !important;
    color: #2271b1 !important;
}

.fcs-cat-toggle svg {
    transition: transform 0.2s;
    display: block; /* Fix para alinhamento */
}

.fcs-cat-add-section {
    border-top: 1px solid #e2e8f0;
    padding: 16px 12px; /* Mais padding vertical */
    background: #f8fafc;
    margin-top: 8px; /* Separar da lista */
}

.fcs-btn-show-add {
    width: auto !important;
    display: block !important;
    padding: 10px 16px !important; /* Mais padding interno */
    border: 1px dashed #cbd5e1 !important;
    background: #fff !important;
    color: #2271b1 !important;
    border-radius: 6px !important;
    cursor: pointer;
    font-size: 13px !important;
    transition: all 0.2s;
    text-align: center;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    margin: 4px auto 0 auto !important; /* Centralizar e dar margem */
}

.fcs-new-cat-name {
    width: 100%;
    padding: 10px 12px !important; /* Mais padding no input */
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    font-size: 14px !important; /* Fonte um pouco maior */
    margin-bottom: 12px !important; /* Mais espaço abaixo */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
    background: #fff !important;
    color: #333 !important;
    height: auto !important;
    line-height: normal !important;
}

.fcs-parent-select-wrapper {
    margin-bottom: 16px !important; /* Mais espaço antes dos botões */
}

.fcs-new-cat-parent-select {
    width: 100% !important;
    padding: 8px 10px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    background-color: #fff !important;
    font-size: 13px !important;
    height: auto !important;
    color: #333 !important;
}

.fcs-add-actions {
    display: flex;
    gap: 12px; /* Mais espaço entre botões */
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0; /* Separador sutil */
    margin-top: 8px;
}

.fcs-btn-cancel-new {
    padding: 6px 12px !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    color: #64748b !important;
    font-size: 13px !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    width: auto !important;
    height: auto !important;
    line-height: normal !important;
    margin: 0 !important;
    box-shadow: none !important;
}

.fcs-btn-cancel-new:hover {
    background: #e2e8f0 !important;
    color: #475569 !important;
}

.fcs-btn-save-new {
    padding: 6px 14px !important;
    border: none !important;
    background: #2271b1 !important;
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    transition: background 0.2s;
    text-transform: none !important;
    width: auto !important;
    height: auto !important;
    line-height: normal !important;
    margin: 0 !important;
    box-shadow: none !important;
}

.fcs-btn-save-new:hover {
    background: #135e96 !important;
    transform: translateY(-1px);
    color: #fff !important;
}
